arduino_firmata
arduino_firmata copied to clipboard
Process never exits
Whenever my process which is using ArduinoFirmata tries to exit gracefully, it never exits because ArduinoFirmata is stuck.
When I do a CTRL+C, the last few lines of the trace are:
/usr/local/firmata-server/vendor/bundle/ruby/1.9.1/gems/arduino_firmata-0.3.7/lib/arduino_firmata/arduino.rb:85:in `sleep': Interrupt
from /usr/local/firmata-server/vendor/bundle/ruby/1.9.1/gems/arduino_firmata-0.3.7/lib/arduino_firmata/arduino.rb:85:in `block in close'
from /usr/local/firmata-server/vendor/bundle/ruby/1.9.1/gems/arduino_firmata-0.3.7/lib/arduino_firmata/arduino.rb:81:in `loop'
from /usr/local/firmata-server/vendor/bundle/ruby/1.9.1/gems/arduino_firmata-0.3.7/lib/arduino_firmata/arduino.rb:81:in `close'
from /usr/local/firmata-server/vendor/bundle/ruby/1.9.1/gems/arduino_firmata-0.3.7/lib/arduino_firmata/arduino.rb:34:in `block in initialize'
When I add some debugging code to arduino.rb:82, it shows that @serial.closed? == true
and @thread_status == true
.
Looking through the code I would guess that the process_input
thread is stuck on line 195 doing a blocking read. So it it never returns from line 41 to see that @status
has been change to Status::CLOSE
.
I personally don't see why it needs the at_exit do close end
. It'll get closed automatically when the process exits. So perhaps the solution would be to remove that.