austinbv/dino

Arduino doesn't receive messages for 2 seconds after connection

Closed this issue · 4 comments

I am not sure what causes it but the arduino seems to not get any messages for about 2 seconds after connecting.

Possible places to check

  • IO actually going out
  • board no reading IO
  • IO being off

I realized just now that it's because most of the Arduino boards reset themselves when you connect via the built in serial to USB converter. Article from the Arduino site:

http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection.

In short: a 10uF capacitor between RESET and GROUND will prevent it with the UNO. Most of the other boards require a 120 Ohm resistor between RESET and 5V. Leonardo doesn't auto reset by default.

I've tried the 10uF cap on my UNO and it works. Starts up quickly. It doesn't look like there's anything we can do about this in software though.

good find I thought it was something to do with IO flush for a while. I still think we need to make sure IO is always flushing to the board at execution time rather than buffering. http://www.ruby-doc.org/core-1.9.3/IO.html#method-i-sync is the solution

Both TCPSocket and SerialPort have sync set to true by default. Maybe we should call fsync after each write as well?

http://www.ruby-doc.org/core-1.9.3/IO.html#method-i-fsync

that makes sense