summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaoyu <shaoyu@life-foundry.com>2018-12-21 14:20:03 -0600
committerShaoyu <shaoyu@life-foundry.com>2018-12-21 14:20:03 -0600
commit226f19f9bfa0ec7d22616751887cb7c00237490a (patch)
tree35b5ab497d2ed05a95263c997f37e467f39076a5
parenta27715f322bb08b1fccffebab776c94df50057e9 (diff)
downloadpyserial-git-226f19f9bfa0ec7d22616751887cb7c00237490a.tar.gz
add bytesize and stopbits argument to parser
-rwxr-xr-xexamples/tcp_serial_redirect.py16
1 files changed, 16 insertions, 0 deletions
diff --git a/examples/tcp_serial_redirect.py b/examples/tcp_serial_redirect.py
index 53dc0ad..6168a35 100755
--- a/examples/tcp_serial_redirect.py
+++ b/examples/tcp_serial_redirect.py
@@ -66,6 +66,13 @@ it waits for the next connect.
group = parser.add_argument_group('serial port')
group.add_argument(
+ "--bytesize",
+ choices=[5, 6, 7, 8],
+ type=int,
+ help="set bytesize, one of {5 6 7 8}, default: 8",
+ default=8)
+
+ group.add_argument(
"--parity",
choices=['N', 'E', 'O', 'S', 'M'],
type=lambda c: c.upper(),
@@ -73,6 +80,13 @@ it waits for the next connect.
default='N')
group.add_argument(
+ "--stopbits",
+ choices=[1, 1.5, 2],
+ type=float,
+ help="set stopbits, one of {1 1.5 2}, default: N",
+ default=1)
+
+ group.add_argument(
'--rtscts',
action='store_true',
help='enable RTS/CTS flow control (default off)',
@@ -117,7 +131,9 @@ it waits for the next connect.
# connect to serial port
ser = serial.serial_for_url(args.SERIALPORT, do_not_open=True)
ser.baudrate = args.BAUDRATE
+ ser.bytesize = args.bytesize
ser.parity = args.parity
+ ser.stopbits = args.stopbits
ser.rtscts = args.rtscts
ser.xonxoff = args.xonxoff