sci-bots / base-node-rpc

Base classes for Arduino RPC node/device
0 stars 2 forks source link

Support reconnect of SerialProxy objects #11

Closed ryanfobel closed 7 years ago

ryanfobel commented 7 years ago

Problem

Sometimes it makes sense to intentionally disconnect a SerialProxy object and reconnect (e.g., to flash a firmware update). This is currently possible by terminating the serial thread via the SerialProxy.terminate() method and calling SerialProxy._connect(); however, it could be simplified.

For one, the serial parameters (port, baudrate, settling_time_s, and retry_count) could be cached so that in the case of a reconnect, the SerialProxy._connect() method uses the same parameters from the previously established connection.

Question: should caching these parameters also be the default after an unintentional loss of the serial connection? How does this work now? I think caching it makes sense for most of these parameters; however it is possible that the serial port may change between connections, so maybe we should be trying the previously established port first, and if that fails, try other ports.