The exact error is: usb.core.USBError: [Errno None] usb_claim_interface: couldn't claim interface
I'm using pydev 1.0 (with libusb 1.0.9) to interface with a sensor. I've tried fiddling with various things but have had no luck (running my code as root doesn't change anything). My code detects the device but dies when I try to read from it. I've seen other mac users report this same problem but I have yet to find an answer :(
device = usb.core.find(idVendor = vendorId, idProduct = productId)
device.set_configuration()
cfg = device.get_active_configuration()
interface_number = cfg[(0,0)].bInterfaceNumber
alternate_setting = usb.control.get_interface(device, interface_number)
# Get Interface Descriptor
intf = usb.util.find_descriptor(
cfg,
bInterfaceNumber = interface_number,
bAlternateSetting = alternate_setting
)
# Get Endpoint Descriptor
ep = usb.util.find_descriptor(
intf,
custom_match = \
lambda e: \
usb.util.endpoint_direction(e.bEndpointAddress) == \
usb.util.ENDPOINT_IN
)
assert ep is not None
# Tried this but didn't help :/
# usb.util.claim_interface(device, intf)
size = 2
print str(device.read(0x82, size))