are you checking the return value of that function?I am having an issue where if I try and write more than 256 bytes through the USB CDC, it seems to drop all characters after writing 256 bytes. I am connecting to the Pico with a WIndows application running at 115200 baud.
I am simply calling the putchar_raw() function in a loop.
Code:
int putchar_raw(int c) { char cc = (char)c; stdio_put_string(&cc, 1, false, true); return c;}but chasing down the code, it looks like puts_raw(const char *s) is a better option
Code:
static void stdio_usb_out_chars(const char *buf, int length) { static uint64_t last_avail_time; if (!mutex_try_enter_block_until(&stdio_usb_mutex, make_timeout_time_ms(PICO_STDIO_DEADLOCK_TIMEOUT_MS))) { return; } if (stdio_usb_connected()) { for (int i = 0; i < length;) { int n = length - i; int avail = (int) tud_cdc_write_available(); if (n > avail) n = avail; if (n) { int n2 = (int) tud_cdc_write(buf + i, (uint32_t)n); tud_task(); tud_cdc_write_flush(); i += n2; last_avail_time = time_us_64(); } else { tud_task(); tud_cdc_write_flush(); if (!stdio_usb_connected() || (!tud_cdc_write_available() && time_us_64() > last_avail_time + PICO_STDIO_USB_STDOUT_TIMEOUT_US)) { break; } } } } else { // reset our timeout last_avail_time = 0; } mutex_exit(&stdio_usb_mutex);} which will write in blocks of the right size, and block until flushed, so it never drops any characters
Statistics: Posted by cleverca22 — Wed Jan 31, 2024 2:04 am