Author Topic: New to LUFA need some usb help.  (Read 4482 times)

ulao

  • Frequent Contributor
  • ****
  • Posts: 172
New to LUFA need some usb help.
« on: December 13, 2018, 08:34:12 pm »
I have set up a USB device with the typical gamepad descriptors but I seem to have a payload mismatch of some sort here. I keep getting a usb babble errors. From what I can tell that meansI sent too much data.  My report descriptor is 8 bytes but if I send 8 bytes it does not enumerate. I must send 9 to get an enumeration but with 9 I get the babble error.

This is how LUFA sends data.
      Endpoint_Write_Stream_LE(&reportBuffer, sizeof(reportBuffer), NULL);

I must set my size to 9 to get the usb to enumerate
               unsigned char reportBuffer[9];


This is my descriptor
Code: [Select]
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Gamepad)
0xa1, 0x01, // COLLECTION (Application)
0x15, 0x00, //   LOGICAL_MINIMUM (0)
0x25, 0x01, //   LOGICAL_MAXIMUM (1)
0x35, 0x00, //   PHYSICAL_MINIMUM (0)
0x45, 0x01, //   PHYSICAL_MAXIMUM (1)
0x75, 0x01, //   REPORT_SIZE (1)
0x95, 0x0e, //   REPORT_COUNT (14)
0x05, 0x09, //   USAGE_PAGE (Button)
0x19, 0x01, //   USAGE_MINIMUM (Button 1)
0x29, 0x0e, //   USAGE_MAXIMUM (Button 14)
0x81, 0x02, //   INPUT (Data,Var,Abs)
0x95, 0x02, //   REPORT_COUNT (2)
0x81, 0x01, //   INPUT (Cnst,Ary,Abs)
0x05, 0x01, //   USAGE_PAGE (Generic Desktop)
0x25, 0x07, //   LOGICAL_MAXIMUM (7)
0x46, 0x3b, 0x01, //   PHYSICAL_MAXIMUM (315)
0x75, 0x04, //   REPORT_SIZE (4)
0x95, 0x01, //   REPORT_COUNT (1)
0x65, 0x14, //   UNIT (Eng Rot:Angular Pos)
0x09, 0x39, //   USAGE (Hat switch)
0x81, 0x42, //   INPUT (Data,Var,Abs,Null)
0x65, 0x00, //   UNIT (None)
0x95, 0x01, //   REPORT_COUNT (1)
0x81, 0x01, //   INPUT (Cnst,Ary,Abs)
0x26, 0xff, 0x00, //   LOGICAL_MAXIMUM (255)
0x46, 0xff, 0x00, //   PHYSICAL_MAXIMUM (255)
0x09, 0x30, //   USAGE (X)
0x09, 0x31, //   USAGE (Y)
0x09, 0x32, //   USAGE (Z)
0x09, 0x35, //   USAGE (Rz)
0x75, 0x08, //   REPORT_SIZE (8)
0x95, 0x04, //   REPORT_COUNT (4)
0x81, 0x02, //   INPUT (Data,Var,Abs)
0x75, 0x08, //   REPORT_SIZE (8)
0x95, 0x01, //   REPORT_COUNT (1)
0x81, 0x01, //   INPUT (Cnst,Ary,Abs)
0xc0, // END_COLLECTION



If I try top capture the error on enumeration I get pnp device state failed.



I can provide more data if needed.

« Last Edit: December 13, 2018, 08:42:22 pm by ulao »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: New to LUFA need some usb help.
« Reply #1 on: December 13, 2018, 08:56:15 pm »
Agree that your report size is 8 bytes/64 bits. You're not using report IDs so no need to include that in the reportBuffer.

If you have any related example code, I would suggest looking at that for clues.

ulao

  • Frequent Contributor
  • ****
  • Posts: 172
Re: New to LUFA need some usb help.
« Reply #2 on: December 14, 2018, 07:22:12 am »
Actually that is the issue, this was example (working ) code. All I did was put in the new descriptor. The old descriptor was 19 bytes. So all I did was changed the array from 19 to 8. I also made a change to the vid/pid.

This was the old descriptor.
Code: [Select]
0x05, 0x01, // USAGE_PAGE (Generic Desktop)
0x09, 0x05, // USAGE (Gamepad)
0xa1, 0x01, // COLLECTION (Application)
0x15, 0x00, //   LOGICAL_MINIMUM (0)
0x25, 0x01, //   LOGICAL_MAXIMUM (1)
0x35, 0x00, //   PHYSICAL_MINIMUM (0)
0x45, 0x01, //   PHYSICAL_MAXIMUM (1)
0x75, 0x01, //   REPORT_SIZE (1)
0x95, 0x0d, //   REPORT_COUNT (13)
0x05, 0x09, //   USAGE_PAGE (Button)
0x19, 0x01, //   USAGE_MINIMUM (Button 1)
0x29, 0x0d, //   USAGE_MAXIMUM (Button 13)
0x81, 0x02, //   INPUT (Data,Var,Abs)
0x95, 0x03, //   REPORT_COUNT (3)
0x81, 0x01, //   INPUT (Cnst,Ary,Abs)
0x05, 0x01, //   USAGE_PAGE (Generic Desktop)
0x25, 0x07, //   LOGICAL_MAXIMUM (7)
0x46, 0x3b, 0x01, //   PHYSICAL_MAXIMUM (315)
0x75, 0x04, //   REPORT_SIZE (4)
0x95, 0x01, //   REPORT_COUNT (1)
0x65, 0x14, //   UNIT (Eng Rot:Angular Pos)
0x09, 0x39, //   USAGE (Hat switch)
0x81, 0x42, //   INPUT (Data,Var,Abs,Null)
0x65, 0x00, //   UNIT (None)
0x95, 0x01, //   REPORT_COUNT (1)
0x81, 0x01, //   INPUT (Cnst,Ary,Abs)
0x26, 0xff, 0x00, //   LOGICAL_MAXIMUM (255)
0x46, 0xff, 0x00, //   PHYSICAL_MAXIMUM (255)
0x09, 0x30, //   USAGE (X)
0x09, 0x31, //   USAGE (Y)
0x09, 0x32, //   USAGE (Z)
0x09, 0x35, //   USAGE (Rz)
0x75, 0x08, //   REPORT_SIZE (8)
0x95, 0x04, //   REPORT_COUNT (4)
0x81, 0x02, //   INPUT (Data,Var,Abs)
0x06, 0x00, 0xff, //   USAGE_PAGE (Vendor Specific)
0x09, 0x20, //   Unknown
0x09, 0x21, //   Unknown
0x09, 0x22, //   Unknown
0x09, 0x23, //   Unknown
0x09, 0x24, //   Unknown
0x09, 0x25, //   Unknown
0x09, 0x26, //   Unknown
0x09, 0x27, //   Unknown
0x09, 0x28, //   Unknown
0x09, 0x29, //   Unknown
0x09, 0x2a, //   Unknown
0x09, 0x2b, //   Unknown
0x95, 0x0c, //   REPORT_COUNT (12)
0x81, 0x02, //   INPUT (Data,Var,Abs)
0x0a, 0x21, 0x26, //   Unknown
0x95, 0x08, //   REPORT_COUNT (8)
0xb1, 0x02, //   FEATURE (Data,Var,Abs)
0xc0, // END_COLLECTION
« Last Edit: December 14, 2018, 07:24:26 am by ulao »

ulao

  • Frequent Contributor
  • ****
  • Posts: 172
Re: New to LUFA need some usb help.
« Reply #3 on: December 14, 2018, 04:57:41 pm »
I added a new pipe (out) and the issue went away.
« Last Edit: December 14, 2018, 09:44:48 pm by ulao »

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: New to LUFA need some usb help.
« Reply #4 on: December 15, 2018, 11:35:19 am »
Thanks for reporting back!