-
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 2 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 |
|---|---|---|
|
|
@@ -180,10 +180,19 @@ static int picolibc_stdout_queued; | |
|
|
||
| static void _picolibc_flush(void) | ||
| { | ||
| if (picolibc_stdout_queued) { | ||
| stdio_write(picolibc_stdout, picolibc_stdout_queued); | ||
| picolibc_stdout_queued = 0; | ||
| char *pos = picolibc_stdout; | ||
| char *end = pos + picolibc_stdout_queued; | ||
| while (pos < end) { | ||
| size_t left = (size_t)end - (size_t)pos; | ||
| ssize_t written = stdio_write(pos, left); | ||
| if (written < 0) { | ||
| /* failed to flush, drop data */ | ||
| break; | ||
| } | ||
| pos += written; | ||
|
Comment on lines
+185
to
+192
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. Could this become an endless loop with high CPU load if
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. Returning There is an expectation towards the transport that returning |
||
| } | ||
|
|
||
| picolibc_stdout_queued = 0; | ||
| } | ||
|
|
||
| static int picolibc_put(char c, FILE *file) | ||
|
|
||
| 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, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.