Wait at most 100ms for Serial in init_serial on 2CAN so it will boot without USB

This commit is contained in:
Jonny 2025-09-12 20:07:25 +01:00
parent 082c005a20
commit 5510d3aeb5

View file

@ -67,7 +67,18 @@ void register_transmitter(Transmitter* transmitter) {
void init_serial() { void init_serial() {
// Init Serial monitor // Init Serial monitor
Serial.begin(115200); Serial.begin(115200);
#if HW_LILYGO2CAN
// Wait up to 100ms for Serial to be available. On the ESP32S3 Serial is
// provided by the USB controller, so will only work if the board is connected
// to a computer.
for (int i = 0; i < 10; i++) {
if (Serial)
break;
delay(10);
}
#else
while (!Serial) {} while (!Serial) {}
#endif
} }
void connectivity_loop(void*) { void connectivity_loop(void*) {