put serial_port in blocking read

This commit is contained in:
Aart van Halteren
2013-07-17 12:44:26 +02:00
parent fa4dc7d31c
commit 8e7fd64701
2 changed files with 5 additions and 0 deletions

View File

@@ -17,6 +17,8 @@ def open_device
begin
# Open connection to serial port
io_device = SerialPort.new("/dev/ttyUSB1", 9600, 7, 1, SerialPort::EVEN)
# Make reading blocking
io_device.read_timeout = 0
rescue
p "Serialport Error - reverting to 'example_blurp.txt'"
io_device = File.open("example_blurp.txt")

View File

@@ -24,6 +24,9 @@ if __FILE__ == $0
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
# Make reading blocking
sp.read_timeout = 0
#just read forever
while true do
printf("%c", sp.getc)