Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make baud rate configurable for examples #1410

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/client_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
--log {critical,error,warning,info,debug}
"critical", "error", "warning", "info" or "debug"
--port PORT the port to use
--baudrate BAUDRATE the baud rate to use for the serial device

The corresponding server must be started before e.g. as:
python3 server_sync.py
Expand Down Expand Up @@ -81,7 +82,7 @@ def setup_async_client(args):
# close_comm_on_error=False,
# strict=True,
# Serial setup parameters
# baudrate=9600,
baudrate=args.baudrate,
# bytesize=8,
# parity="N",
# stopbits=1,
Expand Down
3 changes: 2 additions & 1 deletion examples/client_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
--log {critical,error,warning,info,debug}
"critical", "error", "warning", "info" or "debug"
--port PORT the port to use
--baudrate BAUDRATE the baud rate to use for the serial device

The corresponding server must be started before e.g. as:
python3 server_sync.py
Expand Down Expand Up @@ -80,7 +81,7 @@ def setup_sync_client(args):
# close_comm_on_error=False,.
# strict=True,
# Serial setup parameters
# baudrate=9600,
baudrate=args.baudrate,
# bytesize=8,
# parity="N",
# stopbits=1,
Expand Down
7 changes: 7 additions & 0 deletions examples/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Commandline:
framer = None
host = "127.0.0.1"
port = None
baudrate = 9600
store = "sequential"
identity = None
context = None
Expand Down Expand Up @@ -75,6 +76,12 @@ def get_commandline(server=False, description=None, extras=None):
help="set port",
type=str,
)
parser.add_argument(
"--baudrate",
help="set serial device baud rate",
default=9600,
type=int,
)
if server:
parser.add_argument(
"--store",
Expand Down
3 changes: 2 additions & 1 deletion examples/server_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
--log {critical,error,warning,info,debug}
"critical", "error", "warning", "info" or "debug"
--port PORT the port to use
--baudrate BAUDRATE the baud rate to use for the serial device
--store {sequential,sparse,factory,none}
"sequential", "sparse", "factory" or "none"
--slaves SLAVES number of slaves to respond to
Expand Down Expand Up @@ -187,7 +188,7 @@ async def run_async_server(args):
# stopbits=1, # The number of stop bits to use
# bytesize=8, # The bytesize of the serial messages
# parity="N", # Which kind of parity to use
# baudrate=9600, # The baud rate to use for the serial device
baudrate=args.baudrate, # The baud rate to use for the serial device
# handle_local_echo=False, # Handle local echo of the USB-to-RS485 adaptor
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat unit_id 0 as broadcast address,
Expand Down
3 changes: 2 additions & 1 deletion examples/server_sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
--log {critical,error,warning,info,debug}
"critical", "error", "warning", "info" or "debug"
--port PORT the port to use
--baudrate BAUDRATE the baud rate to use for the serial device
--store {sequential,sparse,factory,none}
"sequential", "sparse", "factory" or "none"
--slaves SLAVES number of slaves to respond to
Expand Down Expand Up @@ -104,7 +105,7 @@ def run_sync_server(args):
# stopbits=1, # The number of stop bits to use
# bytesize=7, # The bytesize of the serial messages
# parity="E", # Which kind of parity to use
# baudrate=9600, # The baud rate to use for the serial device
baudrate=args.baudrate, # The baud rate to use for the serial device
# handle_local_echo=False, # Handle local echo of the USB-to-RS485 adaptor
# ignore_missing_slaves=True, # ignore request to a missing slave
# broadcast_enable=False, # treat unit_id 0 as broadcast address,
Expand Down