mirror of
https://github.com/platformio/platformio-core.git
synced 2025-07-29 17:47:14 +02:00
Added support for custom device monitor filters // Resolve #3924
This commit is contained in:
@ -11,6 +11,7 @@ PlatformIO Core 5
|
||||
5.2.3 (2021-??-??)
|
||||
~~~~~~~~~~~~~~~~~~
|
||||
|
||||
- Added support for custom `device monitor filters <https://docs.platformio.org/page/core/userguide/device/cmd_monitor.html#filters>`__ (`issue #3924 <https://github.com/platformio/platformio-core/issues/3924>`_)
|
||||
- Show human-readable message when infinite recursion is detected while processing `Interpolation of Values <https://docs.platformio.org/page/projectconf/interpolation.html>`__ (`issue #3883 <https://github.com/platformio/platformio-core/issues/3883>`_)
|
||||
- Improved directory interpolation (``${platformio.***_dir}``) in `"platformio.ini" <https://docs.platformio.org/page/projectconf.html>`__ configuration file (`issue #3934 <https://github.com/platformio/platformio-core/issues/3934>`_)
|
||||
- Ignore resolving of SCons variables (e.g., ``${(SOURCE.get_abspath())}``) when preprocessing interpolations (`issue #3933 <https://github.com/platformio/platformio-core/issues/3933>`_)
|
||||
|
2
docs
2
docs
Submodule docs updated: 2f0abf6aba...7e751e6990
@ -23,6 +23,7 @@ from serial.tools import miniterm
|
||||
from platformio import exception, fs, util
|
||||
from platformio.commands.device import helpers as device_helpers
|
||||
from platformio.platform.factory import PlatformFactory
|
||||
from platformio.project.config import ProjectConfig
|
||||
from platformio.project.exception import NotPlatformIOProjectError
|
||||
|
||||
|
||||
@ -182,19 +183,25 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches
|
||||
)
|
||||
|
||||
project_options = {}
|
||||
platform = None
|
||||
try:
|
||||
with fs.cd(kwargs["project_dir"]):
|
||||
project_options = device_helpers.get_project_options(kwargs["environment"])
|
||||
kwargs = device_helpers.apply_project_monitor_options(kwargs, project_options)
|
||||
device_helpers.register_filters(
|
||||
ProjectConfig.get_instance().get("platformio", "monitor_dir"),
|
||||
options=kwargs,
|
||||
)
|
||||
if "platform" in project_options:
|
||||
platform = PlatformFactory.new(project_options["platform"])
|
||||
device_helpers.register_filters(
|
||||
os.path.join(platform.get_dir(), "monitor"), options=kwargs
|
||||
)
|
||||
kwargs = device_helpers.apply_project_monitor_options(
|
||||
kwargs, project_options
|
||||
)
|
||||
except NotPlatformIOProjectError:
|
||||
pass
|
||||
|
||||
platform = None
|
||||
if "platform" in project_options:
|
||||
with fs.cd(kwargs["project_dir"]):
|
||||
platform = PlatformFactory.new(project_options["platform"])
|
||||
device_helpers.register_platform_filters(platform, options=kwargs)
|
||||
|
||||
if not kwargs["port"]:
|
||||
ports = util.get_serial_ports(filter_hwid=True)
|
||||
if len(ports) == 1:
|
||||
|
@ -92,11 +92,9 @@ def load_monitor_filter(path, options=None):
|
||||
return True
|
||||
|
||||
|
||||
def register_platform_filters(platform, options=None):
|
||||
monitor_dir = os.path.join(platform.get_dir(), "monitor")
|
||||
def register_filters(monitor_dir, options=None):
|
||||
if not os.path.isdir(monitor_dir):
|
||||
return
|
||||
|
||||
for name in os.listdir(monitor_dir):
|
||||
if not name.startswith("filter_") or not name.endswith(".py"):
|
||||
continue
|
||||
|
@ -314,11 +314,19 @@ ProjectOptions = OrderedDict(
|
||||
ConfigPlatformioOption(
|
||||
group="directory",
|
||||
name="boards_dir",
|
||||
description="A global storage for custom board manifests",
|
||||
description="A storage for custom board manifests",
|
||||
sysenvvar="PLATFORMIO_BOARDS_DIR",
|
||||
default=os.path.join("$PROJECT_DIR", "boards"),
|
||||
validate=validate_dir,
|
||||
),
|
||||
ConfigPlatformioOption(
|
||||
group="directory",
|
||||
name="monitor_dir",
|
||||
description="A storage for custom monitor filters",
|
||||
sysenvvar="PLATFORMIO_MONITOR_DIR",
|
||||
default=os.path.join("$PROJECT_DIR", "monitor"),
|
||||
validate=validate_dir,
|
||||
),
|
||||
ConfigPlatformioOption(
|
||||
group="directory",
|
||||
name="shared_dir",
|
||||
|
Reference in New Issue
Block a user