0
votes

I simply want to send from device to host with two report ID.These reports must have different Report Count(First report id has 4 report count, second report id has 40).This is what I have done so far:

//14    bytes
0x06, 0x00, 0xff,              // USAGE_PAGE (Vendor Defined Page 1)
0x09, 0x01,                    // USAGE (Vendor Usage 1)
0xa1, 0x01,                    // COLLECTION (Application)
                               // -------- common global items ---------
0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
0x75, 0x08,                    //   REPORT_SIZE (8)

// 10 bytes | Input message 1 (sent from device to host)
0x85,  5,            // Global  Report ID (cannot be 0)
0x95, 4,             // Global  Report Count (number of Report Size fields)
0x19, 0x01,                    //   USAGE_MINIMUM (Vendor Usage 1)
0x29, 5,                    //   USAGE_MAXIMUM (Vendor Usage 64)    
0x81, 0x02,          // Main    Input (data, array, absolute)
// 10 bytes | Input message 1 (sent from device to host)
0x85,  6,            // Global  Report ID (cannot be 0)
0x95, 40,             // Global  Report Count (number of Report Size fields)
0x19, 0x01,                    //   USAGE_MINIMUM (Vendor Usage 1)
0x29, 41,                    //   USAGE_MAXIMUM (Vendor Usage 64)   
0x81, 0x02,          // Main    Input (data, array, absolute)
0xC0

But first report id is sending 40 bayt.Where is my mistake?

HID Terminal output:

R 02 0C 16 20 2A 34 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

R 01 0B 15 1F 29 34 3E 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

1
Report descriptor contents is not tied to the report payload your device sends on the interrupt pipe, therefore, are you sure you actually send reports of the relevant size from your code ?Nipo

1 Answers

2
votes

I believe @Nipo has given you the correct answer: the report descriptor indicates what each report should look like, but it is still the responsibility of your code to send reports with the correct length specified.

For report id 5 that would be 5 (1 for the report id + 4 for the payload), and for report it 6 it would be 41 (1 for the report id + 40 for the payload).

BTW, your report descriptor may need a little tweaking. As it stands, it decodes as:

//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------

PROGMEM char usbHidReportDescriptor[] =
{
  0x06, 0x00, 0xFF,            // (GLOBAL) USAGE_PAGE         0xFF00 Vendor-defined 
  0x09, 0x01,                  // (LOCAL)  USAGE              0xFF000001 <-- Warning: Undocumented usage
  0xA1, 0x01,                  // (MAIN)   COLLECTION         0x00000001 Application (Usage=0xFF000001: Page=Vendor-defined, Usage=, Type=)
  0x15, 0x00,                  //   (GLOBAL) LOGICAL_MINIMUM    0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0 <-- Info: Consider replacing 15 00 with 14
  0x26, 0xFF, 0x00,            //   (GLOBAL) LOGICAL_MAXIMUM    0x00FF (255)  
  0x75, 0x08,                  //   (GLOBAL) REPORT_SIZE        0x08 (8) Number of bits per field  
  0x85, 0x05,                  //   (GLOBAL) REPORT_ID          0x05 (5) 
  0x95, 0x04,                  //   (GLOBAL) REPORT_COUNT       0x04 (4) Number of fields  
  0x19, 0x01,                  //   (LOCAL)  USAGE_MINIMUM      0xFF000001 <-- Warning: Undocumented usage
  0x29, 0x05,                  //   (LOCAL)  USAGE_MAXIMUM      0xFF000005 <-- Warning: Undocumented usage
  0x81, 0x02,                  //   (MAIN)   INPUT              0x00000002 (4 fields x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
  0x85, 0x06,                  //   (GLOBAL) REPORT_ID          0x06 (6) 
  0x95, 0x28,                  //   (GLOBAL) REPORT_COUNT       0x28 (40) Number of fields  
  0x19, 0x01,                  //   (LOCAL)  USAGE_MINIMUM      0xFF000001 <-- Warning: Undocumented usage
  0x29, 0x29,                  //   (LOCAL)  USAGE_MAXIMUM      0xFF000029 <-- Warning: Undocumented usage
  0x81, 0x02,                  //   (MAIN)   INPUT              0x00000002 (40 fields x 8 bits) 0=Data 1=Variable 0=Absolute 0=NoWrap 0=Linear 0=PrefState 0=NoNull 0=NonVolatile 0=Bitmap 
  0xC0,                        // (MAIN)   END_COLLECTION     Application
};

//--------------------------------------------------------------------------------
// Vendor-defined inputReport 05 (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x05 (5)
  uint8_t  VEN_VendorDefined0001;                    // Usage 0xFF000001: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0002;                    // Usage 0xFF000002: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0003;                    // Usage 0xFF000003: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0004;                    // Usage 0xFF000004: , Value = 0 to 255
                                                     // Usage 0xFF000005  Value = 0 to 255 <-- Ignored: REPORT_COUNT (4) is too small
} inputReport05_t;


//--------------------------------------------------------------------------------
// Vendor-defined inputReport 06 (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x06 (6)
  uint8_t  VEN_VendorDefined0001;                    // Usage 0xFF000001: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0002;                    // Usage 0xFF000002: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0003;                    // Usage 0xFF000003: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0004;                    // Usage 0xFF000004: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0005;                    // Usage 0xFF000005: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0006;                    // Usage 0xFF000006: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0007;                    // Usage 0xFF000007: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0008;                    // Usage 0xFF000008: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0009;                    // Usage 0xFF000009: , Value = 0 to 255
  uint8_t  VEN_VendorDefined000A;                    // Usage 0xFF00000A: , Value = 0 to 255
  uint8_t  VEN_VendorDefined000B;                    // Usage 0xFF00000B: , Value = 0 to 255
  uint8_t  VEN_VendorDefined000C;                    // Usage 0xFF00000C: , Value = 0 to 255
  uint8_t  VEN_VendorDefined000D;                    // Usage 0xFF00000D: , Value = 0 to 255
  uint8_t  VEN_VendorDefined000E;                    // Usage 0xFF00000E: , Value = 0 to 255
  uint8_t  VEN_VendorDefined000F;                    // Usage 0xFF00000F: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0010;                    // Usage 0xFF000010: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0011;                    // Usage 0xFF000011: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0012;                    // Usage 0xFF000012: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0013;                    // Usage 0xFF000013: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0014;                    // Usage 0xFF000014: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0015;                    // Usage 0xFF000015: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0016;                    // Usage 0xFF000016: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0017;                    // Usage 0xFF000017: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0018;                    // Usage 0xFF000018: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0019;                    // Usage 0xFF000019: , Value = 0 to 255
  uint8_t  VEN_VendorDefined001A;                    // Usage 0xFF00001A: , Value = 0 to 255
  uint8_t  VEN_VendorDefined001B;                    // Usage 0xFF00001B: , Value = 0 to 255
  uint8_t  VEN_VendorDefined001C;                    // Usage 0xFF00001C: , Value = 0 to 255
  uint8_t  VEN_VendorDefined001D;                    // Usage 0xFF00001D: , Value = 0 to 255
  uint8_t  VEN_VendorDefined001E;                    // Usage 0xFF00001E: , Value = 0 to 255
  uint8_t  VEN_VendorDefined001F;                    // Usage 0xFF00001F: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0020;                    // Usage 0xFF000020: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0021;                    // Usage 0xFF000021: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0022;                    // Usage 0xFF000022: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0023;                    // Usage 0xFF000023: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0024;                    // Usage 0xFF000024: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0025;                    // Usage 0xFF000025: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0026;                    // Usage 0xFF000026: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0027;                    // Usage 0xFF000027: , Value = 0 to 255
  uint8_t  VEN_VendorDefined0028;                    // Usage 0xFF000028: , Value = 0 to 255
                                                     // Usage 0xFF000029  Value = 0 to 255 <-- Ignored: REPORT_COUNT (40) is too small
} inputReport06_t;

You may want to try the following instead:

//--------------------------------------------------------------------------------
// Decoded Application Collection
//--------------------------------------------------------------------------------

PROGMEM char usbHidReportDescriptor[] =
{
  0x06, 0x00, 0xFF,            // (GLOBAL) USAGE_PAGE         0xFF00 Vendor-defined 
  0x09, 0x01,                  // (LOCAL)  USAGE              0xFF000001 <-- Warning: Undocumented usage
  0xA1, 0x01,                  // (MAIN)   COLLECTION         0x00000001 Application (Usage=0xFF000001: Page=Vendor-defined, Usage=, Type=)
  0x15, 0x00,                  //   (GLOBAL) LOGICAL_MINIMUM    0x00 (0) <-- Redundant: LOGICAL_MINIMUM is already 0 <-- Info: Consider replacing 15 00 with 14
  0x26, 0xFF, 0x00,            //   (GLOBAL) LOGICAL_MAXIMUM    0x00FF (255)  
  0x75, 0x08,                  //   (GLOBAL) REPORT_SIZE        0x08 (8) Number of bits per field  
  0x85, 0x05,                  //   (GLOBAL) REPORT_ID          0x05 (5) 
  0x95, 0x04,                  //   (GLOBAL) REPORT_COUNT       0x04 (4) Number of fields  
  0x19, 0x01,                  //   (LOCAL)  USAGE_MINIMUM      0xFF000001 <-- Warning: Undocumented usage
  0x29, 0x04,                  //   (LOCAL)  USAGE_MAXIMUM      0xFF000004 <-- Warning: Undocumented usage
  0x81, 0x00,                  //   (MAIN)   INPUT              0x00000000 (4 fields x 8 bits) 0=Data 0=Array 0=Absolute 0=Ignored 0=Ignored 0=PrefState 0=NoNull 
  0x85, 0x06,                  //   (GLOBAL) REPORT_ID          0x06 (6) 
  0x95, 0x28,                  //   (GLOBAL) REPORT_COUNT       0x28 (40) Number of fields  
  0x19, 0x01,                  //   (LOCAL)  USAGE_MINIMUM      0xFF000001 <-- Warning: Undocumented usage
  0x29, 0x28,                  //   (LOCAL)  USAGE_MAXIMUM      0xFF000028 <-- Warning: Undocumented usage
  0x81, 0x00,                  //   (MAIN)   INPUT              0x00000000 (40 fields x 8 bits) 0=Data 0=Array 0=Absolute 0=Ignored 0=Ignored 0=PrefState 0=NoNull 
  0xC0,                        // (MAIN)   END_COLLECTION     Application
};

//--------------------------------------------------------------------------------
// Vendor-defined inputReport 05 (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x05 (5)
  uint8_t  VEN_VendorDefined[4];                     // Value = 0 to 255
} inputReport05_t;


//--------------------------------------------------------------------------------
// Vendor-defined inputReport 06 (Device --> Host)
//--------------------------------------------------------------------------------

typedef struct
{
  uint8_t  reportId;                                 // Report ID = 0x06 (6)
  uint8_t  VEN_VendorDefined[40];                    // Value = 0 to 255
} inputReport06_t;