既存のシリアル ポートのリストまたは列挙が必要です。今までこのメソッドenumerate_serial_ports()を使用していましたが、Windows 7 では機能しません。Windows 7 で使用可能なシリアル ポートを見つける方法を知っていますか?
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 を取得します