Sam Hooke

libusb usb_open error -4

If you get the following error with pylibftdi:

[...]
  File "/opt/myvenv/lib/python2.7/site-packages/pylibftdi/device.py", line 156, in open
    raise FtdiError(msg)
FtdiError: usb_open() failed (-4)

Make sure to first have these udev rules in place:

/etc/udev/rules.d/11-ftdi.rules §
# The MODE="0666" is necessary, else pylibftdi will get error -4 when it calls libusb

SUBSYSTEM=="usb", ATTR{idVendor}=="1234", ATTR{idProduct}=="5678", GROUP="plugdev", MODE="0666"

These are all the possible libusb error codes:

LIBUSB_SUCCESS = 0
LIBUSB_ERROR_IO = -1
LIBUSB_ERROR_INVALID_PARAM = -2
LIBUSB_ERROR_ACCESS = -3
LIBUSB_ERROR_NO_DEVICE = -4
LIBUSB_ERROR_NOT_FOUND = -5
LIBUSB_ERROR_BUSY = -6
LIBUSB_ERROR_TIMEOUT = -7
LIBUSB_ERROR_OVERFLOW = -8
LIBUSB_ERROR_PIPE = -9
LIBUSB_ERROR_INTERRUPTED = -10
LIBUSB_ERROR_NO_MEM = -11
LIBUSB_ERROR_NOT_SUPPORTED = -12
LIBUSB_ERROR_OTHER = -99

These are rough notes that vary greatly in quality and length, but prove useful to me, and hopefully to you too!

← Previous: Troubleshooting wifi driver crashing (part 4)
Next: Python DEPRECATION warning and pip --no-cache-dir breakage →