Skip to content

Commit 6c353f0

Browse files
author
Sorin Ciorceri
committed
Added query also for &MI_xx parameter from HardwareID string
Some USB Composite Devices will have a MI ('multiple interfaces') parameter which indicates what is the interface number of that USB device.
1 parent 055f31c commit 6c353f0

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

serial/tools/list_ports_common.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(self, device=None):
3939
# USB specific data
4040
self.vid = None
4141
self.pid = None
42+
self.mi = None
4243
self.serial_number = None
4344
self.location = None
4445
self.manufacturer = None

serial/tools/list_ports_windows.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -210,13 +210,15 @@ def iterate_comports():
210210
# in case of USB, make a more readable string, similar to that form
211211
# that we also generate on other platforms
212212
if szHardwareID_str.startswith('USB'):
213-
m = re.search(r'VID_([0-9a-f]{4})(&PID_([0-9a-f]{4}))?(\\(\w+))?', szHardwareID_str, re.I)
213+
m = re.search(r'VID_([0-9a-f]{4})(&PID_([0-9a-f]{4}))?(&MI_(\d{2}))?(\\(\w+))?', szHardwareID_str, re.I)
214214
if m:
215215
info.vid = int(m.group(1), 16)
216216
if m.group(3):
217217
info.pid = int(m.group(3), 16)
218218
if m.group(5):
219-
info.serial_number = m.group(5)
219+
info.mi = int(m.group(5))
220+
if m.group(7):
221+
info.serial_number = m.group(7)
220222
# calculate a location string
221223
loc_path_str = ctypes.create_unicode_buffer(250)
222224
if SetupDiGetDeviceRegistryProperty(

0 commit comments

Comments
 (0)