@@ -295,70 +295,45 @@ char serial_read(void) {
295
295
}
296
296
297
297
uint32_t serial_bytes_available (void ) {
298
+ // There may be multiple serial input channels, so sum the count from all.
299
+ uint32_t count = 0 ;
300
+
298
301
#if CIRCUITPY_USB_VENDOR
299
302
if (tud_vendor_connected ()) {
300
- uint32_t count = tud_vendor_available ();
301
- if (count > 0 ) {
302
- return count ;
303
- }
303
+ count += tud_vendor_available ();
304
304
}
305
305
#endif
306
306
307
307
#if CIRCUITPY_CONSOLE_UART
308
- {
309
- uint32_t count = common_hal_busio_uart_rx_characters_available (& console_uart );
310
- if (count > 0 ) {
311
- return count ;
312
- }
313
- }
308
+ count += common_hal_busio_uart_rx_characters_available (& console_uart );
314
309
#endif
315
310
316
311
#if CIRCUITPY_SERIAL_BLE
317
- {
318
- uint32_t count = ble_serial_available ();
319
- if (count > 0 ) {
320
- return count ;
321
- }
322
- }
312
+ count += ble_serial_available ();
323
313
#endif
324
314
325
315
#if CIRCUITPY_WEB_WORKFLOW
326
- {
327
- uint32_t count = websocket_available ();
328
- if (count > 0 ) {
329
- return count ;
330
- }
331
- }
316
+ count += websocket_available ();
332
317
#endif
333
318
334
319
#if CIRCUITPY_USB_KEYBOARD_WORKFLOW
335
- {
336
- uint32_t count = usb_keyboard_chars_available ();
337
- if (count > 0 ) {
338
- return count ;
339
- }
340
- }
320
+ count += usb_keyboard_chars_available ();
341
321
#endif
342
322
343
323
#if CIRCUITPY_USB_CDC
344
324
if (usb_cdc_console_enabled ()) {
345
- uint32_t count = tud_cdc_available ();
346
- if (count > 0 ) {
347
- return count ;
348
- }
325
+ count += tud_cdc_available ();
349
326
}
350
327
#endif
351
328
352
329
#if CIRCUITPY_USB
353
- {
354
- uint32_t count = tud_cdc_available ();
355
- if (count > 0 ) {
356
- return count ;
357
- }
358
- }
330
+ count += tud_cdc_available ();
359
331
#endif
360
332
361
- return port_serial_bytes_available ();
333
+ // Port-specific serial input.
334
+ count += port_serial_bytes_available ();
335
+
336
+ return count ;
362
337
}
363
338
364
339
void serial_write_substring (const char * text , uint32_t length ) {
0 commit comments