shokai / arduino_firmata

Arduino Firmata protocol implementation on Ruby
http://shokai.github.io/arduino_firmata
MIT License
104 stars 23 forks source link

Initialization hangs without nonblock_io option #39

Open phemmer opened 10 years ago

phemmer commented 10 years ago

When attempting to connect, if the nonblock_io option is not passed, it does not connect, and ends up hanging instead. The code by default sets @read_byte_size = 9600, then in the read method, it blocks trying to read 9600 bytes. During connect, when it waits for the version report, it hangs because the version report is only 8 bytes.

Because it is sitting there sending the "version report" command over and over, the responses will eventually fill the buffer and cause the loop to end, but it takes a very long time.