summaryrefslogtreecommitdiff
path: root/supervisor/shared/serial.c
diff options
context:
space:
mode:
authorJeff Epler <jeff@adafruit.com>2020-10-31 09:35:48 -0500
committerGitHub <noreply@github.com>2020-10-31 09:35:48 -0500
commitbbed1b03546802c03f3f20cdcb36d23cd54d047b (patch)
tree336f5e1e30ec3ca7edc10e473992b6e0b10a59f1 /supervisor/shared/serial.c
parentaba4447a22d8d873d2a3097d7eba12494242ca0d (diff)
parent345d84ffde527b16f50c203f7b6a718886be34f6 (diff)
Merge pull request #3624 from dhalbert/usb-serial-detect-2
improve USB CDC disconnect/reconnect checking
Diffstat (limited to 'supervisor/shared/serial.c')
-rw-r--r--supervisor/shared/serial.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/supervisor/shared/serial.c b/supervisor/shared/serial.c
index 91e90671d..7383cc228 100644
--- a/supervisor/shared/serial.c
+++ b/supervisor/shared/serial.c
@@ -47,8 +47,6 @@ busio_uart_obj_t debug_uart;
byte buf_array[64];
#endif
-volatile bool _serial_connected;
-
void serial_early_init(void) {
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
debug_uart.base.type = &busio_uart_type;
@@ -71,7 +69,9 @@ bool serial_connected(void) {
#if defined(DEBUG_UART_TX) && defined(DEBUG_UART_RX)
return true;
#else
- return _serial_connected;
+ // True if DTR is asserted, and the USB connection is up.
+ // tud_cdc_get_line_state(): bit 0 is DTR, bit 1 is RTS
+ return (tud_cdc_get_line_state() & 1) && tud_ready();
#endif
}