mirror of
https://github.com/platformio/platformio-core.git
synced 2025-08-01 02:54:25 +02:00
* Autodetect serial port for boards with specified hwids * Add new record to history log
This commit is contained in:
@@ -23,6 +23,7 @@ PlatformIO Core 4.0
|
|||||||
* Added support for "pythonPackages" in `platform.json <https://docs.platformio.org/page/platforms/creating_platform.html#manifest-file-platform-json>`__ manifest (PlatformIO Package Manager will install dependent Python packages from PyPi registry automatically when dev-platform is installed)
|
* Added support for "pythonPackages" in `platform.json <https://docs.platformio.org/page/platforms/creating_platform.html#manifest-file-platform-json>`__ manifest (PlatformIO Package Manager will install dependent Python packages from PyPi registry automatically when dev-platform is installed)
|
||||||
* Handle project configuration (monitor, test, and upload options) for PIO Remote commands (`issue #2591 <https://github.com/platformio/platformio-core/issues/2591>`_)
|
* Handle project configuration (monitor, test, and upload options) for PIO Remote commands (`issue #2591 <https://github.com/platformio/platformio-core/issues/2591>`_)
|
||||||
* Added support for Arduino's library.properties ``depends`` field (`issue #2781 <https://github.com/platformio/platformio-core/issues/2781>`_)
|
* Added support for Arduino's library.properties ``depends`` field (`issue #2781 <https://github.com/platformio/platformio-core/issues/2781>`_)
|
||||||
|
* Autodetect monitor port for boards with specified HWIDs (`issue #3349 <https://github.com/platformio/platformio-core/issues/3349>`_)
|
||||||
* Updated SCons tool to 3.1.2
|
* Updated SCons tool to 3.1.2
|
||||||
* Updated Unity tool to 2.5.0
|
* Updated Unity tool to 2.5.0
|
||||||
* Made package ManifestSchema compatible with marshmallow >= 3 (`issue #3296 <https://github.com/platformio/platformio-core/issues/3296>`_)
|
* Made package ManifestSchema compatible with marshmallow >= 3 (`issue #3296 <https://github.com/platformio/platformio-core/issues/3296>`_)
|
||||||
|
@@ -21,6 +21,7 @@ from serial.tools import miniterm
|
|||||||
|
|
||||||
from platformio import exception, fs, util
|
from platformio import exception, fs, util
|
||||||
from platformio.compat import dump_json_to_unicode
|
from platformio.compat import dump_json_to_unicode
|
||||||
|
from platformio.managers.platform import PlatformFactory
|
||||||
from platformio.project.config import ProjectConfig
|
from platformio.project.config import ProjectConfig
|
||||||
from platformio.project.exception import NotPlatformIOProjectError
|
from platformio.project.exception import NotPlatformIOProjectError
|
||||||
|
|
||||||
@@ -189,6 +190,20 @@ def device_monitor(**kwargs): # pylint: disable=too-many-branches
|
|||||||
ports = util.get_serial_ports(filter_hwid=True)
|
ports = util.get_serial_ports(filter_hwid=True)
|
||||||
if len(ports) == 1:
|
if len(ports) == 1:
|
||||||
kwargs["port"] = ports[0]["port"]
|
kwargs["port"] = ports[0]["port"]
|
||||||
|
elif "platform" in project_options and "board" in project_options:
|
||||||
|
board_hwids = get_board_hwids(
|
||||||
|
kwargs["project_dir"],
|
||||||
|
project_options["platform"],
|
||||||
|
project_options["board"],
|
||||||
|
)
|
||||||
|
for item in ports:
|
||||||
|
for hwid in board_hwids:
|
||||||
|
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
|
||||||
|
if hwid_str in item["hwid"]:
|
||||||
|
kwargs["port"] = item["port"]
|
||||||
|
break
|
||||||
|
if kwargs["port"]:
|
||||||
|
break
|
||||||
elif kwargs["port"] and (set(["*", "?", "[", "]"]) & set(kwargs["port"])):
|
elif kwargs["port"] and (set(["*", "?", "[", "]"]) & set(kwargs["port"])):
|
||||||
for item in util.get_serial_ports():
|
for item in util.get_serial_ports():
|
||||||
if fnmatch(item["port"], kwargs["port"]):
|
if fnmatch(item["port"], kwargs["port"]):
|
||||||
@@ -254,3 +269,12 @@ def get_project_options(environment=None):
|
|||||||
else:
|
else:
|
||||||
environment = config.envs()[0]
|
environment = config.envs()[0]
|
||||||
return config.items(env=environment, as_dict=True)
|
return config.items(env=environment, as_dict=True)
|
||||||
|
|
||||||
|
|
||||||
|
def get_board_hwids(project_dir, platform, board):
|
||||||
|
with fs.cd(project_dir):
|
||||||
|
return (
|
||||||
|
PlatformFactory.newPlatform(platform)
|
||||||
|
.board_config(board)
|
||||||
|
.get("build.hwids", [])
|
||||||
|
)
|
||||||
|
Reference in New Issue
Block a user