Playing around with PyUSB a bit to see if it offers some insight as to why a WebUSB library I'm using isn't finding my device. I installed libusb1 on the Mac via Homebrew with brew install libusb
.
Ran lsusb -vv
to get device details. Also set a couple of environment variables for PyUSB:
export PYUSB_LOG_FILENAME=pysubdebug.log
and export PYUSB_DEBUG=debug
import usb
VENDOR_ID = 0x0483
PRODUCT_ID = 0x5740
DATA_SIZE = 1
device = usb.core.find(idVendor=VENDOR_ID, idProduct=PRODUCT_ID)
>>> device
<DEVICE ID 0483:5740 on Bus 020 Address 014>
>>> device.is_kernel_driver_active(0)
False
>>> device.set_configuration()
Traceback (abridged)
usb.core.USBError: [Errno 19] No such device (it may have been disconnected)
>>> cfg = device.get_active_configuration()
Traceback (abridged)
usb.core.USBError: [Errno None] Configuration not set
From the log file it looks like python (which is in a venv) is using a file located at /usr/local/lib/
:
2020-10-27 12:20:41,706 DEBUG:usb.backend.libusb1:_LibUSB.__init__(<CDLL '/usr/local/lib/libusb-1.0.dylib', handle 7f8ba652c7f0 at 0x1101a5f70>)
2020-10-27 12:20:41,712 INFO:usb.core:find(): using backend "usb.backend.libusb1"
Brewed files:
$brew ls libusb
/usr/local/Cellar/libusb/1.0.23/include/libusb-1.0/libusb.h
/usr/local/Cellar/libusb/1.0.23/lib/libusb-1.0.0.dylib
/usr/local/Cellar/libusb/1.0.23/lib/pkgconfig/libusb-1.0.pc
/usr/local/Cellar/libusb/1.0.23/lib/ (2 other files)
/usr/local/Cellar/libusb/1.0.23/share/libusb/ (13 files)
And confirming that PyUSB is looking in the right location:
ls -l /usr/local/lib/libusb-1.0.dylib
lrwxr-xr-x #details# /usr/local/lib/libusb-1.0.dylib@ -> ../Cellar/libusb/1.0.23/lib/libusb-1.0.dylib
Do I need to be creating a function to Specify a library by hand? Doesn't seem like that's the issue.
Maybe there's a configuration step I'm missing.