Ben Bass  committed b9b35a1

stop looking for devices to open on specific errors

  • Participants
  • Parent commits d919eb3

Comments (0)

Files changed (2)

+* When finding and opening a device, don't just present the last error (which
+  may well be a 'device not found (-3)' error, but more specific ones. Avoids
+  issues where errors opening a device were being masked as pylibftdi would
+  continue looking for other devices to open, and report on failure to find
+  any of them.
 * 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)

File pylibftdi/

 USB_PID_LIST = [0x6001, 0x6010, 0x6011, 0x6014]
 class Driver(object):
                     #  - attempt to match device_id to description
                     open_args[-2], open_args[-1] = open_args[-1], open_args[-2]
                     res = self.fdll.ftdi_usb_open_desc(*tuple(open_args))
-            if res == 0:
+            if res != FTDI_ERROR_DEVICE_NOT_FOUND:
+                # if we succeed (0) or get a specific error, don't continue
+                # otherwise (-3) - look for another device
         if res != 0: