Page 1 of 1

change hid-data transfer size

Posted: Sat Feb 16, 2013 10:56 am
by filo
I am modifying the hid-data demo to fit my needs.
I want to read only 8 bytes from the device using hidtool.
My descriptor is (I changed only REPORT_COUNT):

Code: Select all

PROGMEM const char usbHidReportDescriptor[] = {    /* USB report descriptor */
    0x06, 0x00, 0xff,              // USAGE_PAGE (Generic Desktop)
    0x09, 0x01,                    // USAGE (Vendor Usage 1)
    0xa1, 0x01,                    // COLLECTION (Application)
    0x15, 0x00,                    //   LOGICAL_MINIMUM (0)
    0x26, 0xff, 0x00,              //   LOGICAL_MAXIMUM (255)
    0x75, 0x08,                    //   REPORT_SIZE (8)
    0x95, 0x08,                    //   REPORT_COUNT (8) // was 128
    0x09, 0x00,                    //   USAGE (Undefined)
    0xb2, 0x02, 0x01,              //   FEATURE (Data,Var,Abs,Buf)
    0xc0                           // END_COLLECTION
};


When using hidtool from the demo I always get 128 bytes:

Code: Select all

$ ./hidtool read
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19
0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19 0x11 0x12 0x13 0x14 0x15 0x16 0x17 0x19

The numbers from 0x11 to 0x19 are hardcoded for testing, I return 8 at usbFunctionRead.
I have not found any hardcoded numbers in hidtool so I suspect that transfer sizes are taken from the operating system.
I always do a clean compile.
How can I read just 8 bytes using hidtool?

Re: change hid-data transfer size

Posted: Wed Feb 27, 2013 9:54 pm
by barney
I took a look at it myself and unfortunately can't see any other place to change it. Sorry I couldn't help but at least you know someone is also blind to what needs to be changed. I was told somewhere else that the data packets in this type of HID transfer are 64 bytes. So maybe you are looking for some reference to x 2 or some kind of loop that goes twice to get 2 64 packets thus 128. Good luck.

Re: change hid-data transfer size

Posted: Wed Feb 27, 2013 9:58 pm
by barney
Oh also btw, the hidtool is hardcoded as well at 128 bytes. So you may want to look at that C code, because even if you were successful and only storing and sending back less than 128 bytes to the hidtool, it will "pad" it out anyway. Also keep in mind the smallest amount you can send and/or receive is probably 64 based on what I read somewhere.

Re: change hid-data transfer size

Posted: Thu Feb 28, 2013 11:36 pm
by xiangrui
barney's reply about the hard-coded 128 in hidtool is right. You will need to change it 8 for the host side code, and re-compile it .
However, the fixed 64-byte is not true. It can be any number below a certain limit, as long as it is defined in the descriptor and treated correctly at both host and device sides.