Generic HID Descriptor


I am trying to build a data acquisition board using a FEZ Panda II connected via USB to a windows computer.

I changed to board to serial debugging, to free up the USB port.

I would like to use it as an HID, so the Windows PC will not require any additional device drivers.

The board will report the values (digitial and analog) at intervals, but will also receive commands. I.e. change digital output values, change the report time interval, reboot, etc.

For this I have created a “command protocol”, where the Windows PC transmits a command to the board, and the board replies with ACK/NACK and parameters.

Building a HID is no easy task (for me at least), but is is possible to declare a generic 30 byte input buffer, and 50 byte output buffer? Then I could more or less use it as a serial port.

I know GHI supports virtual serial ports, but it requires custom device drivers.

Any HID wizards out there that have suggestions?

My code post about USB HID shows exactly how to do this:

Welcome to the forum!

Thanks WouterH, I did see you excellent sample - and I copied a lot of it :slight_smile:

However, my problem is not the implementation it self (yet), but the descriptor (hidGenericReportDescriptorPayload in your case).

My device does not have buttons or other stuff, I would just like to declare a read buffer of x bytes, and a write buffer of y bytes.

Any advice on how to write a descriptor for that?

Copy the descriptor from a known device (by using USBView or USB sniffing software like USB Snoopy).

In the about tab of the project on Codeshare, there is a link to the HID descriptor tool, which lets you build your own HID Descriptor from scratch and generates a C array for it:

I also looked at the USB tool you mentioned.
I build something like this:

USAGE_PAGE (Consumer Devices) 05 0C
USAGE (Consumer Control) 09 01
REPORT_SIZE (400) 76 90 01
REPORT_COUNT (1) 95 01
OUTPUT (Cnst,Ary,Abs) 91 01
REPORT_SIZE (240) 75 F0
REPORT_COUNT (1) 95 01
INPUT (Cnst,Ary,Abs) 81 01

You think it would work?

No idea. Hit run and connect to PC and you’ll know :slight_smile:

This guy did the trick - 16 bytes in, 16 bytes out.

char ReportDescriptor[33] = {
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x3b,                    // USAGE (Byte Count)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x09, 0x3b,                    //   USAGE (Byte Count)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x95, 0x10,                    //   REPORT_COUNT (16)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0x09, 0x3b,                    //   USAGE (Byte Count)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x95, 0x10,                    //   REPORT_COUNT (16)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x91, 0x02,                    //   OUTPUT (Data,Var,Abs)
    0xc0                           // END_COLLECTION
  • I still find the notation hard to grasp, but now it at least works. Thanks for all the help, your HID sample is pure genius!

Glad it works!

@ soren.bendtsen - Wpuld you like to share your code? I’m trying something similar.

Thanks in advance,

@ EricSan500: I think you basicly need to copy paste the code from the Codeshare project, and replace the reportdescriptor array.

Then you’ll be able to send and receive blocks of 16 bytes.

This link is no longer up (8 years later, yes I know, but …) … any idea if we can have a look at the example somewhere else?

I think that it was from WouterH’s example where I got this from: