Skip to content

Commit

Permalink
Merge branch 'bugfix/tiny_test_fw_filter_invalid_serial_port' into 'm…
Browse files Browse the repository at this point in the history
…aster'

tiny-test-fw: filter out invalid IDF ports

See merge request idf/esp-idf!2745
  • Loading branch information
heyinling committed Jul 12, 2018
2 parents dc09236 + 5edc9f9 commit 05d74d5
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions tools/tiny-test-fw/IDF/IDFDUT.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,9 @@ class IDFDUT(DUT.SerialDUT):
""" IDF DUT, extends serial with ESPTool methods """

CHIP_TYPE_PATTERN = re.compile(r"Detecting chip type[.:\s]+(.+)")
# /dev/ttyAMA0 port is listed in Raspberry Pi
# /dev/tty.Bluetooth-Incoming-Port port is listed in Mac
INVALID_PORT_PATTERN = re.compile(r"AMA|Bluetooth")

def __init__(self, name, port, log_file, app, **kwargs):
self.download_config, self.partition_table = app.process_app_info()
Expand Down Expand Up @@ -133,8 +136,14 @@ def list_available_ports(cls):
ports = [x.device for x in list_ports.comports()]
espport = os.getenv('ESPPORT')
if not espport:
return ports

# It's a little hard filter out invalid port with `serial.tools.list_ports.grep()`:
# The check condition in `grep` is: `if r.search(port) or r.search(desc) or r.search(hwid)`.
# This means we need to make all 3 conditions fail, to filter out the port.
# So some part of the filters will not be straight forward to users.
# And negative regular expression (`^((?!aa|bb|cc).)*$`) is not easy to understand.
# Filter out invalid port by our own will be much simpler.
return [x for x in ports if not cls.INVALID_PORT_PATTERN.search(x)]

port_hint = espport.decode('utf8')

# If $ESPPORT is a valid port, make it appear first in the list
Expand Down

0 comments on commit 05d74d5

Please sign in to comment.