forked from platformio/platformio-core
Improve firmware uploading to Arduino Leonardo based boards
This commit is contained in:
@ -16,6 +16,7 @@ PlatformIO 2.0
|
||||
(`issue #585 <https://github.com/platformio/platformio/issues/585>`_)
|
||||
* Use HTTP mirror for Package Manager in a case with SSL errors
|
||||
(`issue #645 <https://github.com/platformio/platformio/issues/645>`_)
|
||||
* Improved firmware uploading to Arduino Leonardo based boards
|
||||
* Fixed bug with ``env_default`` when ``pio run -e`` is used
|
||||
* Fixed issue with ``src_filter`` option for Windows OS
|
||||
(`issue #652 <https://github.com/platformio/platformio/issues/652>`_)
|
||||
|
@ -50,8 +50,9 @@ def TouchSerialPort(env, port, baudrate):
|
||||
def WaitForNewSerialPort(env, before):
|
||||
new_port = None
|
||||
elapsed = 0
|
||||
sleep(0.5)
|
||||
while elapsed < 10:
|
||||
now = [i['port'] for i in get_serialports()]
|
||||
now = [i['port'] for i in get_serialports(use_grep=True)]
|
||||
diff = list(set(now) - set(before))
|
||||
if diff:
|
||||
new_port = diff[0]
|
||||
|
@ -280,7 +280,24 @@ def exec_command(*args, **kwargs):
|
||||
return result
|
||||
|
||||
|
||||
def get_serialports():
|
||||
def get_serialports(use_grep=False):
|
||||
|
||||
def _grep_serial_ports():
|
||||
assert "Windows" != system()
|
||||
result = []
|
||||
if "Linux" == system():
|
||||
patterns = ["/dev/%s*" % p for p in (
|
||||
"ttyS", "ttyUSB", "ttyACM", "ttyAMA", "rfcomm", "ttyO")]
|
||||
else:
|
||||
patterns = ["/dev/tty.*"]
|
||||
for pattern in patterns:
|
||||
for port in glob(pattern):
|
||||
result.append({"port": port, "description": "", "hwid": ""})
|
||||
return result
|
||||
|
||||
if use_grep and "Windows" != system():
|
||||
return _grep_serial_ports()
|
||||
|
||||
try:
|
||||
from serial.tools.list_ports import comports
|
||||
except ImportError:
|
||||
@ -290,7 +307,7 @@ def get_serialports():
|
||||
for p, d, h in comports():
|
||||
if not p:
|
||||
continue
|
||||
if "windows" in get_systype():
|
||||
if "Windows" == system():
|
||||
try:
|
||||
d = unicode(d, errors="ignore")
|
||||
except TypeError:
|
||||
@ -298,9 +315,9 @@ def get_serialports():
|
||||
result.append({"port": p, "description": d, "hwid": h})
|
||||
|
||||
# fix for PySerial
|
||||
if not result and system() == "Darwin":
|
||||
for p in glob("/dev/tty.*"):
|
||||
result.append({"port": p, "description": "", "hwid": ""})
|
||||
if not result:
|
||||
result = _grep_serial_ports()
|
||||
|
||||
return result
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user