forked from platformio/platformio-core
Resolved an issue with the hexlify
filter in the device monitor command // Resolve #4732
This commit is contained in:
@ -24,6 +24,7 @@ test-driven methodologies, and modern toolchains for unrivaled success.
|
|||||||
* Addressed an issue where passing a relative path (``--project-dir``) to the `pio project init <https://docs.platformio.org/en/latest/core/userguide/project/cmd_init.html>`__ command resulted in an error (`issue #4847 <https://github.com/platformio/platformio-core/issues/4847>`_)
|
* Addressed an issue where passing a relative path (``--project-dir``) to the `pio project init <https://docs.platformio.org/en/latest/core/userguide/project/cmd_init.html>`__ command resulted in an error (`issue #4847 <https://github.com/platformio/platformio-core/issues/4847>`_)
|
||||||
* Resolved an issue related to the relative package path in the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command
|
* Resolved an issue related to the relative package path in the `pio pkg publish <https://docs.platformio.org/en/latest/core/userguide/pkg/cmd_publish.html>`__ command
|
||||||
* Resolved an issue where the |LDF| selected an incorrect library version (`issue #4860 <https://github.com/platformio/platformio-core/issues/4860>`_)
|
* Resolved an issue where the |LDF| selected an incorrect library version (`issue #4860 <https://github.com/platformio/platformio-core/issues/4860>`_)
|
||||||
|
* Resolved an issue with the ``hexlify`` filter in the `device monitor <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html>`__ command, ensuring proper representation of characters with Unicode code points higher than 127 (`issue #4732 <https://github.com/platformio/platformio-core/issues/4732>`_)
|
||||||
|
|
||||||
6.1.13 (2024-01-12)
|
6.1.13 (2024-01-12)
|
||||||
~~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~~
|
||||||
|
2
docs
2
docs
Submodule docs updated: 09232d5768...37c10d2f72
@ -58,7 +58,7 @@ from platformio.project.options import ProjectOptions
|
|||||||
"--encoding",
|
"--encoding",
|
||||||
help=(
|
help=(
|
||||||
"Set the encoding for the serial port "
|
"Set the encoding for the serial port "
|
||||||
"(e.g. hexlify, Latin1, UTF-8) [default=%s]"
|
"(e.g. hexlify, Latin-1, UTF-8) [default=%s]"
|
||||||
% ProjectOptions["env.monitor_encoding"].default
|
% ProjectOptions["env.monitor_encoding"].default
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
@ -25,11 +25,12 @@ from platformio.project.config import ProjectConfig
|
|||||||
class DeviceMonitorFilterBase(miniterm.Transform):
|
class DeviceMonitorFilterBase(miniterm.Transform):
|
||||||
def __init__(self, options=None):
|
def __init__(self, options=None):
|
||||||
"""Called by PlatformIO to pass context"""
|
"""Called by PlatformIO to pass context"""
|
||||||
miniterm.Transform.__init__(self)
|
super().__init__()
|
||||||
|
|
||||||
self.options = options or {}
|
self.options = options or {}
|
||||||
self.project_dir = self.options.get("project_dir")
|
self.project_dir = self.options.get("project_dir")
|
||||||
self.environment = self.options.get("environment")
|
self.environment = self.options.get("environment")
|
||||||
|
self._running_terminal = None
|
||||||
|
|
||||||
self.config = ProjectConfig.get_instance()
|
self.config = ProjectConfig.get_instance()
|
||||||
if not self.environment:
|
if not self.environment:
|
||||||
@ -47,6 +48,12 @@ class DeviceMonitorFilterBase(miniterm.Transform):
|
|||||||
def NAME(self):
|
def NAME(self):
|
||||||
raise NotImplementedError("Please declare NAME attribute for the filter class")
|
raise NotImplementedError("Please declare NAME attribute for the filter class")
|
||||||
|
|
||||||
|
def set_running_terminal(self, terminal):
|
||||||
|
self._running_terminal = terminal
|
||||||
|
|
||||||
|
def get_running_terminal(self):
|
||||||
|
return self._running_terminal
|
||||||
|
|
||||||
|
|
||||||
def register_filters(platform=None, options=None):
|
def register_filters(platform=None, options=None):
|
||||||
# project filters
|
# project filters
|
||||||
|
@ -24,12 +24,18 @@ class Hexlify(DeviceMonitorFilterBase):
|
|||||||
super().__init__(*args, **kwargs)
|
super().__init__(*args, **kwargs)
|
||||||
self._counter = 0
|
self._counter = 0
|
||||||
|
|
||||||
|
def set_running_terminal(self, terminal):
|
||||||
|
# force to Latin-1, issue #4732
|
||||||
|
if terminal.input_encoding == "UTF-8":
|
||||||
|
terminal.set_rx_encoding("Latin-1")
|
||||||
|
super().set_running_terminal(terminal)
|
||||||
|
|
||||||
def rx(self, text):
|
def rx(self, text):
|
||||||
result = ""
|
result = ""
|
||||||
for b in serial.iterbytes(text):
|
for c in serial.iterbytes(text):
|
||||||
if (self._counter % 16) == 0:
|
if (self._counter % 16) == 0:
|
||||||
result += "\n{:04X} | ".format(self._counter)
|
result += "\n{:04X} | ".format(self._counter)
|
||||||
asciicode = ord(b)
|
asciicode = ord(c)
|
||||||
if asciicode <= 255:
|
if asciicode <= 255:
|
||||||
result += "{:02X} ".format(asciicode)
|
result += "{:02X} ".format(asciicode)
|
||||||
else:
|
else:
|
||||||
|
@ -110,6 +110,12 @@ def new_terminal(options):
|
|||||||
term.raw = options["raw"]
|
term.raw = options["raw"]
|
||||||
term.set_rx_encoding(options["encoding"])
|
term.set_rx_encoding(options["encoding"])
|
||||||
term.set_tx_encoding(options["encoding"])
|
term.set_tx_encoding(options["encoding"])
|
||||||
|
for ts in (term.tx_transformations, term.rx_transformations):
|
||||||
|
for t in ts:
|
||||||
|
try:
|
||||||
|
t.set_running_terminal(term)
|
||||||
|
except AttributeError:
|
||||||
|
pass
|
||||||
return term
|
return term
|
||||||
|
|
||||||
|
|
||||||
|
@ -549,7 +549,7 @@ ProjectOptions = OrderedDict(
|
|||||||
ConfigEnvOption(
|
ConfigEnvOption(
|
||||||
group="monitor",
|
group="monitor",
|
||||||
name="monitor_encoding",
|
name="monitor_encoding",
|
||||||
description="Custom encoding (e.g. hexlify, Latin1, UTF-8)",
|
description="Custom encoding (e.g. hexlify, Latin-1, UTF-8)",
|
||||||
default="UTF-8",
|
default="UTF-8",
|
||||||
),
|
),
|
||||||
# Library
|
# Library
|
||||||
|
Reference in New Issue
Block a user