mirror of
https://github.com/meshtastic/python.git
synced 2026-01-03 05:17:55 -05:00
add detection of duplicate ports to findPorts; fix smoke1 test
This commit is contained in:
@@ -24,21 +24,17 @@ class SerialInterface(StreamInterface):
|
||||
"""
|
||||
self.noProto = noProto
|
||||
|
||||
self.devPath = None
|
||||
self.devPath = devPath
|
||||
|
||||
if devPath is None:
|
||||
ports = meshtastic.util.findPorts()
|
||||
if self.devPath is None:
|
||||
ports = meshtastic.util.findPorts(True)
|
||||
logging.debug(f"ports:{ports}")
|
||||
if len(ports) == 0:
|
||||
meshtastic.util.our_exit("Warning: No Meshtastic devices detected.")
|
||||
elif len(ports) > 1:
|
||||
tmp_ports = meshtastic.util.eliminate_duplicate_port(ports)
|
||||
if len(tmp_ports) != 1:
|
||||
message = "Warning: Multiple serial ports were detected so one serial port must be specified with the '--port'.\n"
|
||||
message += f" Ports detected:{ports}"
|
||||
meshtastic.util.our_exit(message)
|
||||
else:
|
||||
self.devPath = tmp_ports[0]
|
||||
message = "Warning: Multiple serial ports were detected so one serial port must be specified with the '--port'.\n"
|
||||
message += f" Ports detected:{ports}"
|
||||
meshtastic.util.our_exit(message)
|
||||
else:
|
||||
self.devPath = ports[0]
|
||||
|
||||
|
||||
Reference in New Issue
Block a user