Skip to content

Commit c37d478

Browse files
[splib3] serialport: fixes case of NoneType entry (#126)
1 parent 4addc7b commit c37d478

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

‎python3/src/splib3/interface/serialport.py‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ def getDevicePort(entry, method="manufacturer"):
1313
ports = []
1414
comports = serial.tools.list_ports.comports()
1515

16-
if comports is None:
16+
if comports is None or len(comports) == 0:
1717
Sofa.msg_error("stlib3.interface.serialport",
1818
"Serial ports check failed, list of ports is empty.")
1919
return
2020

2121
if method == "manufacturer":
22-
ports = [p for p in comports if entry in p.manufacturer]
22+
ports = [p for p in comports if p.manufacturer is not None and entry in p.manufacturer]
2323
if method == "description":
24-
ports = [p for p in comports if entry in p.description]
24+
ports = [p for p in comports if p.description is not None and entry in p.description]
2525
if method == "serial_number":
26-
ports = [p for p in comports if entry in p.serial_number]
26+
ports = [p for p in comports if p.serial_number is not None and entry in p.serial_number]
2727

2828
if not ports:
2929
Sofa.msg_error("stlib3.interface.serialport",

0 commit comments

Comments
 (0)