Ruby – Need assistance with serial port communications in Ruby

communicationrubyserial-port

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

Best Answer

Just because searching for ruby-serialport will lead you sometimes here:

toholio's github repo no longer seems to be active (as of 09/2010). The published gem comes from

http://github.com/hparra/ruby-serialport