Skip to content

Commit dc77f31

Browse files
committed
serial_bytes_available: don't double-count bytes on usb cdc
In 9.0.x, serial_bytes_available returned a bool and tud_cdc_available was harmlessly checked twice for any characters. When the routine was changed to return an int, the double checking led to over-reporting the number of characters available. In code that would attempt to read this many bytes from sys.stdin, this made the read call block since only 1 byte was actually available. This behavior came up in the discussion of #9393. I don't mark this bug as closing that one, because that issue seems to be reporting multiple things that this change would not address, such as delays in `sys.stdout.write()` or problems seen while using webserial.
1 parent 06d6535 commit dc77f31

File tree

1 file changed

+0
-4
lines changed

1 file changed

+0
-4
lines changed

supervisor/shared/serial.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -309,10 +309,6 @@ uint32_t serial_bytes_available(void) {
309309
}
310310
#endif
311311

312-
#if CIRCUITPY_USB_DEVICE
313-
count += tud_cdc_available();
314-
#endif
315-
316312
// Board-specific serial input.
317313
count += board_serial_bytes_available();
318314

0 commit comments

Comments
 (0)