From fb82d05caea7e242f704d678747122bede19b5d5 Mon Sep 17 00:00:00 2001 From: cyberman54 Date: Thu, 20 Jan 2022 17:38:31 +0100 Subject: [PATCH] gpsread.cpp: add yield for thread safety --- src/gpsread.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gpsread.cpp b/src/gpsread.cpp index 8d5cb228..428604e4 100644 --- a/src/gpsread.cpp +++ b/src/gpsread.cpp @@ -146,12 +146,14 @@ void gps_loop(void *pvParameters) { // feed GPS decoder with serial NMEA data from GPS device while (GPS_Serial.available()) { gps.encode(GPS_Serial.read()); + yield(); } #elif defined GPS_I2C Wire.requestFrom(GPS_ADDR, 32); // caution: this is a blocking call while (Wire.available()) { gps.encode(Wire.read()); delay(2); // 2ms delay according L76 datasheet + yield(); } #endif @@ -170,7 +172,7 @@ void gps_loop(void *pvParameters) { // gps.passedChecksum(), gps.failedChecksum(), // gps.sentencesWithFix()); - delay(2); // yield to CPU + yield(); // yield to CPU } // end of infinite loop