确切的错误是:usb.core.USBError:[Errno无] usb_claim_interface:无法声明接口
我正在使用pydev 1.0(使用libusb 1.0.9)与传感器连接。我试过摆弄各种各样的东西,但没有运气(以root身份运行我的代码不会改变任何东西)。我的代码检测到设备但在我尝试读取时死亡。我见过其他mac用户报告同样的问题,但我还没有找到答案:(
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))