Reading from a Serial Port with Ruby

Viewed 16421

I'm trying to use ruby to do a simple read + write operation to a serial port.

This is the code I've got so far. I'm using the serialport gem.

require 'rubygems'
require 'serialport'

ser = SerialPort.new("/dev/ttyACM0", 9600, 8, 1, SerialPort::NONE)

ser.write "ab\r\n"
puts ser.read

But the script hangs when it is run.

5 Answers
Related