From e5e9d2ba473deadb7d1b076c043775befb70ae6b Mon Sep 17 00:00:00 2001 From: Dan Halbert Date: Thu, 4 Apr 2019 18:58:35 -0400 Subject: [PATCH] @hathach's changes; check cdc connected during string write --- supervisor/shared/serial.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c index ed210416fe..a61899576f 100644 --- a/supervisor/shared/serial.c +++ b/supervisor/shared/serial.c @@ -52,15 +52,13 @@ bool serial_bytes_available(void) { } void serial_write_substring(const char* text, uint32_t length) { - #if CIRCUITPY_DISPLAYIO +#if CIRCUITPY_DISPLAYIO int errcode; common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode); - #endif - if (!tud_cdc_connected()) { - return; - } +#endif + uint32_t count = 0; - while (count < length) { + while (count < length && tud_cdc_connected()) { count += tud_cdc_write(text + count, length - count); usb_background(); }