forked from espressif/esp-idf
Merge branch 'bugfix/fix_after_monitor_refact' into 'master'
tools: Fix IDF Monitor after refactoring See merge request espressif/esp-idf!13162
This commit is contained in:
@@ -49,15 +49,10 @@ endif()
|
||||
|
||||
if(min_rev)
|
||||
list(APPEND esptool_elf2image_args --min-rev ${min_rev})
|
||||
set(monitor_rev_args --revision ${min_rev})
|
||||
unset(min_rev)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESP32_REV_MIN)
|
||||
set(rev_min ${CONFIG_ESP32_REV_MIN})
|
||||
else()
|
||||
set(rev_min -1)
|
||||
endif()
|
||||
|
||||
if(CONFIG_ESPTOOLPY_FLASHSIZE_DETECT)
|
||||
# Set ESPFLASHSIZE to 'detect' *after* elf2image options are generated,
|
||||
# as elf2image can't have 'detect' as an option...
|
||||
@@ -160,7 +155,7 @@ add_custom_target(monitor
|
||||
COMMAND ${CMAKE_COMMAND}
|
||||
-D IDF_PATH="${idf_path}"
|
||||
-D SERIAL_TOOL="${ESPMONITOR}"
|
||||
-D SERIAL_TOOL_ARGS="--target ${target} --revision ${rev_min} ${elf_dir}/${elf}"
|
||||
-D SERIAL_TOOL_ARGS="--target ${target} ${monitor_rev_args} ${elf_dir}/${elf}"
|
||||
-D WORKING_DIRECTORY="${build_dir}"
|
||||
-P run_serial_tool.cmake
|
||||
WORKING_DIRECTORY ${CMAKE_CURRENT_LIST_DIR}
|
||||
|
@@ -73,7 +73,7 @@ import tempfile
|
||||
import serial
|
||||
import serial.tools.list_ports
|
||||
# Windows console stuff
|
||||
from idf_monitor_base.ansi_color_convertor import ANSIColorConverter
|
||||
from idf_monitor_base.ansi_color_converter import get_converter
|
||||
|
||||
key_description = miniterm.key_description
|
||||
|
||||
@@ -101,9 +101,9 @@ class Monitor(object):
|
||||
self.console = miniterm.Console()
|
||||
self.enable_address_decoding = enable_address_decoding
|
||||
|
||||
sys.stderr = ANSIColorConverter(sys.stderr, decode_output=True)
|
||||
self.console.output = ANSIColorConverter(self.console.output)
|
||||
self.console.byte_output = ANSIColorConverter(self.console.byte_output)
|
||||
sys.stderr = get_converter(sys.stderr, decode_output=True)
|
||||
self.console.output = get_converter(self.console.output)
|
||||
self.console.byte_output = get_converter(self.console.byte_output)
|
||||
|
||||
socket_mode = serial_instance.port.startswith(
|
||||
'socket://') # testing hook - data from serial can make exit the monitor
|
||||
|
@@ -17,7 +17,11 @@ import os
|
||||
import re
|
||||
import sys
|
||||
from io import TextIOBase
|
||||
from typing import Union
|
||||
|
||||
try:
|
||||
from typing import Optional, Union
|
||||
except ImportError:
|
||||
pass
|
||||
|
||||
from .output_helpers import ANSI_NORMAL
|
||||
|
||||
@@ -39,6 +43,17 @@ if os.name == 'nt':
|
||||
SetConsoleTextAttribute = ctypes.windll.kernel32.SetConsoleTextAttribute # type: ignore
|
||||
|
||||
|
||||
def get_converter(orig_output_method=None, decode_output=False):
|
||||
# type: (Optional[TextIOBase], bool) -> Union[ANSIColorConverter, Optional[TextIOBase]]
|
||||
"""
|
||||
Returns an ANSIColorConverter on Windows and the original output method (orig_output_method) on other platforms.
|
||||
The ANSIColorConverter with decode_output=True will decode the bytes before passing them to the output.
|
||||
"""
|
||||
if os.name == 'nt':
|
||||
return ANSIColorConverter(orig_output_method, decode_output)
|
||||
return orig_output_method
|
||||
|
||||
|
||||
class ANSIColorConverter(object):
|
||||
"""Class to wrap a file-like output stream, intercept ANSI color codes,
|
||||
and convert them into calls to Windows SetConsoleTextAttribute.
|
||||
@@ -50,11 +65,6 @@ class ANSIColorConverter(object):
|
||||
least-bad working solution, as winpty doesn't support any "passthrough" mode for raw output.
|
||||
"""
|
||||
|
||||
def __new__(cls, output=None, decode_output=False): # type: ignore # noqa
|
||||
if os.name == 'nt':
|
||||
return cls
|
||||
return output
|
||||
|
||||
def __init__(self, output=None, decode_output=False):
|
||||
# type: (TextIOBase, bool) -> None
|
||||
self.output = output
|
@@ -100,7 +100,9 @@ def action_extensions(base_actions, project_path):
|
||||
|
||||
target_arch_riscv = get_sdkconfig_value(project_desc['config_file'], 'CONFIG_IDF_TARGET_ARCH_RISCV')
|
||||
monitor_args += ['--target', project_desc['target']]
|
||||
monitor_args += ['--revision', project_desc.get('rev', -1)]
|
||||
revision = project_desc.get('rev')
|
||||
if revision:
|
||||
monitor_args += ['--revision', revision]
|
||||
|
||||
if target_arch_riscv:
|
||||
monitor_args += ['--decode-panic', 'backtrace']
|
||||
|
Reference in New Issue
Block a user