mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-31 02:27:13 +02:00
Fixed an issue when "pio device monitor –eol" and “send_on_enter” filter do not work properly // Resolve #3787
This commit is contained in:
@ -45,6 +45,7 @@ PlatformIO Core 5
|
|||||||
- Improved listing of `multicast DNS services <https://docs.platformio.org/page/core/userguide/device/cmd_list.html>`_
|
- Improved listing of `multicast DNS services <https://docs.platformio.org/page/core/userguide/device/cmd_list.html>`_
|
||||||
- Fixed a "UnicodeDecodeError: 'utf-8' codec can't decode byte" when using J-Link for firmware uploading on Linux (`issue #3804 <https://github.com/platformio/platformio-core/issues/3804>`_)
|
- Fixed a "UnicodeDecodeError: 'utf-8' codec can't decode byte" when using J-Link for firmware uploading on Linux (`issue #3804 <https://github.com/platformio/platformio-core/issues/3804>`_)
|
||||||
- Fixed an issue with a compiler driver for ".ccls" language server (`issue #3808 <https://github.com/platformio/platformio-core/issues/3808>`_)
|
- Fixed an issue with a compiler driver for ".ccls" language server (`issue #3808 <https://github.com/platformio/platformio-core/issues/3808>`_)
|
||||||
|
- Fixed an issue when `pio device monitor --eol <https://docs.platformio.org/en/latest/core/userguide/device/cmd_monitor.html#cmdoption-pio-device-monitor-eol>`__ and "send_on_enter" filter do not work properly (`issue #3787 <https://github.com/platformio/platformio-core/issues/3787>`_)
|
||||||
|
|
||||||
5.0.4 (2020-12-30)
|
5.0.4 (2020-12-30)
|
||||||
~~~~~~~~~~~~~~~~~~
|
~~~~~~~~~~~~~~~~~~
|
||||||
|
@ -179,7 +179,9 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches
|
|||||||
for name in os.listdir(filters_dir):
|
for name in os.listdir(filters_dir):
|
||||||
if not name.endswith(".py"):
|
if not name.endswith(".py"):
|
||||||
continue
|
continue
|
||||||
device_helpers.load_monitor_filter(os.path.join(filters_dir, name))
|
device_helpers.load_monitor_filter(
|
||||||
|
os.path.join(filters_dir, name), options=kwargs
|
||||||
|
)
|
||||||
|
|
||||||
project_options = {}
|
project_options = {}
|
||||||
try:
|
try:
|
||||||
@ -193,9 +195,7 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches
|
|||||||
if "platform" in project_options:
|
if "platform" in project_options:
|
||||||
with fs.cd(kwargs["project_dir"]):
|
with fs.cd(kwargs["project_dir"]):
|
||||||
platform = PlatformFactory.new(project_options["platform"])
|
platform = PlatformFactory.new(project_options["platform"])
|
||||||
device_helpers.register_platform_filters(
|
device_helpers.register_platform_filters(platform, options=kwargs)
|
||||||
platform, kwargs["project_dir"], kwargs["environment"]
|
|
||||||
)
|
|
||||||
|
|
||||||
if not kwargs["port"]:
|
if not kwargs["port"]:
|
||||||
ports = util.get_serial_ports(filter_hwid=True)
|
ports = util.get_serial_ports(filter_hwid=True)
|
||||||
|
@ -18,12 +18,13 @@ from platformio.project.config import ProjectConfig
|
|||||||
|
|
||||||
|
|
||||||
class DeviceMonitorFilter(miniterm.Transform):
|
class DeviceMonitorFilter(miniterm.Transform):
|
||||||
def __init__(self, project_dir=None, environment=None):
|
def __init__(self, options=None):
|
||||||
""" Called by PlatformIO to pass context """
|
""" Called by PlatformIO to pass context """
|
||||||
miniterm.Transform.__init__(self)
|
miniterm.Transform.__init__(self)
|
||||||
|
|
||||||
self.project_dir = project_dir
|
self.options = options or {}
|
||||||
self.environment = environment
|
self.project_dir = self.options.get("project_dir")
|
||||||
|
self.environment = self.options.get("environment")
|
||||||
|
|
||||||
self.config = ProjectConfig.get_instance()
|
self.config = ProjectConfig.get_instance()
|
||||||
if not self.environment:
|
if not self.environment:
|
||||||
|
@ -22,10 +22,17 @@ class SendOnEnter(DeviceMonitorFilter):
|
|||||||
super(SendOnEnter, self).__init__(*args, **kwargs)
|
super(SendOnEnter, self).__init__(*args, **kwargs)
|
||||||
self._buffer = ""
|
self._buffer = ""
|
||||||
|
|
||||||
|
if self.options.get("eol") == "CR":
|
||||||
|
self._eol = "\r"
|
||||||
|
elif self.options.get("eol") == "LF":
|
||||||
|
self._eol = "\n"
|
||||||
|
else:
|
||||||
|
self._eol = "\r\n"
|
||||||
|
|
||||||
def tx(self, text):
|
def tx(self, text):
|
||||||
self._buffer += text
|
self._buffer += text
|
||||||
if self._buffer.endswith("\r\n"):
|
if self._buffer.endswith(self._eol):
|
||||||
text = self._buffer[:-2]
|
text = self._buffer[: len(self._eol) * -1]
|
||||||
self._buffer = ""
|
self._buffer = ""
|
||||||
return text
|
return text
|
||||||
return ""
|
return ""
|
||||||
|
@ -76,7 +76,7 @@ def get_board_hwids(project_dir, platform, board):
|
|||||||
return platform.board_config(board).get("build.hwids", [])
|
return platform.board_config(board).get("build.hwids", [])
|
||||||
|
|
||||||
|
|
||||||
def load_monitor_filter(path, project_dir=None, environment=None):
|
def load_monitor_filter(path, options=None):
|
||||||
name = os.path.basename(path)
|
name = os.path.basename(path)
|
||||||
name = name[: name.find(".")]
|
name = name[: name.find(".")]
|
||||||
module = load_python_module("platformio.commands.device.filters.%s" % name, path)
|
module = load_python_module("platformio.commands.device.filters.%s" % name, path)
|
||||||
@ -87,12 +87,12 @@ def load_monitor_filter(path, project_dir=None, environment=None):
|
|||||||
or cls == DeviceMonitorFilter
|
or cls == DeviceMonitorFilter
|
||||||
):
|
):
|
||||||
continue
|
continue
|
||||||
obj = cls(project_dir, environment)
|
obj = cls(options)
|
||||||
miniterm.TRANSFORMATIONS[obj.NAME] = obj
|
miniterm.TRANSFORMATIONS[obj.NAME] = obj
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def register_platform_filters(platform, project_dir, environment):
|
def register_platform_filters(platform, options=None):
|
||||||
monitor_dir = os.path.join(platform.get_dir(), "monitor")
|
monitor_dir = os.path.join(platform.get_dir(), "monitor")
|
||||||
if not os.path.isdir(monitor_dir):
|
if not os.path.isdir(monitor_dir):
|
||||||
return
|
return
|
||||||
@ -103,4 +103,4 @@ def register_platform_filters(platform, project_dir, environment):
|
|||||||
path = os.path.join(monitor_dir, name)
|
path = os.path.join(monitor_dir, name)
|
||||||
if not os.path.isfile(path):
|
if not os.path.isfile(path):
|
||||||
continue
|
continue
|
||||||
load_monitor_filter(path, project_dir, environment)
|
load_monitor_filter(path, options)
|
||||||
|
Reference in New Issue
Block a user