#109 list_ports does not show all ports

v1.0 (example)
closed-fixed
Chris Liechti
None
5
2013-05-31
2011-09-27
Stephan Walter
No

I have 4 serial ports on my system:
COM1 - actual serial port on the mainboard
COM12 - USB-serial adapter
COM21, COM22 - virtual serial ports created by null-modem emulator: http://com0com.sourceforge.net/

using serial.tools.list_ports, I only get the first two (COM1 and COM12).

Using the following code, I am able to get all four:

import itertools
import _winreg as winreg

def enumerate_serial_ports():
path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path)
ports = []
for i in itertools.count():
try:
val = winreg.EnumValue(key, i)
ports.append(str(val[1]))
except EnvironmentError:
break
return sorted(ports)

Discussion

  • Stephan Walter
    Stephan Walter
    2011-09-27

    Sorry, sourceforge sucks.

    Here's the code with proper indentation: https://gist.github.com/1244446

     
  • Chris Liechti
    Chris Liechti
    2013-05-31

    This is similar to Bug #144 which should be fixed in next release (2.7)

     
  • Chris Liechti
    Chris Liechti
    2013-05-31

    • status: open --> closed-fixed
    • assigned_to: Chris Liechti
    • Group: --> v1.0 (example)