From ead0e6da36bb611aaa15447585b992c6375b41e6 Mon Sep 17 00:00:00 2001 From: Sergei Silnov Date: Tue, 5 Nov 2019 15:21:28 +0100 Subject: [PATCH] idf.py: add monitor-baud option to monitor command --- tools/idf.py | 54 ++++++++++++++++++++++++++++++-------------- tools/idf_monitor.py | 2 +- 2 files changed, 38 insertions(+), 18 deletions(-) diff --git a/tools/idf.py b/tools/idf.py index 2cee97441..9e9eb554b 100755 --- a/tools/idf.py +++ b/tools/idf.py @@ -364,7 +364,7 @@ def erase_flash(action, ctx, args): _run_tool("esptool.py", esptool_args, args.build_dir) -def monitor(action, ctx, args, print_filter): +def monitor(action, ctx, args, print_filter, monitor_baud): """ Run idf_monitor.py to watch build output """ @@ -387,7 +387,17 @@ def monitor(action, ctx, args, print_filter): monitor_args = [PYTHON, idf_monitor] if args.port is not None: monitor_args += ["-p", args.port] - monitor_args += ["-b", project_desc["monitor_baud"]] + + if not monitor_baud: + if os.getenv("IDF_MONITOR_BAUD"): + monitor_baud = os.getenv("IDF_MONITOR_BAUD", None) + elif os.getenv("MONITORBAUD"): + monitor_baud = os.getenv("MONITORBAUD", None) + else: + monitor_baud = project_desc["monitor_baud"] + + monitor_args += ["-b", monitor_baud] + if print_filter is not None: monitor_args += ["--print_filter", print_filter] monitor_args += [elf_file] @@ -1107,7 +1117,7 @@ def init_cli(): baud_rate = { "names": ["-b", "--baud"], - "help": "Baud rate.", + "help": "Baud rate for flashing.", "scope": "global", "envvar": "ESPBAUD", "default": 460800, @@ -1139,21 +1149,31 @@ def init_cli(): "callback": monitor, "help": "Display serial output.", "options": [ - port, - { + port, { "names": ["--print-filter", "--print_filter"], - "help": ( - "Filter monitor output.\n" - "Restrictions on what to print can be specified as a series of : items " - "where is the tag string and is a character from the set " - "{N, E, W, I, D, V, *} referring to a level. " - 'For example, "tag1:W" matches and prints only the outputs written with ' - 'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). ' - 'Not specifying a or using "*" defaults to Verbose level.\n' - 'Please see the IDF Monitor section of the ESP-IDF documentation ' - 'for a more detailed description and further examples.'), - "default": None, - }, + "help": + ("Filter monitor output.\n" + "Restrictions on what to print can be specified as a series of : items " + "where is the tag string and is a character from the set " + "{N, E, W, I, D, V, *} referring to a level. " + 'For example, "tag1:W" matches and prints only the outputs written with ' + 'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). ' + 'Not specifying a or using "*" defaults to Verbose level.\n' + 'Please see the IDF Monitor section of the ESP-IDF documentation ' + 'for a more detailed description and further examples.'), + "default": + None, + }, { + "names": ["--monitor-baud", "-B"], + "type": + click.INT, + "help": ("Baud rate for monitor.\n" + "If this option is not provided IDF_MONITOR_BAUD and MONITORBAUD " + "environment variables and project_description.json in build directory " + "(generated by CMake from project's sdkconfig) " + "will be checked for default value."), + } + ], "order_dependencies": [ "flash", diff --git a/tools/idf_monitor.py b/tools/idf_monitor.py index c0f6d3b81..ea4ad44c1 100755 --- a/tools/idf_monitor.py +++ b/tools/idf_monitor.py @@ -696,7 +696,7 @@ def main(): '--baud', '-b', help='Serial port baud rate', type=int, - default=os.environ.get('MONITOR_BAUD', 115200)) + default=os.getenv('IDF_MONITOR_BAUD', os.getenv('MONITORBAUD', 115200))) parser.add_argument( '--make', '-m',