put serial_port in blocking read
This commit is contained in:
@@ -17,6 +17,8 @@ def open_device
|
|||||||
begin
|
begin
|
||||||
# Open connection to serial port
|
# Open connection to serial port
|
||||||
io_device = SerialPort.new("/dev/ttyUSB1", 9600, 7, 1, SerialPort::EVEN)
|
io_device = SerialPort.new("/dev/ttyUSB1", 9600, 7, 1, SerialPort::EVEN)
|
||||||
|
# Make reading blocking
|
||||||
|
io_device.read_timeout = 0
|
||||||
rescue
|
rescue
|
||||||
p "Serialport Error - reverting to 'example_blurp.txt'"
|
p "Serialport Error - reverting to 'example_blurp.txt'"
|
||||||
io_device = File.open("example_blurp.txt")
|
io_device = File.open("example_blurp.txt")
|
||||||
|
|||||||
@@ -24,6 +24,9 @@ if __FILE__ == $0
|
|||||||
|
|
||||||
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
|
sp = SerialPort.new(port_str, baud_rate, data_bits, stop_bits, parity)
|
||||||
|
|
||||||
|
# Make reading blocking
|
||||||
|
sp.read_timeout = 0
|
||||||
|
|
||||||
#just read forever
|
#just read forever
|
||||||
while true do
|
while true do
|
||||||
printf("%c", sp.getc)
|
printf("%c", sp.getc)
|
||||||
|
|||||||
Reference in New Issue
Block a user