forked from platformio/platformio-core
Unix shell-style wildcards for “upload_port” // Resolve #839
This commit is contained in:
14
HISTORY.rst
14
HISTORY.rst
@ -19,18 +19,20 @@ PlatformIO 3.0
|
|||||||
* `PIO Account <http://docs.platformio.org/en/latest/userguide/account/index.html>`__
|
* `PIO Account <http://docs.platformio.org/en/latest/userguide/account/index.html>`__
|
||||||
and `PLATFORMIO_AUTH_TOKEN <http://docs.platformio.org/en/latest/envvars.html#envvar-PLATFORMIO_AUTH_TOKEN>`__
|
and `PLATFORMIO_AUTH_TOKEN <http://docs.platformio.org/en/latest/envvars.html#envvar-PLATFORMIO_AUTH_TOKEN>`__
|
||||||
environment variable for CI systems
|
environment variable for CI systems
|
||||||
* Refactored `Library Dependency Finder (LDF) <http://docs.platformio.org/en/stable/librarymanager/ldf.html>`__
|
|
||||||
C/C++ Preprocessor for conditional syntax (``#ifdef``, ``#if``, ``#else``,
|
|
||||||
``#elif``, ``#define``, etc.)
|
|
||||||
(`issue #837 <https://github.com/platformio/platformio/issues/837>`_)
|
|
||||||
* Added new `LDF Modes <http://docs.platformio.org/en/latest/librarymanager/ldf.html#ldf-mode>`__:
|
|
||||||
``chain+`` and ``deep+`` and set ``chain+`` as default
|
|
||||||
* Inject system environment variables to configuration settings in
|
* Inject system environment variables to configuration settings in
|
||||||
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/stable/projectconf.html>`__
|
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/stable/projectconf.html>`__
|
||||||
(`issue #792 <https://github.com/platformio/platformio/issues/792>`_)
|
(`issue #792 <https://github.com/platformio/platformio/issues/792>`_)
|
||||||
* Custom boards per project with ``boards_dir`` option in
|
* Custom boards per project with ``boards_dir`` option in
|
||||||
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/stable/projectconf.html>`__
|
`Project Configuration File "platformio.ini" <http://docs.platformio.org/en/stable/projectconf.html>`__
|
||||||
(`issue #515 <https://github.com/platformio/platformio/issues/515>`_)
|
(`issue #515 <https://github.com/platformio/platformio/issues/515>`_)
|
||||||
|
* Unix shell-style wildcards for `upload_port <http://docs.platformio.org/en/latest/projectconf.html#upload-port>`_
|
||||||
|
(`issue #839 <https://github.com/platformio/platformio/issues/839>`_)
|
||||||
|
* Refactored `Library Dependency Finder (LDF) <http://docs.platformio.org/en/stable/librarymanager/ldf.html>`__
|
||||||
|
C/C++ Preprocessor for conditional syntax (``#ifdef``, ``#if``, ``#else``,
|
||||||
|
``#elif``, ``#define``, etc.)
|
||||||
|
(`issue #837 <https://github.com/platformio/platformio/issues/837>`_)
|
||||||
|
* Added new `LDF Modes <http://docs.platformio.org/en/latest/librarymanager/ldf.html#ldf-mode>`__:
|
||||||
|
``chain+`` and ``deep+`` and set ``chain+`` as default
|
||||||
* Changed a default exit combination for Device Monitor from ``Ctrl+]`` to ``Ctrl+C``
|
* Changed a default exit combination for Device Monitor from ``Ctrl+]`` to ``Ctrl+C``
|
||||||
* Improved detecting of ARM mbed media disk for uploading
|
* Improved detecting of ARM mbed media disk for uploading
|
||||||
* Improved Project Generator for CLion IDE when source folder contains nested items
|
* Improved Project Generator for CLion IDE when source folder contains nested items
|
||||||
|
@ -653,6 +653,26 @@ To print all available serial ports use :ref:`cmd_device_list` command.
|
|||||||
This option can be set by global environment variable
|
This option can be set by global environment variable
|
||||||
:envvar:`PLATFORMIO_UPLOAD_PORT`.
|
:envvar:`PLATFORMIO_UPLOAD_PORT`.
|
||||||
|
|
||||||
|
Please note that you can use Unix shell-style wildcards:
|
||||||
|
|
||||||
|
.. list-table::
|
||||||
|
:header-rows: 1
|
||||||
|
|
||||||
|
* - Pattern
|
||||||
|
- Meaning
|
||||||
|
|
||||||
|
* - ``*``
|
||||||
|
- matches everything
|
||||||
|
|
||||||
|
* - ``?``
|
||||||
|
- matches any single character
|
||||||
|
|
||||||
|
* - ``[seq]``
|
||||||
|
- matches any character in seq
|
||||||
|
|
||||||
|
* - ``[!seq]``
|
||||||
|
- matches any character not in seq
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
.. code-block:: ini
|
.. code-block:: ini
|
||||||
@ -660,8 +680,11 @@ Example:
|
|||||||
[env:uno]
|
[env:uno]
|
||||||
platform = atmelavr
|
platform = atmelavr
|
||||||
framework = arduino
|
framework = arduino
|
||||||
board = uno
|
; any port that stats with /dev/ttyUSB
|
||||||
upload_port = /dev/ttyUSB0
|
upload_port = /dev/ttyUSB*
|
||||||
|
|
||||||
|
; COM1 or COM3
|
||||||
|
upload_port = COM[13]
|
||||||
|
|
||||||
``upload_protocol``
|
``upload_protocol``
|
||||||
^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
from __future__ import absolute_import
|
from __future__ import absolute_import
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
|
from fnmatch import fnmatch
|
||||||
from os import environ
|
from os import environ
|
||||||
from os.path import isfile, join
|
from os.path import isfile, join
|
||||||
from platform import system
|
from platform import system
|
||||||
@ -85,9 +86,24 @@ def WaitForNewSerialPort(env, before):
|
|||||||
def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
|
def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
|
||||||
env = args[0]
|
env = args[0]
|
||||||
|
|
||||||
|
def _get_pattern():
|
||||||
|
if "UPLOAD_PORT" not in env:
|
||||||
|
return None
|
||||||
|
if set(["*", "?", "[", "]"]) & set(env['UPLOAD_PORT']):
|
||||||
|
return env['UPLOAD_PORT']
|
||||||
|
return None
|
||||||
|
|
||||||
|
def _is_match_pattern(port):
|
||||||
|
pattern = _get_pattern()
|
||||||
|
if not pattern:
|
||||||
|
return True
|
||||||
|
return fnmatch(port, pattern)
|
||||||
|
|
||||||
def _look_for_mbed_disk():
|
def _look_for_mbed_disk():
|
||||||
msdlabels = ("mbed", "nucleo", "frdm", "microbit")
|
msdlabels = ("mbed", "nucleo", "frdm", "microbit")
|
||||||
for item in util.get_logicaldisks():
|
for item in util.get_logicaldisks():
|
||||||
|
if not _is_match_pattern(item['disk']):
|
||||||
|
continue
|
||||||
if (item['name'] and
|
if (item['name'] and
|
||||||
any([l in item['name'].lower() for l in msdlabels])):
|
any([l in item['name'].lower() for l in msdlabels])):
|
||||||
return item['disk']
|
return item['disk']
|
||||||
@ -101,6 +117,8 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
|
|||||||
if "BOARD" in env and "build.hwids" in env.BoardConfig():
|
if "BOARD" in env and "build.hwids" in env.BoardConfig():
|
||||||
board_hwids = env.BoardConfig().get("build.hwids")
|
board_hwids = env.BoardConfig().get("build.hwids")
|
||||||
for item in util.get_serialports(filter_hwid=True):
|
for item in util.get_serialports(filter_hwid=True):
|
||||||
|
if not _is_match_pattern(item['port']):
|
||||||
|
continue
|
||||||
port = item['port']
|
port = item['port']
|
||||||
for hwid in board_hwids:
|
for hwid in board_hwids:
|
||||||
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
|
hwid_str = ("%s:%s" % (hwid[0], hwid[1])).replace("0x", "")
|
||||||
@ -108,7 +126,7 @@ def AutodetectUploadPort(*args, **kwargs): # pylint: disable=unused-argument
|
|||||||
return port
|
return port
|
||||||
return port
|
return port
|
||||||
|
|
||||||
if "UPLOAD_PORT" in env:
|
if "UPLOAD_PORT" in env and not _get_pattern():
|
||||||
print env.subst("Use manually specified: $UPLOAD_PORT")
|
print env.subst("Use manually specified: $UPLOAD_PORT")
|
||||||
return
|
return
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user