【发布时间】:2012-03-19 07:00:43
【问题描述】:
我正在尝试从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 失败。
- 我如何
Set Idle、Get Input Report、Set Feature Report、Set Output Report? - 为什么
usb_bulk_read会失败? - 我还需要做什么才能与我的设备建立通信?
【问题讨论】:
-
你是用哪个usb-sniffer得到上述报告的?