From d80c2187442c8d435c0186660e1786abfd4cd9e8 Mon Sep 17 00:00:00 2001 From: Ben Lye Date: Thu, 5 Sep 2019 07:33:01 +0100 Subject: [PATCH] Add timeout to serial debug (#253) * Wait 30s for serial debug instead of waiting forever * Delay of 50ms to allow FTDI debugger to connect at startup --- Multiprotocol/Multiprotocol.ino | 20 +++++++++++++++++++- docs/Troubleshooting.md | 1 + 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/Multiprotocol/Multiprotocol.ino b/Multiprotocol/Multiprotocol.ino index ee98be1..58ee856 100644 --- a/Multiprotocol/Multiprotocol.ino +++ b/Multiprotocol/Multiprotocol.ino @@ -224,7 +224,25 @@ void setup() // Setup diagnostic uart before anything else #ifdef DEBUG_SERIAL Serial.begin(115200,SERIAL_8N1); - while (!Serial); // Wait for ever for the serial port to connect... + + // Wait up to 30s for a serial connection; double-blink the LED while we wait + unsigned long currMillis = millis(); + unsigned long initMillis = currMillis; + pinMode(LED_pin,OUTPUT); + LED_off; + while (!Serial && (currMillis - initMillis) <= 30000) { + LED_on; + delay(100); + LED_off; + delay(100); + LED_on; + delay(100); + LED_off; + delay(500); + currMillis = millis(); + } + + delay(50); // Brief delay for FTDI debugging debugln("Multiprotocol version: %d.%d.%d.%d", VERSION_MAJOR, VERSION_MINOR, VERSION_REVISION, VERSION_PATCH_LEVEL); #endif diff --git a/docs/Troubleshooting.md b/docs/Troubleshooting.md index 5976b99..e39cc49 100644 --- a/docs/Troubleshooting.md +++ b/docs/Troubleshooting.md @@ -15,6 +15,7 @@ - **_Fast blink(on=0.1s,off=0.1s)_**: bind in progress - **_Slow blink(on=0.5s,off=0.5s)_**: serial has been selected but no valid signal is being seen on the RX pin. - **_Slower blink(on=1s,off=1s)_**: PPM has been selected but no valid signal is being seen on the PPM pin. +- **_Fast double blink(on=0.1s,off=0.1s,on=0.1s,off=0.5s)_**: serial debugging is enabled and is waiting for a serial connection - **_On_**: Module is in normal operation mode (transmitting control signals). ## Protocol selection