def monitor(action, ctx, args, print_filter, monitor_baud, encrypted, timestamps, timestamp_format): """ Run idf_monitor.py to watch build output """ desc_path = os.path.join(args.build_dir, 'project_description.json') if not os.path.exists(desc_path): ensure_build_directory(args, ctx.info_name) with open(desc_path, 'r') as f: project_desc = json.load(f) 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', " 'and the binary on the device must match the one in the build directory exactly. ' "Try '%s flash monitor'." % (elf_file, ctx.info_name), ctx) idf_monitor = os.path.join(os.environ['IDF_PATH'], 'tools/idf_monitor.py') monitor_args = [PYTHON, idf_monitor] esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] if not monitor_baud: monitor_baud = os.getenv('IDF_MONITOR_BAUD') or os.getenv('MONITORBAUD') or project_desc['monitor_baud'] monitor_args += ['-b', monitor_baud] monitor_args += ['--toolchain-prefix', project_desc['monitor_toolprefix']] coredump_decode = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_ESP_COREDUMP_DECODE') if coredump_decode is not None: monitor_args += ['--decode-coredumps', coredump_decode] target_arch_riscv = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV') monitor_args += ['--target', project_desc['target']] revision = project_desc.get('rev') if revision: monitor_args += ['--revision', revision] if target_arch_riscv: monitor_args += ['--decode-panic', 'backtrace'] if print_filter is not None: monitor_args += ['--print_filter', print_filter] monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] if timestamps: monitor_args += ['--timestamps'] if timestamp_format: monitor_args += ['--timestamp-format', timestamp_format] idf_py = [PYTHON] + _get_commandline_options(ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] if 'MSYSTEM' in os.environ: monitor_args = ['winpty'] + monitor_args run_tool('idf_monitor', monitor_args, args.project_dir)
def monitor(action, ctx, args, print_filter, monitor_baud, encrypted): """ Run idf_monitor.py to watch build output """ if args.port is None: args.port = _get_default_serial_port() desc_path = os.path.join(args.build_dir, "project_description.json") if not os.path.exists(desc_path): ensure_build_directory(args, ctx.info_name) with open(desc_path, "r") as f: project_desc = json.load(f) 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', " "and the binary on the device must match the one in the build directory exactly. " "Try '%s flash monitor'." % (elf_file, ctx.info_name), ctx) 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] if not monitor_baud: monitor_baud = os.getenv("IDF_MONITOR_BAUD") or os.getenv("MONITORBAUD") or project_desc["monitor_baud"] monitor_args += ["-b", monitor_baud] monitor_args += ["--toolchain-prefix", project_desc["monitor_toolprefix"]] coredump_decode = get_sdkconfig_value(project_desc["config_file"], "CONFIG_ESP_COREDUMP_DECODE") if coredump_decode is not None: monitor_args += ["--decode-coredumps", coredump_decode] target_arch_riscv = get_sdkconfig_value(project_desc["config_file"], "CONFIG_IDF_TARGET_ARCH_RISCV") if target_arch_riscv: monitor_args += ["--decode-panic", "backtrace", "--target", project_desc["target"]] if print_filter is not None: monitor_args += ["--print_filter", print_filter] monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] idf_py = [PYTHON] + _get_commandline_options(ctx) # commands to re-run idf.py monitor_args += ["-m", " ".join("'%s'" % a for a in idf_py)] if "MSYSTEM" in os.environ: monitor_args = ["winpty"] + monitor_args run_tool("idf_monitor", monitor_args, args.project_dir)
def monitor(action, ctx, args, print_filter, monitor_baud, encrypted, timestamps, timestamp_format): """ Run idf_monitor.py to watch build output """ project_desc = _get_project_desc(ctx, args) elf_file = os.path.join(args.build_dir, project_desc['app_elf']) idf_monitor = os.path.join(os.environ['IDF_PATH'], 'tools/idf_monitor.py') monitor_args = [PYTHON, idf_monitor] if project_desc['target'] != 'linux': esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] if not monitor_baud: monitor_baud = os.getenv('IDF_MONITOR_BAUD') or os.getenv( 'MONITORBAUD') or project_desc['monitor_baud'] monitor_args += ['-b', monitor_baud] monitor_args += [ '--toolchain-prefix', project_desc['monitor_toolprefix'] ] coredump_decode = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_ESP_COREDUMP_DECODE') if coredump_decode is not None: monitor_args += ['--decode-coredumps', coredump_decode] target_arch_riscv = get_sdkconfig_value( project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV') monitor_args += ['--target', project_desc['target']] revision = project_desc.get('rev') if revision: monitor_args += ['--revision', revision] if target_arch_riscv: monitor_args += ['--decode-panic', 'backtrace'] if print_filter is not None: monitor_args += ['--print_filter', print_filter] if elf_file: monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] if timestamps: monitor_args += ['--timestamps'] if timestamp_format: monitor_args += ['--timestamp-format', timestamp_format] idf_py = [PYTHON] + _get_commandline_options( ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] run_tool('idf_monitor', monitor_args, args.project_dir)
def monitor(action: str, ctx: click.core.Context, args: PropertyDict, print_filter: str, monitor_baud: str, encrypted: bool, no_reset: bool, timestamps: bool, timestamp_format: str, force_color: bool) -> None: """ Run idf_monitor.py to watch build output """ project_desc = _get_project_desc(ctx, args) elf_file = os.path.join(args.build_dir, project_desc['app_elf']) idf_monitor = os.path.join(os.environ['IDF_PATH'], 'tools/idf_monitor.py') monitor_args = [PYTHON, idf_monitor] if project_desc['target'] != 'linux': if no_reset and args.port is None: msg = ( 'WARNING: --no-reset is ignored. ' 'Please specify the port with the --port argument in order to use this option.' ) yellow_print(msg) no_reset = False esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] baud = monitor_baud or os.getenv('IDF_MONITOR_BAUD') or os.getenv( 'MONITORBAUD') if baud is None: # Baud hasn't been changed locally (by local baud argument nor by environment variables) # # Use the global baud rate if it has been changed by the command line. # Use project_desc['monitor_baud'] as the last option. global_baud_defined = ctx._parameter_source[ 'baud'] == click.core.ParameterSource.COMMANDLINE baud = args.baud if global_baud_defined else project_desc[ 'monitor_baud'] monitor_args += ['-b', baud] monitor_args += [ '--toolchain-prefix', project_desc['monitor_toolprefix'] ] coredump_decode = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_ESP_COREDUMP_DECODE') if coredump_decode is not None: monitor_args += ['--decode-coredumps', coredump_decode] target_arch_riscv = get_sdkconfig_value( project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV') monitor_args += ['--target', project_desc['target']] revision = project_desc.get('rev') if revision: monitor_args += ['--revision', revision] if target_arch_riscv: monitor_args += ['--decode-panic', 'backtrace'] if print_filter is not None: monitor_args += ['--print_filter', print_filter] if elf_file: monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] if no_reset: monitor_args += ['--no-reset'] if timestamps: monitor_args += ['--timestamps'] if timestamp_format: monitor_args += ['--timestamp-format', timestamp_format] if force_color or os.name == 'nt': monitor_args += ['--force-color'] idf_py = [PYTHON] + _get_commandline_options( ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] hints = not args.no_hints RunTool('idf_monitor', monitor_args, args.project_dir, build_dir=args.build_dir, hints=hints)()
def monitor(action, ctx, args, print_filter, monitor_baud, encrypted, timestamps, timestamp_format): """ Run idf_monitor.py to watch build output """ project_desc = _get_project_desc(ctx, args) elf_file = os.path.join(args.build_dir, project_desc['app_elf']) idf_monitor = os.path.join(os.environ['IDF_PATH'], 'tools/idf_monitor.py') monitor_args = [PYTHON, idf_monitor] if project_desc['target'] != 'linux': esp_port = args.port or _get_default_serial_port(args) monitor_args += ['-p', esp_port] baud = monitor_baud or os.getenv('IDF_MONITOR_BAUD') or os.getenv( 'MONITORBAUD') if baud is None: # Baud hasn't been changed locally (by local baud argument nor by environment variables) # # Use the global baud rate if it has been changed by the command line. # Use project_desc['monitor_baud'] as the last option. global_baud_defined = ctx._parameter_source[ 'baud'] == click.core.ParameterSource.COMMANDLINE baud = args.baud if global_baud_defined else project_desc[ 'monitor_baud'] monitor_args += ['-b', baud] monitor_args += [ '--toolchain-prefix', project_desc['monitor_toolprefix'] ] coredump_decode = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_ESP_COREDUMP_DECODE') if coredump_decode is not None: monitor_args += ['--decode-coredumps', coredump_decode] target_arch_riscv = get_sdkconfig_value( project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV') monitor_args += ['--target', project_desc['target']] revision = project_desc.get('rev') if revision: monitor_args += ['--revision', revision] if target_arch_riscv: monitor_args += ['--decode-panic', 'backtrace'] if print_filter is not None: monitor_args += ['--print_filter', print_filter] if elf_file: monitor_args += [elf_file] if encrypted: monitor_args += ['--encrypted'] if timestamps: monitor_args += ['--timestamps'] if timestamp_format: monitor_args += ['--timestamp-format', timestamp_format] idf_py = [PYTHON] + _get_commandline_options( ctx) # commands to re-run idf.py monitor_args += ['-m', ' '.join("'%s'" % a for a in idf_py)] run_tool('idf_monitor', monitor_args, args.project_dir)