Skip to content

Commit

Permalink
Handle null ports
Browse files Browse the repository at this point in the history
  • Loading branch information
lbussy committed Mar 29, 2021
1 parent ddf80fb commit 2131590
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions autoSerial.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,13 @@ def configure_serial_for_device(s, d):

for p in find_all_serial_ports():
try:
print("{0}, VID:{1:04x}, PID:{2:04x}".format(str(p), (p.vid), (p.pid)))
if (p.vid):
print("{0}, VID:{1:04x}, PID:{2:04x}".format(str(p), (p.vid), (p.pid)))
else:
print("{} has no PID.".format(str(p)))
except ValueError:
# could not convert pid and vid to hex
print("{0}, VID:{1}, PID:{2}".format(str(p), (p.vid), (p.pid)))
print("Value Error: {0}, VID:{1}, PID:{2}".format(str(p), (p.vid), (p.pid)))
print("Compatible ports: ")
for p in find_compatible_serial_ports():
print(p)
Expand Down

0 comments on commit 2131590

Please sign in to comment.