我正在尝试从HID设备读取数据。我有一个 USB 嗅探器捕获,基本上可以:
Get Device Descriptor
Get Device Descriptor
Set Address
Get Configuration Descriptor
Get Configuration Descriptor
Set Configuration
Set Idle
Get Input Report
Get Input Report
Get Input Report
Get Input Report
Set Feature Report
Get Input Report
Set Feature Report
Get Input Report
Get Input Report
Set Output Report
Get Input Report
Set Feature Report
Input Report
Input Report
似乎在Input Report
设置之前的所有内容都是Input Report
从设备收集的常规数据。
在libusb中,我正在执行以下操作:
usb_init();
usb_find_busses();
usb_find_devices();
loop through busses
loop through devices
if correct vendor and correct product
handle = usb_open(device)
break
usb_set_configuration(dev_handle, 1)
// Endpoint 0 is a 'write endpoint', endpoint 1 is a 'read endpoint'.
endpoint = &device->config[0].interface[0].altsetting[0].endpoint[1]
usb_claim_interface(dev_handle, 0)
usb_set_altinterface(dev_handle, 0)
usb_bulk_read(dev_handle, endpoint->bEndpointAddress, buffer, endpoint->wMaxPacketSize, 1);
我猜测驱动程序和代码最高usb_set_configuration
对应于嗅探器分析最高Set Configuration
.
代码中的所有内容都会成功,直到usb_bulk_read
which 失败。
- 我怎么
Set Idle
,,,,?Get Input Report
_Set Feature Report
Set Output Report
- 为什么会
usb_bulk_read
失败? - 我还需要做什么才能与我的设备建立通信?