@hathach's changes; check cdc connected during string write

This commit is contained in:
Dan Halbert 2019-04-04 18:58:35 -04:00
parent 9d43a25d6e
commit e5e9d2ba47

View File

@ -52,15 +52,13 @@ bool serial_bytes_available(void) {
} }
void serial_write_substring(const char* text, uint32_t length) { void serial_write_substring(const char* text, uint32_t length) {
#if CIRCUITPY_DISPLAYIO #if CIRCUITPY_DISPLAYIO
int errcode; int errcode;
common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode); common_hal_terminalio_terminal_write(&supervisor_terminal, (const uint8_t*) text, length, &errcode);
#endif #endif
if (!tud_cdc_connected()) {
return;
}
uint32_t count = 0; uint32_t count = 0;
while (count < length) { while (count < length && tud_cdc_connected()) {
count += tud_cdc_write(text + count, length - count); count += tud_cdc_write(text + count, length - count);
usb_background(); usb_background();
} }