summaryrefslogtreecommitdiff
path: root/examples/host
diff options
context:
space:
mode:
authorhathach <[email protected]>2025-06-17 22:16:13 +0700
committerhathach <[email protected]>2025-06-17 22:16:13 +0700
commitd4abf43f226b5594c935c60c38d05a90359763e1 (patch)
treedf9f65775f8f00c926904552670b3b769716b8ae /examples/host
parent4a44dd5c471578ee5b957a75adaf3dbc6a48241a (diff)
add common cdch_process_set_config() to safely complete set_config() when it failed.
driver_process_set_config() also pass drv index with user_data
Diffstat (limited to 'examples/host')
-rw-r--r--examples/host/cdc_msc_hid/src/cdc_app.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/examples/host/cdc_msc_hid/src/cdc_app.c b/examples/host/cdc_msc_hid/src/cdc_app.c
index e68ec383b..6f4433f22 100644
--- a/examples/host/cdc_msc_hid/src/cdc_app.c
+++ b/examples/host/cdc_msc_hid/src/cdc_app.c
@@ -31,8 +31,7 @@ static size_t get_console_inputs(uint8_t* buf, size_t bufsize) {
size_t count = 0;
while (count < bufsize) {
int ch = board_getchar();
- if (ch <= 0) break;
-
+ if (ch <= 0) { break; }
buf[count] = (uint8_t) ch;
count++;
}
@@ -69,10 +68,12 @@ void tuh_cdc_rx_cb(uint8_t idx) {
uint32_t const bufsize = sizeof(buf) - 1;
// forward cdc interfaces -> console
- uint32_t count = tuh_cdc_read(idx, buf, bufsize);
- buf[count] = 0;
-
- printf("%s", (char*) buf);
+ const uint32_t count = tuh_cdc_read(idx, buf, bufsize);
+ if (count) {
+ buf[count] = 0;
+ printf("%s", (char*) buf);
+ fflush(stdout);
+ }
}
// Invoked when a device with CDC interface is mounted