tools/pyboard.py: Support setting device/baudrate from shell env vars.
Allow defaults for --device and --baudrate to be set in the environment using PYBOARD_DEVICE and PYBOARD_BAUDRATE.
This commit is contained in:
parent
688323307a
commit
1cf994c48b
@ -59,6 +59,17 @@ with the device.::
|
|||||||
$ pyboard.py --device /dev/ttyACM0 -c 'print(1+1)'
|
$ pyboard.py --device /dev/ttyACM0 -c 'print(1+1)'
|
||||||
2
|
2
|
||||||
|
|
||||||
|
If you are often interacting with the same device, you can set the environment
|
||||||
|
variable ``PYBOARD_DEVICE`` as an alternative to using the ``--device``
|
||||||
|
command line option. For example, the following is equivalent to the previous
|
||||||
|
example::
|
||||||
|
|
||||||
|
$ export PYBOARD_DEVICE=/dev/ttyACM0
|
||||||
|
$ pyboard.py -c 'print(1+1)'
|
||||||
|
|
||||||
|
Similarly, the ``PYBOARD_BAUDRATE`` environment variable can be used
|
||||||
|
to set the default for the `--baudrate` option.
|
||||||
|
|
||||||
Running a script on the device
|
Running a script on the device
|
||||||
------------------------------
|
------------------------------
|
||||||
|
|
||||||
|
@ -558,11 +558,14 @@ def main():
|
|||||||
cmd_parser = argparse.ArgumentParser(description="Run scripts on the pyboard.")
|
cmd_parser = argparse.ArgumentParser(description="Run scripts on the pyboard.")
|
||||||
cmd_parser.add_argument(
|
cmd_parser.add_argument(
|
||||||
"--device",
|
"--device",
|
||||||
default="/dev/ttyACM0",
|
default=os.environ.get("PYBOARD_DEVICE", "/dev/ttyACM0"),
|
||||||
help="the serial device or the IP address of the pyboard",
|
help="the serial device or the IP address of the pyboard",
|
||||||
)
|
)
|
||||||
cmd_parser.add_argument(
|
cmd_parser.add_argument(
|
||||||
"-b", "--baudrate", default=115200, help="the baud rate of the serial device"
|
"-b",
|
||||||
|
"--baudrate",
|
||||||
|
default=os.environ.get("PYBOARD_BAUDRATE", "115200"),
|
||||||
|
help="the baud rate of the serial device",
|
||||||
)
|
)
|
||||||
cmd_parser.add_argument("-u", "--user", default="micro", help="the telnet login username")
|
cmd_parser.add_argument("-u", "--user", default="micro", help="the telnet login username")
|
||||||
cmd_parser.add_argument("-p", "--password", default="python", help="the telnet login password")
|
cmd_parser.add_argument("-p", "--password", default="python", help="the telnet login password")
|
||||||
|
Loading…
Reference in New Issue
Block a user