Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7581145
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T18:07:46+00:00 2026-05-30T18:07:46+00:00

I am trying to read data from a HID device. I have a USB

  • 0

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.

  1. How do I Set Idle, Get Input Report, Set Feature Report, Set Output Report?
  2. Why does the usb_bulk_read fail?
  3. What else do I need to do to set up communication with my device?
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-30T18:07:47+00:00Added an answer on May 30, 2026 at 6:07 pm

    I’m new to libusb and USB in general, so I’m not sure if this is the right thing, but after looking at the output from a USB sniffer such as USBlyzer and tweaking several things I come up with the following protocol items:

    usb_claim_interface

    When I claimed an interface (usb_claim_interface) and then cancelled my application, I was in an inoperable state on subsequent runs. I tried various resets (usb_reset and usb_resetep), but I still could not get proper usage out of usb_control_msg.

    SetReport / GetReport

    USBlyzer showed that the relevant packets where Get Descriptor, Select Configuration, Set Report, and Get Report. Get Descriptor and Select Configuration are clearly associated with usb_get_descriptor and usb_set_configuration respectively.

    Some Get Report packets contained Feature Id and others Input Id. I was able to match these with usb_control_msg with the following parameters, (libusb.c helped
    me figure this out):

    requesttype = USB_ENDPOINT_IN | USB_TYPE_CLASS | USB_RECIP_INTERFACE
    value = 0x01 (for GetReport)
    index = id | (0x03 << 8) (for FeatureId)
    

    Set Report packets also used Feature Id but Output Id. From looking at the details it became clear that Input Id matches (0x01 << 8) and Output Id matches (0x02 << 8). So to get Set Report I called usb_control_msg with these adjusted params:

    requesttype = USB_ENDPOINT_OUT | USB_TYPE_CLASS | USB_RECIP_INTERFACE
    value = 0x09 (for SetReport)
    index = id | (0x03 << 8) (for FeatureId)
    

    This may not be the “right” way to do all this, and I would certainly appreciate any deeper insight into what is happening with the various functions of the API. But this was able to get my host to capture all relevant data from the device.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to read data from an RS-232 port. Does anyone have an
I am trying to read data from excel file in asp.net. I have added
I'm trying to read encrypted struct data from file using fread(). once i get
I read data from MS Access using C#. But get the OleDbException trying to
I am trying to read data from an MS Project XML file. I have
I'm trying to read serial data from my Arduino using Java. I have followed
I am trying to read data from a serialport. When i use USB adapters
I am trying to read data from properties file.I have specified the path in
I'm trying to read data from a.csv file to ouput it on a webpage
I am trying to read data from excel files using datatable. The command select

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.