Analog Pins on Windows #11

jcasimir opened this Issue Nov 16, 2012 · 4 comments


None yet

4 participants


I'm trying to run this code:

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

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.


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.


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

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

Thanks! 💯 👍

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