Skip to content

Windows: hid_write returns larger number of bytes then the size of the report #255

Answered by Youw
gfisys asked this question in Q&A
Discussion options

You must be logged in to vote

I'm assuming you're using latest 0.10.1 version of hidapi.

Can you try the very same code on Linux/macOS?

Your expectations are natural from HID point of view, but I'm afraid this is likely is a Windows backend limitation. And not because of the hidapi implementation on Windows, but because of the WinAPI itself. hidapi is jut strying to be a thin proxy between a user and underlying OS API, when that is possible.
WinAPI requires that the buffer passed to WriteFile (underlying implementation of hid_write) is large-enugh to hold the largest report (the size of larger report is reported by WinAPI as well, and used by hidapi). And, apparently, it doesn't return how many actual bytes are sent t…

Replies: 2 comments 1 reply

Comment options

You must be logged in to vote
1 reply
@gfisys
Comment options

Answer selected by mcuee
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants