diff options
author | Michael Buesch <m@bues.ch> | 2019-12-28 20:38:27 +0100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2020-02-01 00:03:37 +1100 |
commit | 83afd48ad93e162eec65d34c2dfe266c995fbafd (patch) | |
tree | bcf9195862bf66821fb940280b6ebd07ac5b0c86 /tools/pyboard.py | |
parent | 3e1bbeabafc08ec0c9b6349b416aed306ef8a7c8 (diff) |
tools/pyboard.py: Add option --no-follow to detach after sending script.
This option makes pyboard.py exit as soon as the script/command is
successfully sent to the device, ie it does not wait for any output. This
can help to avoid hangs if the board is being rebooted with --comman (for
example).
Example usage:
$ python3 ./tools/pyboard.py --device /dev/ttyUSB0 --no-follow \
--command 'import machine; machine.reset()'
Diffstat (limited to 'tools/pyboard.py')
-rwxr-xr-x | tools/pyboard.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/tools/pyboard.py b/tools/pyboard.py index 2a255e91c..f1ccc59b9 100755 --- a/tools/pyboard.py +++ b/tools/pyboard.py @@ -520,7 +520,9 @@ def main(): cmd_parser.add_argument('-p', '--password', default='python', help='the telnet login password') cmd_parser.add_argument('-c', '--command', help='program passed in as string') cmd_parser.add_argument('-w', '--wait', default=0, type=int, help='seconds to wait for USB connected board to become available') - cmd_parser.add_argument('--follow', action='store_true', help='follow the output after running the scripts [default if no scripts given]') + group = cmd_parser.add_mutually_exclusive_group() + group.add_argument('--follow', action='store_true', help='follow the output after running the scripts [default if no scripts given]') + group.add_argument('--no-follow', action='store_true', help='Do not follow the output after running the scripts.') cmd_parser.add_argument('-f', '--filesystem', action='store_true', help='perform a filesystem action') cmd_parser.add_argument('files', nargs='*', help='input files') args = cmd_parser.parse_args() @@ -545,7 +547,11 @@ def main(): def execbuffer(buf): try: - ret, ret_err = pyb.exec_raw(buf, timeout=None, data_consumer=stdout_write_bytes) + if args.no_follow: + pyb.exec_raw_no_follow(buf) + ret_err = None + else: + ret, ret_err = pyb.exec_raw(buf, timeout=None, data_consumer=stdout_write_bytes) except PyboardError as er: print(er) pyb.close() |