I am trying to read data from a HID device. I have a USB sniffer capture that basically does:
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
It appears that everything before the Input Report
is setup and that Input Report
is the regular data collection from the device.
In libusb, I am doing the following:
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);
I am guessing that the driver and the code up to usb_set_configuration
corresponds with the sniffer analysis up to Set Configuration
.
Everything in the code succeeds until the usb_bulk_read
which fails.
- How do I
Set Idle
,Get Input Report
,Set Feature Report
,Set Output Report
? - Why does the
usb_bulk_read
fail? - What else do I need to do to set up communication with my device?