diff options
author | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-06 00:15:56 +0000 |
---|---|---|
committer | cliechti <cliechti@f19166aa-fa4f-0410-85c2-fa1106f25c8a> | 2009-08-06 00:15:56 +0000 |
commit | 15d21ebd9316e8c813c6dfe45d344edefcb10970 (patch) | |
tree | 53ddeb4ed0340e52e7757317d4f5edf269cb609f /examples | |
parent | 6c83957036f93372801ed1d7bf1076d82f9785c5 (diff) | |
download | pyserial-15d21ebd9316e8c813c6dfe45d344edefcb10970.tar.gz |
- fix error introduced by last patch
- fix problem with devices that have no "friendly name"
git-svn-id: http://svn.code.sf.net/p/pyserial/code/trunk/pyserial@307 f19166aa-fa4f-0410-85c2-fa1106f25c8a
Diffstat (limited to 'examples')
-rw-r--r-- | examples/scanwin32.py | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/examples/scanwin32.py b/examples/scanwin32.py index 6d58d89..aec5bb0 100644 --- a/examples/scanwin32.py +++ b/examples/scanwin32.py @@ -61,7 +61,8 @@ PSP_DEVICE_INTERFACE_DATA = ctypes.POINTER(SP_DEVICE_INTERFACE_DATA) PSP_DEVICE_INTERFACE_DETAIL_DATA = ctypes.c_void_p class dummy(ctypes.Structure): - _fields_=[("d1",ctypes.DWORD), ("d2",ctypes.CHAR)] + _fields_=[("d1", DWORD), ("d2", CHAR)] + _pack_ = 1 SIZEOF_SP_DEVICE_INTERFACE_DETAIL_DATA_A = ctypes.sizeof(dummy) SetupDiDestroyDeviceInfoList = ctypes.windll.setupapi.SetupDiDestroyDeviceInfoList @@ -165,7 +166,7 @@ def comports(available_only=True): raise ctypes.WinError() # friendly name - szFriendlyName = ctypes.create_string_buffer('\0' * 250) + szFriendlyName = ctypes.create_string_buffer(1024) if not SetupDiGetDeviceRegistryProperty( g_hdi, ctypes.byref(devinfo), @@ -176,11 +177,13 @@ def comports(available_only=True): ): # Ignore ERROR_INSUFFICIENT_BUFFER if ctypes.GetLastError() != ERROR_INSUFFICIENT_BUFFER: - raise ctypes.WinError() + #~ raise ctypes.WinError() + # not getting friendly name for com0com devices -> skip it + continue try: port_name = re.search(r"\((.*)\)", szFriendlyName.value).group(1) - except AttributeError,msg: - port_name = "???" + except AttributeError, msg: + pass yield port_name, szFriendlyName.value, szHardwareID.value SetupDiDestroyDeviceInfoList(g_hdi) |