PORTS Forum
Ports and Interfaces => USB => Topic started by: ulao on June 01, 2017, 11:22:12 pm
-
Struggling with something here..
say I have a call like this
usbGetReport(dev, USB_HID_REPORT_TYPE_FEATURE, 17, buffer.bytes, &len)
I could easily add this to my report descriptor and handle the 17 request and return data. I do this an all works out fine. but I really need to send more data then just a report ID. I want to send an extra byte but do not want to do a send report first. Is there a way to add a parameter to my descriptor for this?
0x85, 0x11, // REPORT_ID (17)
0x95, 0x06, // REPORT_COUNT (6)
0x09, 0x00, // USAGE (Undefined)
0xb2, 0x02, 0x01, // FEATURE (Data,Var,Abs,Buf)
Or is it only possible to send a report ID. I know that my wLength is the size and the wValue only has two bytes report + type but there is also a the wIndex. I'm not sure what this is for or if I could even use that. If I did I might be miss using it.
I believe the correct path is to make multiple report IDs but I'd like not to do that as it will increase the maintenance on my descriptor. To put this is a more functional description I want to do this.
if (strcmp(data1, "controller") == 0 ) commandRequest=0x01;
if (strcmp(data1, "pause_state") == 0 ) commandRequest=0x04;
if (strcmp(data1, "model") == 0 ) commandRequest=0x10;
if (strcmp(data1, "modes") == 0 ) commandRequest=0x18;
//but where do I put commandRequest?
usbGetReport(dev, USB_HID_REPORT_TYPE_FEATURE, 17, buffer.bytes, &len)
I did look in to custom types
usbGetReport(dev,commandRequest, 17, buffer.bytes, &len)
but there was not much help on this out there. Again, maybe I'm just looking to cheat the methods here but this would be so much more simpler.
-
In the Get_Report request, wIndex must be set to the interface number the request applies to.
You are correct that the correct path is to use multiple report IDs; that is their purpose.
One way around it would be to define a report that contains all of the possible data in a defined format. Then the host can choose whatever data is of interest from the report. The single report will be longer, of course.
-
haha, very clever ;)