Skip to content

Commit

Permalink
[splib3] serialport: fixes case of NoneType entry (#126)
Browse files Browse the repository at this point in the history
  • Loading branch information
EulalieCoevoet authored Oct 18, 2024
1 parent 4addc7b commit c37d478
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions python3/src/splib3/interface/serialport.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,17 @@ def getDevicePort(entry, method="manufacturer"):
ports = []
comports = serial.tools.list_ports.comports()

if comports is None:
if comports is None or len(comports) == 0:
Sofa.msg_error("stlib3.interface.serialport",
"Serial ports check failed, list of ports is empty.")
return

if method == "manufacturer":
ports = [p for p in comports if entry in p.manufacturer]
ports = [p for p in comports if p.manufacturer is not None and entry in p.manufacturer]
if method == "description":
ports = [p for p in comports if entry in p.description]
ports = [p for p in comports if p.description is not None and entry in p.description]
if method == "serial_number":
ports = [p for p in comports if entry in p.serial_number]
ports = [p for p in comports if p.serial_number is not None and entry in p.serial_number]

if not ports:
Sofa.msg_error("stlib3.interface.serialport",
Expand Down

0 comments on commit c37d478

Please sign in to comment.