我需要的列表或列举现有的串口, 直到现在我用这个方法enumerate_serial_ports(),但它与Windows 7不工作,你知道一些替代我怎样才能找到可用的串行在Windows 7下的端口?pyserial枚举端口
def enumerate_serial_ports():
""" Uses the Win32 registry to return an
iterator of serial (COM) ports
existing on this computer.
"""
path = 'HARDWARE\\DEVICEMAP\\SERIALCOMM'
try:
key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, path)
except WindowsError:
raise IterationError
for i in itertools.count():
try:
val = winreg.EnumValue(key, i)
yield str(val[1])
except EnvironmentError:
break
我得到IterationError
什么是不工作? – 2011-05-30 12:50:17
到Space_C0wb0y:添加图片 – Meloun 2011-05-30 12:56:44
不会引发nnknown类异常(IterationError),让回溯帮助我们了解真正的问题; – 2011-05-30 13:03:14