Skip to content

Commit f8e7285

Browse files
committed
Merge branch 'feature/idfpy_add_baud_parameter_to_monitor' into 'master'
idf.py: add monitor-baud option to monitor command Closes IDF-978 See merge request espressif/esp-idf!6613
2 parents ac1834e + 767cde7 commit f8e7285

File tree

2 files changed

+42
-20
lines changed

2 files changed

+42
-20
lines changed

tools/idf_monitor.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -794,7 +794,7 @@ def _get_default_serial_port():
794794
'--baud', '-b',
795795
help='Serial port baud rate',
796796
type=int,
797-
default=os.environ.get('MONITOR_BAUD', 115200))
797+
default=os.getenv('IDF_MONITOR_BAUD', os.getenv('MONITORBAUD', 115200)))
798798

799799
parser.add_argument(
800800
'--make', '-m',

tools/idf_py_actions/serial_ext.py

+41-19
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
import os
33
import sys
44

5+
import click
6+
57
from idf_py_actions.errors import FatalError
68
from idf_py_actions.global_options import global_options
79
from idf_py_actions.tools import ensure_build_directory, run_tool, run_target
@@ -60,7 +62,7 @@ def _get_commandline_options(ctx):
6062

6163
return result
6264

63-
def monitor(action, ctx, args, print_filter):
65+
def monitor(action, ctx, args, print_filter, monitor_baud):
6466
"""
6567
Run idf_monitor.py to watch build output
6668
"""
@@ -81,7 +83,16 @@ def monitor(action, ctx, args, print_filter):
8183
monitor_args = [PYTHON, idf_monitor]
8284
if args.port is not None:
8385
monitor_args += ["-p", args.port]
84-
monitor_args += ["-b", project_desc["monitor_baud"]]
86+
87+
if not monitor_baud:
88+
if os.getenv("IDF_MONITOR_BAUD"):
89+
monitor_baud = os.getenv("IDF_MONITOR_BAUD", None)
90+
elif os.getenv("MONITORBAUD"):
91+
monitor_baud = os.getenv("MONITORBAUD", None)
92+
else:
93+
monitor_baud = project_desc["monitor_baud"]
94+
95+
monitor_args += ["-b", monitor_baud]
8596
monitor_args += ["--toolchain-prefix", project_desc["monitor_toolprefix"]]
8697

8798
if print_filter is not None:
@@ -112,7 +123,7 @@ def erase_flash(action, ctx, args):
112123

113124
baud_rate = {
114125
"names": ["-b", "--baud"],
115-
"help": "Baud rate.",
126+
"help": "Baud rate for flashing.",
116127
"scope": "global",
117128
"envvar": "ESPBAUD",
118129
"default": 460800,
@@ -141,24 +152,35 @@ def erase_flash(action, ctx, args):
141152
"options": [baud_rate, port],
142153
},
143154
"monitor": {
144-
"callback": monitor,
145-
"help": "Display serial output.",
155+
"callback":
156+
monitor,
157+
"help":
158+
"Display serial output.",
146159
"options": [
147-
port,
148-
{
160+
port, {
149161
"names": ["--print-filter", "--print_filter"],
150-
"help": (
151-
"Filter monitor output.\n"
152-
"Restrictions on what to print can be specified as a series of <tag>:<log_level> items "
153-
"where <tag> is the tag string and <log_level> is a character from the set "
154-
"{N, E, W, I, D, V, *} referring to a level. "
155-
'For example, "tag1:W" matches and prints only the outputs written with '
156-
'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). '
157-
'Not specifying a <log_level> or using "*" defaults to Verbose level.\n'
158-
'Please see the IDF Monitor section of the ESP-IDF documentation '
159-
'for a more detailed description and further examples.'),
160-
"default": None,
161-
},
162+
"help":
163+
("Filter monitor output.\n"
164+
"Restrictions on what to print can be specified as a series of <tag>:<log_level> items "
165+
"where <tag> is the tag string and <log_level> is a character from the set "
166+
"{N, E, W, I, D, V, *} referring to a level. "
167+
'For example, "tag1:W" matches and prints only the outputs written with '
168+
'ESP_LOGW("tag1", ...) or at lower verbosity level, i.e. ESP_LOGE("tag1", ...). '
169+
'Not specifying a <log_level> or using "*" defaults to Verbose level.\n'
170+
'Please see the IDF Monitor section of the ESP-IDF documentation '
171+
'for a more detailed description and further examples.'),
172+
"default":
173+
None,
174+
}, {
175+
"names": ["--monitor-baud", "-B"],
176+
"type":
177+
click.INT,
178+
"help": ("Baud rate for monitor.\n"
179+
"If this option is not provided IDF_MONITOR_BAUD and MONITORBAUD "
180+
"environment variables and project_description.json in build directory "
181+
"(generated by CMake from project's sdkconfig) "
182+
"will be checked for default value."),
183+
}
162184
],
163185
"order_dependencies": [
164186
"flash",

0 commit comments

Comments
 (0)