Skip to content

Commit f603f0c

Browse files
committed
check for USB ready before reading usb_cdc instead of checking for serial connected
1 parent a0b482c commit f603f0c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

shared-module/usb_cdc/Serial.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ size_t common_hal_usb_cdc_serial_read(usb_cdc_serial_obj_t *self, uint8_t *data,
1919
// Read up to len bytes immediately.
2020
// The number of bytes read will not be larger than what is already in the TinyUSB FIFO.
2121
uint32_t total_num_read = 0;
22-
if (tud_cdc_n_connected(self->idx)) {
22+
if (tud_ready()) {
2323
total_num_read = tud_cdc_n_read(self->idx, data, len);
2424
}
2525

@@ -48,7 +48,7 @@ size_t common_hal_usb_cdc_serial_read(usb_cdc_serial_obj_t *self, uint8_t *data,
4848
data += num_read;
4949

5050
// Try to read another batch of bytes.
51-
if (tud_cdc_n_connected(self->idx)) {
51+
if (tud_ready()) {
5252
num_read = tud_cdc_n_read(self->idx, data, len);
5353
}
5454
total_num_read += num_read;

0 commit comments

Comments
 (0)