Is it possible to include a length parameter for the ReceiveFeatureReport function?
In our web application, we need to reduce the packet size to increase the update frequency.
When using the Logic Analyzer to observe the packet, I noticed that ReceiveFeatureReport always returns the full length as defined in the descriptor. However, with HIDIOCGFEATURE(len) in Linux or HidD_GetFeature in Windows, only a specific length will be obtained.
How can we do it using WebHID?
Interesting, I didn't realize you could request a shorter report to improve update frequency. Currently, WebHID uses the size of the report defined in the report descriptor and doesn't provide a way to specify the report size.
We could support this by adding an (optional) options parameter to receiveFeatureReport:
device.receiveFeatureReport(reportId, {overrideReportLength: 8});
I'm not sure what this should do if the requested report length is longer than the length defined in the report descriptor. I think for most devices this will cause a device error, but perhaps there are devices where this is necessary.
Thanks! I am really looking forward for this feature.
@nondebug @beaufortfrancois @marcoscaceres
Really need this feature. I have a device that has multiple Feature Reports with different Report IDs, and each Report ID has a different length. However, I've found that in Chromium, it requests all Report IDs using the longest length.
Here is the HID Report Descriptor for my device:
const uint8_t USBD_VendorDefinedHIDReportDescriptor[] =
{
0x06, 0x01, 0xFF, // Usage Page (Vendor-Defined 2)
0x09, 0x01, // Usage (Vendor-Defined 1)
0xA1, 0x01, // Collection (Application)
0x15, 0x00, // Logical Minimum (0)
0x26, 0xFF, 0x00, // Logical Maximum (255)
0x75, 0x08, // Report Size (8)
0x85, 0x01, // Report ID (1)
0x95, 0x40, // Report Count (64)
0x09, 0x01, // Usage (Vendor-Defined 1)
0x81, 0x02, // Input (Data,Var,Abs,NWrp,Lin,Pref,NNul,Bit)
0x85, 0x02, // Report ID (2)
0x95, 0x40, // Report Count (64)
0x09, 0x01, // Usage (Vendor-Defined 1)
0x91, 0x02, // Output (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0x85, 0x03, // Report ID (3)
0x95, 0x40, // Report Count (64)
0x09, 0x01, // Usage (Vendor-Defined 1)
0xB1, 0x02, // Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0x85, 0x05, // Report ID (5)
0x95, 0x08, // Report Count (8)
0x09, 0x01, // Usage (Vendor-Defined 1)
0xB1, 0x02, // Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0x85, 0x07, // Report ID (7)
0x95, 0x08, // Report Count (8)
0x09, 0x01, // Usage (Vendor-Defined 1)
0xB1, 0x02, // Feature (Data,Var,Abs,NWrp,Lin,Pref,NNul,NVol,Bit)
0xC0, // End Collection
};
When using the receiveFeatureReport function in Chorme to request a Feature Report with report id 0x05, it requests 65 bytes instead of 9 bytes !