New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
stmhal: implement HID OUT endpoint (USB receive) #2448
Conversation
Implements #1217 |
To test:
import pyb
pyb.usb_mode('VCP+HID')
import pyb
h = pyb.USB_HID()
h.recv(4)
import hid
h = hid.device()
h.open(0xf055, 0x9801)
h.write([0] + range(4))
(Also works with packet size of 64, but one needs to specify custom hid descriptor in |
} | ||
|
||
// Copy bytes from device to user buffer | ||
memcpy(buf, buffer[current_read_buffer], last_read_len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The len argument to this function is not used at all, in particular this line could overrun buf if buf is too short.
@@ -0,0 +1,36 @@ | |||
/* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is such a simple file. The original copyright is not needed.
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please keep this blank line.
@@ -0,0 +1,109 @@ | |||
/* | |||
* TODO: this header is even more lies now |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where did the bulk of this file come from, an ST example?
Pushed a new commit fixing the issues. |
I tested it and there was a bug: needed to adjust size of MAX_TEMPLATE_CONFIG_DESC_SIZE from 100 to 107. Otherwise it works well. Thanks for the submission, it's a very cool feature to have! During the merge I squashed some commits in various ways to try and make the history a bit cleaner. See 99d62c4 for last of the 4 commits. |
Thanks! |
Add PacketBuffer and MTU negotiation support.
This changeset implements HID OUT endpoint, which allows receiving data on the uPy side of things.
Original commits from https://github.com/philandstuff/micropython/tree/usb-hid-out-endpoint, added few more fixes by me.