Analog Pins on Windows #11

Closed
jcasimir opened this Issue Nov 16, 2012 · 4 comments

Projects

None yet

4 participants

@jcasimir

I'm trying to run this code:

http://tutorials.jumpstartlab.com/codenow/nightlight.rb

Based on the second project I wrote up in this tutorial:

http://tutorials.jumpstartlab.com/codenow/introducing_arduino.html

The first project is working fine. This one appears unable to read from the analog pin. Ideas I've tried:

  • Changing the baud rate in the windows device settings
  • Reading from the pin in IRB

I'm not getting anywhere. The on_read callback is never getting triggered. I presume the board is not able to read the pin.

One thing that stood out -- on OS X I have no problem using ctrl-c to break execution while the code runs. On windows, though, it just "hangs." No keyboard input can break the running program. This has me thinking that there's some difference in either how sleep is handled or how the Thread is spun off for the device.

I'm brain dead right now. I hope to look at this again in the morning. I know others probably don't have access to Windows -- but I'd love some ideas of places to investigate.

@mattetti

Try replacing your sleep call with a while or loop loop, you can make it sleep for a little bit in the loop and see if that helps.

@austinbv
Owner

The other is catch a sigterm and close all threads with Thread#join. I thought this would be an issue but it never came up for me before now.

@austinbv austinbv was assigned Nov 17, 2012
@vickash
Collaborator

This was caused by serialport not being able to read whole lines on Windows using gets.

As of 7fcf387, we are using the rubyserial gem, I have made the handshake routine better, and there are a couple other fixes for enumerating the callbacks hash that raised exceptions in Windows.

I have tested that commit extensively on Windows XP and 7 for both input and output and it's more reliable than anything previously done with the serialport gem. However, you must still explicitly specify the COM port. Enumeration doesn't work like in *nix yet.

@vickash vickash closed this Feb 7, 2015
@jcasimir

Thanks! 💯 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment