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

  • SEARCH
  • Home
  • 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 7071499
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:41:43+00:00 2026-05-28T05:41:43+00:00

I have a USB device that I need to be able to talk to

  • 0

I have a USB device that I need to be able to talk to from a .net application. The device is not a standard HID device and in order to initilise it I’ve been given a trace of packets from a USB Protocol Analyser / Sniffer for the packets used when intialising it on another type of machine. I need to replicate this packet sequence from my .net application to initialise the device.

Everything is working well until I get to a particular control transfer packet / class type request.

The trace I’ve been given states I should issue:

Control Transfer Class Type Request 
21 0A 00 00 00 00 00 00 
Result stall (intentional)

Control Transfer Class Tyoe Request
A1 01 01 03 00 00 40 00 
Result will initiate a 64 byte transfer of data from the device to the host.

This is the code I’m using to do this:

                // Transcation 6
                UsbSetupPacket setup = new UsbSetupPacket(0x21, 0x0A, 0, 0, 0);
                bool result = MyUsbDevice.ControlTransfer(ref setup, buffer, 0, out transferred);
                Console.WriteLine("Result = {0}", result);

                // Transcation 7
                setup = new UsbSetupPacket(0xA1, 0x01, 0x0301, 0x0000, 0x0040);
                result = MyUsbDevice.ControlTransfer(ref setup, buffer, 64, out transferred);

                Console.WriteLine("Result = {0}, {1}", result, transferred);

And this is the trace I’m receiving from BusHound which is sniffing the USB data traffic for this device:

Device  Phase  Data                      Description       Cmd.Phase.Ofs(rep)
------  -----  ------------------------  ----------------  ------------------
  46.0  CTL    21 0a 00 00  00 00 00 00  SET IDLE                20.1.0        
  46.0  USTS   c0000004                  stall pid               20.2.0        
  46.0  CTL    a1 01 01 03  00 00 00 00  GET REPORT              21.1.0        
  46.1  USTS   c0000004                  stall pid               22.1.0        

As you can see the 0x0040 value parameter in the setup packet is not making it out even though I’m setting it. I’m relatively new to USB and to .net / LibUsbDotNet and I’m not quite sure what I’m doing wrong. I wonder if anyone can suggest anything for me to try?

Note, I’m developing on a Windows 7 64bit machine using Visual Studio 2008.

Thanks,
Rich

  • 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-28T05:41:43+00:00Added an answer on May 28, 2026 at 5:41 am

    OK, after much investigation I found the source of the problem and it was really my lack of understanding of how LibUSBDotNet works, which isn’t helped by the poor documentation for the otherwise excellent library.

    The problem is that the 0x0040 should not be manually specified in the setup packet – this value appears to be irrelevant. Instead simply specify the bytes to transfer in the ControlTransfer method and also ensure that buffer is a pre-allocated suitably large byte array eg:

    byte[] buffer = new byte[256];
    setup = new UsbSetupPacket(0xA1, 0x01, 0x0301, 0x0000, 0x0000); 
    result = MyUsbDevice.ControlTransfer(ref setup, buffer, 0x0040, out transferred); 
    

    This will generate the correct control transfer packet sent to the USB device

    Control Transfer Class Tyoe Request   
    A1 01 01 03 00 00 40 00   
    

    It appears the LibUsbDotNet does some validation on the various parameters and in the case where the buffer array isn’t large enought it simply just sends something else instead (in my case 0x0000) rather than throwing an appropriate exception.

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

Sidebar

Related Questions

I have a .sh script that automounts any usb device that is plugged in.
Background information: I presently have a hardware device that connects to the USB port.
Is it possible to use a USB device peripheral that I have created directly
I have a device that connects to pc via USB, which gets mapped to
I have an SDK for a USB device. It includes some installer for .NET
I currently have an ASP.NET web application written in C#, and I need to
I have developed a USB device that communicates with linux over a simple but
The instruments that are used with Guitar Hero and Rock Band have USB connections.
I need to test the bandwidth I have on my USB RNDIS connection. I
I have to develop software for a USB scale that, when you press a

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.