From ff4b03b8c1cb594f093ed0229404f254c91fe438 Mon Sep 17 00:00:00 2001 From: Kevin Hester Date: Sat, 7 Nov 2020 09:15:28 +0800 Subject: [PATCH] Fix #509 was causing failure on non GPS equipped boards --- src/gps/GPS.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gps/GPS.cpp b/src/gps/GPS.cpp index aca074ccc..314b4c313 100644 --- a/src/gps/GPS.cpp +++ b/src/gps/GPS.cpp @@ -25,9 +25,15 @@ uint8_t GPS::i2cAddress = 0; GPS *gps; +/// Multiple GPS instances might use the same serial port (in sequence), but we can +/// only init that port once. +static bool didSerialInit; + bool GPS::setupGPS() { - if (_serial_gps) { + if (_serial_gps && !didSerialInit) { + didSerialInit = true; + #ifdef GPS_RX_PIN _serial_gps->begin(GPS_BAUDRATE, SERIAL_8N1, GPS_RX_PIN, GPS_TX_PIN); #else