mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
idf.py: add monitor-baud option to monitor command
This commit is contained in:
parent
5e09d473c7
commit
655e201b1c
@ -796,7 +796,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',
|
||||
|
@ -2,6 +2,8 @@ import json
|
||||
import os
|
||||
import sys
|
||||
|
||||
import click
|
||||
|
||||
from idf_py_actions.errors import FatalError
|
||||
from idf_py_actions.global_options import global_options
|
||||
from idf_py_actions.tools import ensure_build_directory, run_tool
|
||||
@ -21,7 +23,8 @@ def action_extensions(base_actions, project_path):
|
||||
|
||||
ports = list(reversed(sorted(p.device for p in serial.tools.list_ports.comports())))
|
||||
try:
|
||||
print("Choosing default port %s (use '-p PORT' option to set a specific serial port)" %
|
||||
print(
|
||||
"Choosing default port %s (use '-p PORT' option to set a specific serial port)" %
|
||||
ports[0].encode("ascii", "ignore"))
|
||||
return ports[0]
|
||||
except IndexError:
|
||||
@ -60,7 +63,7 @@ def action_extensions(base_actions, project_path):
|
||||
|
||||
return result
|
||||
|
||||
def monitor(action, ctx, args, print_filter, encrypted):
|
||||
def monitor(action, ctx, args, print_filter, encrypted, monitor_baud):
|
||||
"""
|
||||
Run idf_monitor.py to watch build output
|
||||
"""
|
||||
@ -74,14 +77,24 @@ def action_extensions(base_actions, project_path):
|
||||
|
||||
elf_file = os.path.join(args.build_dir, project_desc["app_elf"])
|
||||
if not os.path.exists(elf_file):
|
||||
raise FatalError("ELF file '%s' not found. You need to build & flash the project before running 'monitor', "
|
||||
raise FatalError(
|
||||
"ELF file '%s' not found. You need to build & flash the project before running 'monitor', "
|
||||
"and the binary on the device must match the one in the build directory exactly. "
|
||||
"Try '%s flash monitor'." % (elf_file, ctx.info_name))
|
||||
idf_monitor = os.path.join(os.environ["IDF_PATH"], "tools/idf_monitor.py")
|
||||
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]
|
||||
monitor_args += ["--toolchain-prefix", project_desc["monitor_toolprefix"]]
|
||||
|
||||
if print_filter is not None:
|
||||
@ -130,7 +143,7 @@ def action_extensions(base_actions, project_path):
|
||||
|
||||
baud_rate = {
|
||||
"names": ["-b", "--baud"],
|
||||
"help": "Baud rate.",
|
||||
"help": "Baud rate for flashing.",
|
||||
"scope": "global",
|
||||
"envvar": "ESPBAUD",
|
||||
"default": 460800,
|
||||
@ -163,8 +176,7 @@ def action_extensions(base_actions, project_path):
|
||||
"callback": monitor,
|
||||
"help": "Display serial output.",
|
||||
"options": [
|
||||
port,
|
||||
{
|
||||
port, {
|
||||
"names": ["--print-filter", "--print_filter"],
|
||||
"help": (
|
||||
"Filter monitor output.\n"
|
||||
@ -180,10 +192,20 @@ def action_extensions(base_actions, project_path):
|
||||
}, {
|
||||
"names": ["--encrypted", "-E"],
|
||||
"is_flag": True,
|
||||
"help": ("Enable encrypted flash targets.\n"
|
||||
"help": (
|
||||
"Enable encrypted flash targets.\n"
|
||||
"IDF Monitor will invoke encrypted-flash and encrypted-app-flash targets "
|
||||
"if this option is set. This option is set by default if IDF Monitor was invoked "
|
||||
"together with encrypted-flash or encrypted-app-flash target."),
|
||||
}, {
|
||||
"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": [
|
||||
|
Loading…
Reference in New Issue
Block a user