Fix unintended control transfers in webserial example.#645
Fix unintended control transfers in webserial example.#645hathach merged 2 commits intohathach:masterfrom
Conversation
hathach
left a comment
There was a problem hiding this comment.
Thank you very much for the PR, this is spot-on. I am too lazy to check for the request vendor type. There is only a couple of style feedback
- Please add
default: return false;to the switch(bRequest) - I am not against openning
{in the same line with new code, however, you should not reformat the existing style.
| return tud_control_xfer(rhport, request, (void*) desc_ms_os_20, total_len); | ||
| } else { | ||
| return false; | ||
| } |
There was a problem hiding this comment.
all switch should have default, please add one with return false;
- every switch must have a default - revert formatting of unchanged lines
|
Thank you for the kind comments! It's a wonderful codebase, I had a great time this weekend getting to know it. I hope I can be of assistance in the future as well. I've uploaded a new commit addressing your comments. |
hathach
left a comment
There was a problem hiding this comment.
Thank you very much for your PR. I am appreciate that you have spent time to troubleshoot this issue.
Thank you very much for willing to help, I am looking forward to your future PRs. Feel free to submit any issues/pr/discussion. PS: see also #646, while this PR fix the behavior of vendor app, 646 allow usbd to detect tud_control_status() is called from vendor and skip duplication action. |
As discussed in #609,
The problem is that when receiving a "standard" CLEAR_FEATURE request, usbd.c calls into the class driver:
tinyusb/src/device/usbd.c
Line 757 in a96ee8f
Unfortunately the "class driver", i.e. the webusb example's main function, intereprets this as a "class" request with bRequest==1 (i.e. VENDOR_REQUEST_WEBUSB), rather than as a "endpoint" request with bRequest==CLEAR_FEATURE,
tinyusb/examples/device/webusb_serial/src/main.c
Line 156 in a96ee8f
To fix this, the class driver should ignore requests that are not clearly meant for it.