Skip to content

Commit

Permalink
Changes on converting instance id into serial (Win32USBDeviceScanner)
Browse files Browse the repository at this point in the history
  • Loading branch information
lankes-fzj committed Apr 16, 2020
1 parent 85ce234 commit 97f036e
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions device_manager/scanner/_win32.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,12 @@ def _device_from_raw(raw_device) -> USBDevice:
# devices found.
raise TypeError("Expected PNP class \"USB\", got \"{}\" instead.".format(device_type))

if instance_id is not None and "&" not in instance_id:
# If ampersands are contained in the instance id, it cannot be a serial number
dev.serial = instance_id
if instance_id is not None:
# If the second character of the instance id is an ampersand, the device does not have a
# serial number
instance_id = instance_id.split("&")[0]
if len(instance_id) > 1:
dev.serial = instance_id

# Readout the device attributes
for key, value in attributes.items():
Expand Down

0 comments on commit 97f036e

Please sign in to comment.