Commits

Ben Bass committed 9c3a276

bitbucket issue #10 - don't fail on certain ftdi_usb_get_strings failures

  • Participants
  • Parent commits 90b4118

Comments (0)

Files changed (2)

 0.13pre
 ~~~~~~~
 
+* Don't error out on failure during string retrieval part of device
+  enumeration (list_devices) on failure to read product manufacturer,
+  description or serial number (bitbucket issue #10)
 * USB_PID_LIST now defaults to 0x6001, 0x6010, 0x6011, 0x6014. The new
   entries are 0x6010 and 0x6011. Note that USB_PID has been removed, and
   USB_VID has been replaced with FTDI_VENDOR_ID

File pylibftdi/driver.py

                                                   usb_vid,
                                                   usb_pid)
                 if res < 0:
-                    raise FtdiError(self.fdll.ftdi_get_error_string(byref(ctx)))
+                    msg = "%s (%d)" % (self.get_error_string(), res)
+                    raise FtdiError(msg)
                 elif res > 0:
                     # take a copy of the dev_list for subsequent list_free
                     dev_list_base = pointer(dev_list_ptr.contents)
                                 byref(ctx),
                                 dev_list_ptr.contents.dev,
                                 manuf, 127, desc, 127, serial, 127)
-                            if res < 0:
-                                raise FtdiError(self.fdll.ftdi_get_error_string(byref(ctx)))
+                            # don't error on failure to get all the data
+                            # error codes: -7: manuf, -8: desc, -9: serial
+                            if res < 0 and res not in (-7, -8, -9):
+                                msg = "%s (%d)" % (self.get_error_string(), res)
+                                raise FtdiError(msg)
                             devices.append((manuf.value, desc.value, serial.value))
-                            # step to next in linked-list if not
+                            # step to next in linked-list
                             dev_list_ptr = cast(dev_list_ptr.contents.next,
                                                 devlistptrtype)
                     finally: