First output report received by USBHID instance is corrupt

01 Apr 2019

mbed-os-5.12.0 USBHID

When the first output report is received, the data is missing the first 4 bytes. If I access the data the trailing data contains 4 random bytes. Looking at USBHID::callback_set_configuration it makes a call to read_start, which activates the endpoint to receive the first output report: read_start(_int_out, (uint8_t *)&_output_report, MAX_HID_REPORT_SIZE);

I think this is incorrect. It's passing the whole structure rather than the data buffer.

It should be the same as USBHID::read_nb

that is the call to read_start should be: read_start(_int_out, _output_report.data , MAX_HID_REPORT_SIZE);

With this change, the first output report received is correctly formed.