Skip to content

Commit 13c8f6d

Browse files
committed
feat(list_ports): add interface num to location on win32
1 parent cfea7d0 commit 13c8f6d

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

serial/tools/list_ports_common.py

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

serial/tools/list_ports_windows.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,7 @@ def iterate_comports():
143143

144144
# repeat for all possible GUIDs
145145
for index in range(guids_size.value):
146+
bInterfaceNumber = None
146147
g_hdi = SetupDiGetClassDevs(
147148
ctypes.byref(GUIDs[index]),
148149
None,
@@ -216,7 +217,7 @@ def iterate_comports():
216217
if m.group(3):
217218
info.pid = int(m.group(3), 16)
218219
if m.group(5):
219-
info.mi = int(m.group(5))
220+
bInterfaceNumber = int(m.group(5))
220221
if m.group(7):
221222
info.serial_number = m.group(7)
222223
# calculate a location string
@@ -240,6 +241,10 @@ def iterate_comports():
240241
else:
241242
location.append('-')
242243
location.append(g.group(2))
244+
if bInterfaceNumber is not None:
245+
location.append(':{}.{}'.format(
246+
'x', # XXX how to determine correct bConfigurationValue?
247+
bInterfaceNumber))
243248
if location:
244249
info.location = ''.join(location)
245250
info.hwid = info.usb_info()

0 commit comments

Comments
 (0)