Skip to content

Commit

Permalink
win32: do not check for links in serial.tools.list_ports
Browse files Browse the repository at this point in the history
fixes #303
  • Loading branch information
zsquareplusc committed May 7, 2018
1 parent 49f1993 commit 2f57d7d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
6 changes: 4 additions & 2 deletions serial/tools/list_ports_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def numsplit(text):
class ListPortInfo(object):
"""Info collection base class for serial ports"""

def __init__(self, device):
def __init__(self, device, skip_link_detection=False):
self.device = device
self.name = os.path.basename(device)
self.description = 'n/a'
Expand All @@ -46,7 +46,7 @@ def __init__(self, device):
self.product = None
self.interface = None
# special handling for links
if device is not None and os.path.islink(device):
if not skip_link_detection and device is not None and os.path.islink(device):
self.hwid = 'LINK={}'.format(os.path.realpath(device))

def usb_description(self):
Expand Down Expand Up @@ -91,6 +91,7 @@ def __getitem__(self, index):
else:
raise IndexError('{} > 2'.format(index))


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
def list_links(devices):
"""\
Expand All @@ -103,6 +104,7 @@ def list_links(devices):
links.append(device)
return links


# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# test
if __name__ == '__main__':
Expand Down
4 changes: 2 additions & 2 deletions serial/tools/list_ports_windows.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ def __str__(self):
RegCloseKey.restype = LONG

RegQueryValueEx = advapi32.RegQueryValueExW
RegQueryValueEx.argtypes = [HKEY, LPCTSTR , LPDWORD, LPDWORD, LPBYTE, LPDWORD]
RegQueryValueEx.argtypes = [HKEY, LPCTSTR, LPDWORD, LPDWORD, LPBYTE, LPDWORD]
RegQueryValueEx.restype = LONG


Expand Down Expand Up @@ -206,7 +206,7 @@ def iterate_comports():
# stringify
szHardwareID_str = szHardwareID.value

info = list_ports_common.ListPortInfo(port_name_buffer.value)
info = list_ports_common.ListPortInfo(port_name_buffer.value, skip_link_detection=True)

# in case of USB, make a more readable string, similar to that form
# that we also generate on other platforms
Expand Down

1 comment on commit 2f57d7d

@morefigs
Copy link

@morefigs morefigs commented on 2f57d7d May 13, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change is quite old now, did it ever make it into pip land?

Please sign in to comment.