I need to do some communications over a serial port in Ruby. From my research, it appears that there aren’t many modern libraries for serial communications and the newest material I can find is from 2006. Are there any gems that I’m not aware of?
I ultimately need to maintain communications with a serial device attached to USB (I can figure out the port no problem) for back and forth communications like so (somewhat Ruby-esque pseudo code).
def serial_write_read if serial.read == 'READY' serial.write '1' until serial.read == 'OK' serial.write '5' end return when serial.read == 'DONE' end end
The serial port specification has not changed in forever, I wouldn’t worry about how old the libraries are.
I’m assuming you saw this article from 2006 about ruby and serial ports
Here’s someone who got the Ruby-SerialPort library mentioned there to work on macs this year.
There’s also this old post from ruby talk, about interfacing to the Win32 Serial API.