-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/usb/cdc_acm: Change API to report errors #21894
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -24,7 +24,6 @@ | |
| #include <stdio.h> | ||
| #include <sys/types.h> | ||
|
|
||
| #include "log.h" | ||
| #include "isrpipe.h" | ||
| #include "stdio_base.h" | ||
|
|
||
|
|
@@ -36,15 +35,9 @@ static uint8_t _cdc_tx_buf_mem[CONFIG_USBUS_CDC_ACM_STDIO_BUF_SIZE]; | |
|
|
||
| static ssize_t _write(const void* buffer, size_t len) | ||
| { | ||
| const char *start = buffer; | ||
| while (len) { | ||
| size_t n = usbus_cdc_acm_submit(&cdcacm, buffer, len); | ||
| usbus_cdc_acm_flush(&cdcacm); | ||
| /* Use tsrb and flush */ | ||
| buffer = (char *)buffer + n; | ||
| len -= n; | ||
| } | ||
| return (char *)buffer - start; | ||
| ssize_t retval = usbus_cdc_acm_submit(&cdcacm, buffer, len); | ||
| usbus_cdc_acm_flush(&cdcacm); | ||
| return retval; | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Handling the partial transfer in the upper layer won't work when
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can do the looping in If we force all transports to be smart and handle all the special cases and IRQ themselves, we easily run into duplicates code and transport specific behaviour. |
||
| } | ||
|
|
||
| static void _cdc_acm_rx_pipe(usbus_cdcacm_device_t *cdcacm, | ||
|
|
||
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.
Could this become an endless loop with high CPU load if
stdio_writereturns 0 (and does not write anything)? I'd have to look up ifstdio_writecould behave like that.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.
Returning
0is very much valid. If the stdio would have flow control (e.g. UART with flow control or some network protocol), it may not be able to send out any data right now.There is an expectation towards the transport that returning
0is a temporary thing that will sort itself out within reasonable time. The layer above cannot reasonably judge when stuff won't work, so it just has to trust that at some point the transport will either make progress or give up.