Author Topic: USB HID Device Read/Write Huge data  (Read 6743 times)

gi

  • Member
  • ***
  • Posts: 27
USB HID Device Read/Write Huge data
« on: August 19, 2014, 06:05:02 am »
Hi Jan,

May I ask if what is the best way of reading and writing data into USB HID Device?
I usually done it by using report descriptor (feature and input report) with small data only (8 bytes max), but now I have to deal with 250+ bytes of data. The data looks something like below:
The data is read only once and written only once after boot up of my uC before entering infinite loop. I'm using 8051 from Silabs.
Code: [Select]
#define SIZE 24
typedef struct
{
    BYTE Detail1[SIZE];
    BYTE Detail2[SIZE];
    BYTE Detail3[SIZE];
    BYTE Detail4[SIZE];
    BYTE Detail5[SIZE];
    BYTE Detail6[SIZE];
    BYTE Detail7[SIZE];
    BYTE Detail8[SIZE];
    BYTE Detail9[SIZE];
    BYTE Detail10[SIZE];
    BYTE Detail11[8];
    BYTE Detail12[8];
}

Hope to hear from you soon.

Thanks
gi

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB HID Device Read/Write Huge data
« Reply #1 on: August 19, 2014, 02:46:36 pm »
You can do this in a HID report. If the host reads it only once, I would use a Feature report. Be sure the firmware can read reports whose data requires multiple transactions.

gi

  • Member
  • ***
  • Posts: 27
Re: USB HID Device Read/Write Huge data
« Reply #2 on: August 19, 2014, 11:40:48 pm »
Thank you Jan.

gi

  • Member
  • ***
  • Posts: 27
Re: USB HID Device Read/Write Huge data
« Reply #3 on: September 01, 2014, 02:50:40 am »
Hi Jan,

I was wondering if possible to structure the report descriptor to have individual usages that has 24bytes in size per usage.
Looking into USB HID 1.11 spec, the Logical Maximum can only reach 0x7fffff (0010 01 nn p.45) if my understanding is correct.
I don't think this report will work.
Code: [Select]
0x85, DETAILS_FEAT_REP_ID,
0x15, 0,         //  LOGICAL_MINIMUM (0)
0x27, 0xff, 0xff, 0x7f,    //  LOGICAL_MAXIMUM (7fffff) ???
0x75, 0x18,    //  REPORT_SIZE(24) ???
0x95, 0x0c,         //  REPORT_COUNT(12)
0x09, USAGE_DETAIL1, // USAGE 0xYX
0x09, USAGE_DETAIL2, // USAGE 0xYX
0x09, USAGE_DETAIL3, // USAGE 0xYX
...
0x09, USAGE_DETAIL12, // USAGE 0xYX
0xB1, 2,

I modified the above report with only 1 usage, below.
Code: [Select]
0x85, DETAILS_FEAT_REP_ID,
0x15, 0,         //  LOGICAL_MINIMUM (0)
0x26, 0xff, 0x00,     //  LOGICAL_MAXIMUM (255)
0x75, 0x08,    //  REPORT_SIZE(8)
0x96, 0x00, 0x01        //  REPORT_COUNT(256)
0x09, USAGE_DETAILS, // USAGE 0xYX
0xB1, 2,                //  FEATURE(Data,Var,Abs)

My question, will my modified report works with the huge data above?

Thanks
Gi

Jan Axelson

  • Administrator
  • Frequent Contributor
  • *****
  • Posts: 3033
    • Lakeview Research
Re: USB HID Device Read/Write Huge data
« Reply #4 on: September 01, 2014, 05:09:20 pm »
Yes, if by "huge data" you mean really large and precise individual values, you may need to break them up to transmit.

gi

  • Member
  • ***
  • Posts: 27
Re: USB HID Device Read/Write Huge data
« Reply #5 on: September 02, 2014, 04:00:25 am »
Great! Thank you Jan.

So, my modified report no longer require a padding, right?

Thanks again for the help.
Gi