You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When working with HID reports, there’s a common pattern that can be tricky when sending and receiving data.
Key points:
HID reports always start with a ReportID as the first byte. This identifies the type of report.
When receiving a report via the callback, the ReportID is accessible as report[0]. This means your input report struct can safely include the ReportID as its first field.
However, when sending a report using tuh_hid_report_send, you also pass the ReportID as an argument. Internally, the function actually expects your report to be the output report without the first ReportID byte, and does:
This creates confusion, as one expects the same way to recieve and send reports.
To keep things consistent and avoid confusion, both input and output report structs should include the ReportID as their first field. This makes the code more predictable and easier to debug.
(kindly regards someone who just used 5 hours debugging code and had one byte shifted since the report included reportid twice and just figured out why)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
When working with HID reports, there’s a common pattern that can be tricky when sending and receiving data.
Key points:
This creates confusion, as one expects the same way to recieve and send reports.
To keep things consistent and avoid confusion, both input and output report structs should include the ReportID as their first field. This makes the code more predictable and easier to debug.
(kindly regards someone who just used 5 hours debugging code and had one byte shifted since the report included reportid twice and just figured out why)
Beta Was this translation helpful? Give feedback.
All reactions