diff --git a/demo/read-serial.py b/demo/read-serial.py new file mode 100644 index 0000000000000000000000000000000000000000..96110d24ce60cfb85f0b8635e2c4b91c1e905beb --- /dev/null +++ b/demo/read-serial.py @@ -0,0 +1,18 @@ +# This example opens the first serial port in 4800 bits per second and +# reads input from it. It terminates after 10 consecutive seconds +# with no input. + +import pcl_expect.pyserial +import pcl_expect + +port = pcl_expect.pyserial.Serial(0, baudrate=4800) + +x = pcl_expect.Controller() +while x.loop(): + if x.re(port, "..*"): + print "Got", repr(port.consumed) + elif x.timeout(): + print "Timeout" + break + +port.close()