Skip to content
Snippets Groups Projects
Commit 4e8b9364 authored by Per Cederqvist's avatar Per Cederqvist
Browse files

Added comments.

parent 2b89938a
No related branches found
No related tags found
No related merge requests found
...@@ -5,18 +5,32 @@ import pcl_expect.pyserial ...@@ -5,18 +5,32 @@ import pcl_expect.pyserial
import pcl_expect.user import pcl_expect.user
import pcl_expect import pcl_expect
# Open the serial port. You could specify parity, number of bits, and
# a lot of other things here as well. See the pySerial
# documentation.
port = pcl_expect.pyserial.Serial(0, baudrate=9600) port = pcl_expect.pyserial.Serial(0, baudrate=9600)
# We need to listen for input from the user as well. Set the tty in
# RAW mode so that the user can enter Ctrl-C, DEL, Backspace and other
# special characters.
user = pcl_expect.user.User(pcl_expect.user.RAW) user = pcl_expect.user.User(pcl_expect.user.RAW)
x = pcl_expect.Controller() x = pcl_expect.Controller()
while x.loop(): while x.loop():
if x.re(user, "^\035"): if x.re(user, "^\035"):
# Exit once the user hits Ctrl-].
break break
elif x.re(user, "(?s)."): elif x.re(user, "(?s)."):
# Anything else is sent to the seiral port.
port.send(user.consumed) port.send(user.consumed)
elif x.re(port, "..*"): elif x.re(port, "(?s)..*"):
# Anything that arrives from the serial port is sent to the
# user.
user.send(port.consumed) user.send(port.consumed)
elif x.timeout(): elif x.timeout():
# Ignore timeouts.
pass pass
port.close() port.close()
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment