Skip to content

Commit 349615f

Browse files
committed
conflict resolution defs/common.py
1 parent 918fdaf commit 349615f

1 file changed

Lines changed: 9 additions & 5 deletions

File tree

defs/common.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import re
21
import os
2+
import re
33

4-
import serial.tools.list_ports
4+
from serial.tools import list_ports
55

66

77
def strtobool (val):
@@ -52,9 +52,13 @@ def get_usb_serial_port_info(port : str = "") -> str:
5252
if os.path.islink(port):
5353
port = os.path.realpath(port)
5454

55-
for p in serial.tools.list_ports.comports():
55+
for p in list_ports.comports(): #from serial.tools
5656
if str(p.device).upper() == port.upper():
57-
return "["+hex(p.vid)+":"+hex(p.pid)+":"+str(p.serial_number)+":"+str(p.location)+"]"
57+
vid = hex(p.vid) if p.vid is not None else ""
58+
pid = hex(p.pid) if p.pid is not None else ""
59+
serial = str(p.serial_number) if p.serial_number is not None else ""
60+
location = str(p.location) if p.location is not None else ""
61+
return "["+vid+":"+pid+":"+serial+":"+location+"]"
5862

5963
return ""
6064

@@ -76,7 +80,7 @@ def find_usb_serial_port(port : str = "", vendor_id : str = "", product_id : st
7680
serial_number = match.group("serial") if match.group("serial") else ""
7781
location = match.group("location") if match.group("location") else ""
7882

79-
for port in serial.tools.list_ports.comports():
83+
for port in list_ports.comports(): #from serial.tools
8084
if ((not vendor_id or port.vid == vendor_id) and
8185
( not product_id or port.pid == product_id) and
8286
( not serial_number or port.serial_number == serial_number) and

0 commit comments

Comments
 (0)