tiny-test-fw: IDFDUT: in the absence of configuration, try ESPPORT first
This commit is contained in:
parent
59c96ae331
commit
8a88dd3590
1 changed files with 23 additions and 0 deletions
|
@ -14,9 +14,12 @@
|
||||||
|
|
||||||
""" DUT for IDF applications """
|
""" DUT for IDF applications """
|
||||||
import os
|
import os
|
||||||
|
import sys
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import functools
|
import functools
|
||||||
|
import serial
|
||||||
|
from serial.tools import list_ports
|
||||||
|
|
||||||
import DUT
|
import DUT
|
||||||
|
|
||||||
|
@ -124,3 +127,23 @@ class IDFDUT(DUT.SerialDUT):
|
||||||
"--before", "default_reset", "--after", "hard_reset", "read_flash",
|
"--before", "default_reset", "--after", "hard_reset", "read_flash",
|
||||||
_address, _size, output_file]
|
_address, _size, output_file]
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@classmethod
|
||||||
|
def list_available_ports(cls):
|
||||||
|
ports = [x.device for x in list_ports.comports()]
|
||||||
|
port_hint = os.getenv('ESPPORT').decode('utf8')
|
||||||
|
|
||||||
|
# If $ESPPORT is a valid port, make it appear first in the list
|
||||||
|
if port_hint in ports:
|
||||||
|
ports.remove(port_hint)
|
||||||
|
return [port_hint] + ports
|
||||||
|
|
||||||
|
# On macOS, user may set ESPPORT to /dev/tty.xxx while
|
||||||
|
# pySerial lists only the corresponding /dev/cu.xxx port
|
||||||
|
if sys.platform == 'darwin' and 'tty.' in port_hint:
|
||||||
|
port_hint = port_hint.replace('tty.', 'cu.')
|
||||||
|
if port_hint in ports:
|
||||||
|
ports.remove(port_hint)
|
||||||
|
return [port_hint] + ports
|
||||||
|
|
||||||
|
return ports
|
||||||
|
|
Loading…
Reference in a new issue