firmata / firmata.js

JavaScript implementation of the Firmata protocol
711 stars 147 forks source link

add exit function to terminate firmata communication #135

Closed ericogr closed 8 years ago

ericogr commented 8 years ago

(close pc seria port)

rwaldron commented 8 years ago

This is a dangerous addition that I don't think should be added. Firmata maintains internal state based on messages sent to and received from the remote board. If the connection is just terminated—what happens to that state? What is its meaning? The calling instance cannot simply "reconnect", because it has a lifecycle that coincides with an active connection to the board—if that connection was severed and reconnected, the board will automattically reset all of its own state; the instance cannot unambiguously reconcile its old state with whatever just happened to the board. If a program really, really wants to load this footgun, the ability to call board.transport.close() already exists and is just the right amount of painful to reach that the author should have to think twice about what they are doing and why.