[Solved] HID doesn't work if reportbuffer exceeds 8 bytes

General discussions about V-USB, our firmware-only implementation of a low speed USB device on Atmel's AVR microcontrollers
Post Reply
teschi
Posts: 2
Joined: Sun Sep 13, 2009 9:58 pm

[Solved] HID doesn't work if reportbuffer exceeds 8 bytes

Post by teschi » Sun Sep 13, 2009 10:49 pm

Hi there,

I currently have problems with my attempt to build a custom game controller.
I'm using an Atmega16 at 12MHz and vusb-20090822.
I started with the hid-mouse example, changed the descriptors to be a gamepad, and everything worked fine as long as the descriptor defined a report buffer of 8 bytes.


But when I add another axis (or another 8 buttons) and therefore define a report buffer of 9 bytes no data is transferred anymore.
The device is recognized fine by windows, but windows doesnt react on any controller movements.

I ran SnoopyPro on both report-buffer-lengths.
- the 8-byte version shows a series of interrupt-transfers
- the 9-byte version shows mainly empty interrupt-transfers and a lot of ABORT_PIPEs and RESET_PIPEs

Does someone know if this is a given limit of the V-USB, a given limit of my configuration (atmega16+12MHz) or if i just did something wrong.

Thanks a lot for any hints
Teschi

------------------------

hmmm... can't add attachments here, but it's very easy to reproduce using the hid-mouse example, by:
- changing the VID/PID so it doesn't reflect a mouse
- defining the reportBuffer to be an uchar[8]
- defining a HID-Descriptor for 7 axis an 8 buttons

Code: Select all

PROGMEM char usbHidReportDescriptor[53]  = {
    0x05, 0x01,                    // USAGE_PAGE (Generic Desktop)
    0x09, 0x04,                    // USAGE (Joystick)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x09, 0x01,                    //   USAGE (Pointer)
    0xa1, 0x00,                    //   COLLECTION (Physical)
    0x09, 0x30,                    //    X
    0x09, 0x31,                    //    Y
    0x09, 0x32,                  //    Z
    0x09, 0x33,                  //    Rx
    0x09, 0x34,                  //    Ry
    0x09, 0x35,                  //    Rz
    0x09, 0x36,                  //    Slider
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x07,                    //   REPORT_COUNT (7)
    0x81, 0x02,                    //   INPUT (Data,Var,Abs)
    0xc0,                          // END_COLLECTION
    0x05, 0x09,                    // USAGE_PAGE (Button)
    0x19, 0x01,                    //   USAGE_MINIMUM (Button 1)
    0x29, 0x08,                    //   USAGE_MAXIMUM (Button 8)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x25, 0x01,                    //   LOGICAL_MAXIMUM (1)
    0x75, 0x01,                    // REPORT_SIZE (1)
    0x95, 0x08,                    // REPORT_COUNT (8)
    0x81, 0x42,                    // INPUT (Data,Var,Abs, null state)
    0xc0                           // END_COLLECTION
};


and changing advanceCircleByFixedAngle to change the array, e.g. (reportBuffer[0] = 0x80 + (d*16);)

This works fine.

But if you change the HID-Descriptor to define 16-buttons instead of 8, and increasing the reportBuffer to 9 bytes:

interrupt transfer fails.
Last edited by teschi on Mon Sep 14, 2009 1:20 pm, edited 1 time in total.

Grendel
Rank 4
Rank 4
Posts: 167
Joined: Sat Dec 16, 2006 9:53 pm
Location: Oregon, USA
Contact:

Re: HID doesn't work if reportbuffer exceeds 8 bytes

Post by Grendel » Mon Sep 14, 2009 2:51 am

Welp, from usbdrv.h:

Code: Select all

USB_PUBLIC void usbSetInterrupt(uchar *data, uchar len);
/* This function sets the message which will be sent during the next interrupt
 * IN transfer. The message is copied to an internal buffer and must not exceed
 * a length of 8 bytes. The message may be 0 bytes long just to indicate the
 * interrupt status to the host.
 * If you need to transfer more bytes, use a control read after the interrupt.
 */

Or define multiple reports in the report descriptor (ie. collect the buttons in one report, the axis in a 2nd) and send them alternating. You will lose one byte per report for the report id tho.

teschi
Posts: 2
Joined: Sun Sep 13, 2009 9:58 pm

[Solved] HID doesn't work if reportbuffer exceeds 8 bytes

Post by teschi » Mon Sep 14, 2009 1:19 pm

Thanks very much!

Sorry for the RTFM-Question (probably I shouldn't write code that late).
And thanks for the hint about the Report_IDs, that's exactly what I need.

Post Reply