From 4000a63ea171aaaab13d07f3de860d9679db26f4 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Mon, 6 Oct 2025 12:27:37 +0100 Subject: [PATCH 1/2] v3.1.13 - make millis timeouts wrap-safe --- .../Example34_I2C_Serial_Passthrough.ino | 6 +++--- .../DataLoggingExample3_RXM_SFRBX_and_RAWX.ino | 2 +- .../DataLoggingExample4_RXM_without_Callbacks.ino | 2 +- .../DataLoggingExample5_Fast_RXM.ino | 2 +- .../DataLoggingExample6_NMEA/DataLoggingExample6_NMEA.ino | 2 +- .../DataLoggingExample7_OpenLogESP32_SPI_SDIO.ino | 2 +- .../DataLoggingExample8_RTCM/DataLoggingExample8_RTCM.ino | 2 +- .../DataLoggingExample9_enableUBXlogging.ino | 2 +- examples/NEO-F10N/Example1_NAV_SIG/Example1_NAV_SIG.ino | 2 +- .../Example17_NTRIPClient_With_GGA_Callback.ino | 4 ++-- .../Example17_NTRIPClient_With_GGA_Callback__Serial.ino | 4 ++-- library.properties | 2 +- src/u-blox_GNSS.cpp | 8 ++++---- 13 files changed, 20 insertions(+), 20 deletions(-) diff --git a/examples/Basics/Example34_I2C_Serial_Passthrough/Example34_I2C_Serial_Passthrough.ino b/examples/Basics/Example34_I2C_Serial_Passthrough/Example34_I2C_Serial_Passthrough.ino index 68b82dd..2c29e9f 100644 --- a/examples/Basics/Example34_I2C_Serial_Passthrough/Example34_I2C_Serial_Passthrough.ino +++ b/examples/Basics/Example34_I2C_Serial_Passthrough/Example34_I2C_Serial_Passthrough.ino @@ -87,7 +87,7 @@ void loop() // If it is more than i2cReadInterval_ms since the last read, read how // many bytes are available in the GNSS I2C buffer. This will leave the register // address pointing at 0xFF. - if ((millis() > (i2cLastRead_ms + i2cReadInterval_ms)) || (i2cLastRead_ms == 0)) + if ((((millis() - i2cLastRead_ms) > i2cReadInterval_ms)) || (i2cLastRead_ms == 0)) { i2cBytesAvailable = gnssI2cAvailable(); i2cLastRead_ms = millis(); @@ -115,7 +115,7 @@ void loop() } // Else if uartI2cRingBuffer contains data and it is more than uartI2cSendInterval_ms // since the last send, send them - else if ((bytesToSend > 0) && (millis() > (uartI2cLastSend_ms + uartI2cSendInterval_ms))) + else if ((bytesToSend > 0) && ((millis() - uartI2cLastSend_ms) > uartI2cSendInterval_ms)) { sendI2cBytes(bytesToSend); uartI2cLastSend_ms = millis(); @@ -148,7 +148,7 @@ void loop() } // Else if i2cUartRingBuffer contains data and it is more than i2cUartSendInterval_ms // since the last send, send them - else if ((bytesToSend > 0) && (millis() > (i2cUartLastSend_ms + i2cUartSendInterval_ms))) + else if ((bytesToSend > 0) && ((millis() - i2cUartLastSend_ms) > i2cUartSendInterval_ms)) { sendUartBytes(bytesToSend); i2cUartLastSend_ms = millis(); diff --git a/examples/Data_Logging/DataLoggingExample3_RXM_SFRBX_and_RAWX/DataLoggingExample3_RXM_SFRBX_and_RAWX.ino b/examples/Data_Logging/DataLoggingExample3_RXM_SFRBX_and_RAWX/DataLoggingExample3_RXM_SFRBX_and_RAWX.ino index d4e11bb..204c866 100644 --- a/examples/Data_Logging/DataLoggingExample3_RXM_SFRBX_and_RAWX/DataLoggingExample3_RXM_SFRBX_and_RAWX.ino +++ b/examples/Data_Logging/DataLoggingExample3_RXM_SFRBX_and_RAWX/DataLoggingExample3_RXM_SFRBX_and_RAWX.ino @@ -210,7 +210,7 @@ void loop() // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if (millis() > (lastPrint + 1000)) // Print the message count once per second + if ((millis() - lastPrint) > 1000) // Print the message count once per second { Serial.print(F("Number of message groups received: SFRBX: ")); // Print how many message groups have been received (see note above) Serial.print(numSFRBX); diff --git a/examples/Data_Logging/DataLoggingExample4_RXM_without_Callbacks/DataLoggingExample4_RXM_without_Callbacks.ino b/examples/Data_Logging/DataLoggingExample4_RXM_without_Callbacks/DataLoggingExample4_RXM_without_Callbacks.ino index 4e3375f..71e3447 100644 --- a/examples/Data_Logging/DataLoggingExample4_RXM_without_Callbacks/DataLoggingExample4_RXM_without_Callbacks.ino +++ b/examples/Data_Logging/DataLoggingExample4_RXM_without_Callbacks/DataLoggingExample4_RXM_without_Callbacks.ino @@ -181,7 +181,7 @@ void loop() // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if (millis() > (lastPrint + 1000)) // Print bytesWritten once per second + if ((millis() - lastPrint) > 1000) // Print bytesWritten once per second { Serial.print(F("The number of bytes written to SD card is ")); // Print how many bytes have been written to SD card Serial.println(bytesWritten); diff --git a/examples/Data_Logging/DataLoggingExample5_Fast_RXM/DataLoggingExample5_Fast_RXM.ino b/examples/Data_Logging/DataLoggingExample5_Fast_RXM/DataLoggingExample5_Fast_RXM.ino index c178d94..b131add 100644 --- a/examples/Data_Logging/DataLoggingExample5_Fast_RXM/DataLoggingExample5_Fast_RXM.ino +++ b/examples/Data_Logging/DataLoggingExample5_Fast_RXM/DataLoggingExample5_Fast_RXM.ino @@ -196,7 +196,7 @@ void loop() // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if (millis() > (lastPrint + 1000)) // Print bytesWritten once per second + if ((millis() - lastPrint) > 1000) // Print bytesWritten once per second { Serial.print(F("The number of bytes written to SD card is: ")); // Print how many bytes have been written to SD card Serial.println(bytesWritten); diff --git a/examples/Data_Logging/DataLoggingExample6_NMEA/DataLoggingExample6_NMEA.ino b/examples/Data_Logging/DataLoggingExample6_NMEA/DataLoggingExample6_NMEA.ino index 8bab107..8dd21dd 100644 --- a/examples/Data_Logging/DataLoggingExample6_NMEA/DataLoggingExample6_NMEA.ino +++ b/examples/Data_Logging/DataLoggingExample6_NMEA/DataLoggingExample6_NMEA.ino @@ -178,7 +178,7 @@ void loop() // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if (millis() > (lastPrint + 1000)) // Print bytesWritten once per second + if ((millis() - lastPrint) > 1000) // Print bytesWritten once per second { Serial.print(F("The number of bytes written to SD card is ")); // Print how many bytes have been written to SD card Serial.println(bytesWritten); diff --git a/examples/Data_Logging/DataLoggingExample7_OpenLogESP32_SPI_SDIO/DataLoggingExample7_OpenLogESP32_SPI_SDIO.ino b/examples/Data_Logging/DataLoggingExample7_OpenLogESP32_SPI_SDIO/DataLoggingExample7_OpenLogESP32_SPI_SDIO.ino index 3b5962d..3ba28cf 100644 --- a/examples/Data_Logging/DataLoggingExample7_OpenLogESP32_SPI_SDIO/DataLoggingExample7_OpenLogESP32_SPI_SDIO.ino +++ b/examples/Data_Logging/DataLoggingExample7_OpenLogESP32_SPI_SDIO/DataLoggingExample7_OpenLogESP32_SPI_SDIO.ino @@ -279,7 +279,7 @@ void loop() // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if (millis() > (lastPrint + 1000)) // Print the message count once per second + if ((millis() - lastPrint) > 1000) // Print the message count once per second { uint16_t maxBufferBytes = myGNSS.getMaxFileBufferAvail(); // Get how full the file buffer has been (not how full it is now) float bufferHigh = 100.0 * (float)maxBufferBytes / (float)fileBufferSize; diff --git a/examples/Data_Logging/DataLoggingExample8_RTCM/DataLoggingExample8_RTCM.ino b/examples/Data_Logging/DataLoggingExample8_RTCM/DataLoggingExample8_RTCM.ino index 6c59f7e..cb3a942 100644 --- a/examples/Data_Logging/DataLoggingExample8_RTCM/DataLoggingExample8_RTCM.ino +++ b/examples/Data_Logging/DataLoggingExample8_RTCM/DataLoggingExample8_RTCM.ino @@ -183,7 +183,7 @@ void loop() // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if (millis() > (lastPrint + 1000)) // Print bytesWritten once per second + if ((millis() - lastPrint) > 1000) // Print bytesWritten once per second { Serial.print(F("The number of bytes written to SD card is ")); // Print how many bytes have been written to SD card Serial.println(bytesWritten); diff --git a/examples/Data_Logging/DataLoggingExample9_enableUBXlogging/DataLoggingExample9_enableUBXlogging.ino b/examples/Data_Logging/DataLoggingExample9_enableUBXlogging/DataLoggingExample9_enableUBXlogging.ino index ba252a4..7b639af 100644 --- a/examples/Data_Logging/DataLoggingExample9_enableUBXlogging/DataLoggingExample9_enableUBXlogging.ino +++ b/examples/Data_Logging/DataLoggingExample9_enableUBXlogging/DataLoggingExample9_enableUBXlogging.ino @@ -194,7 +194,7 @@ void loop() // =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=- - if (millis() > (lastPrint + 1000)) // Print bytesWritten once per second + if ((millis() - lastPrint) > 1000) // Print bytesWritten once per second { Serial.print(F("The number of bytes written to SD card is ")); // Print how many bytes have been written to SD card Serial.println(bytesWritten); diff --git a/examples/NEO-F10N/Example1_NAV_SIG/Example1_NAV_SIG.ino b/examples/NEO-F10N/Example1_NAV_SIG/Example1_NAV_SIG.ino index cda40be..447da25 100644 --- a/examples/NEO-F10N/Example1_NAV_SIG/Example1_NAV_SIG.ino +++ b/examples/NEO-F10N/Example1_NAV_SIG/Example1_NAV_SIG.ino @@ -298,7 +298,7 @@ void loop() void printDot() // Print a dot every 200ms - without using delay { static unsigned long lastPrint = millis(); - if (millis() > (lastPrint + 200)) + if ((millis() - lastPrint) > 200) { Serial.print("."); lastPrint = millis(); diff --git a/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback/Example17_NTRIPClient_With_GGA_Callback.ino b/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback/Example17_NTRIPClient_With_GGA_Callback.ino index df0bb54..fc38a09 100644 --- a/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback/Example17_NTRIPClient_With_GGA_Callback.ino +++ b/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback/Example17_NTRIPClient_With_GGA_Callback.ino @@ -246,7 +246,7 @@ void setup() unsigned long startTime = millis(); WiFi.begin(ssid, password); - while ((WiFi.status() != WL_CONNECTED) && (millis() < (startTime + 10000))) // Timeout after 10 seconds + while ((WiFi.status() != WL_CONNECTED) && ((millis() - startTime) < 10000)) // Timeout after 10 seconds { delay(500); Serial.print(F(".")); @@ -421,7 +421,7 @@ bool beginClient() unsigned long startTime = millis(); while (ntripClient.available() == 0) { - if (millis() > (startTime + 5000)) + if ((millis() - startTime) > 5000) { Serial.println(F("Caster timed out!")); ntripClient.stop(); diff --git a/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback__Serial/Example17_NTRIPClient_With_GGA_Callback__Serial.ino b/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback__Serial/Example17_NTRIPClient_With_GGA_Callback__Serial.ino index a0eab5a..76c9ee3 100644 --- a/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback__Serial/Example17_NTRIPClient_With_GGA_Callback__Serial.ino +++ b/examples/ZED-F9P/Example17_NTRIPClient_With_GGA_Callback__Serial/Example17_NTRIPClient_With_GGA_Callback__Serial.ino @@ -258,7 +258,7 @@ void setup() unsigned long startTime = millis(); WiFi.begin(ssid, password); - while ((WiFi.status() != WL_CONNECTED) && (millis() < (startTime + 10000))) // Timeout after 10 seconds + while ((WiFi.status() != WL_CONNECTED) && ((millis() - startTime) < 10000)) // Timeout after 10 seconds { delay(500); Serial.print(F(".")); @@ -433,7 +433,7 @@ bool beginClient() unsigned long startTime = millis(); while (ntripClient.available() == 0) { - if (millis() > (startTime + 5000)) + if ((millis() - startTime) > 5000) { Serial.println(F("Caster timed out!")); ntripClient.stop(); diff --git a/library.properties b/library.properties index 13ba65a..904b1e1 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS v3 -version=3.1.12 +version=3.1.13 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules

diff --git a/src/u-blox_GNSS.cpp b/src/u-blox_GNSS.cpp index 318d124..23dc43d 100644 --- a/src/u-blox_GNSS.cpp +++ b/src/u-blox_GNSS.cpp @@ -5680,7 +5680,7 @@ sfe_ublox_status_e DevUBLOXGNSS::waitForACKResponse(ubxPacket *outgoingUBX, uint packetAuto.classAndIDmatch = SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED; unsigned long startTime = millis(); - while (millis() < (startTime + (unsigned long)maxTime)) + while ((millis() - startTime) < (unsigned long)maxTime) { if (checkUbloxInternal(outgoingUBX, requestedClass, requestedID) == true) // See if new data is available. Process bytes as they come in. { @@ -5819,7 +5819,7 @@ sfe_ublox_status_e DevUBLOXGNSS::waitForACKResponse(ubxPacket *outgoingUBX, uint } // checkUbloxInternal == true delay(1); // Allow an RTOS to get an elbow in (#11) - } // while (millis() < (startTime + (unsigned long)maxTime)) + } // while ((millis() - startTime) < (unsigned long)maxTime) // We have timed out... // If the outgoingUBX->classAndIDmatch is VALID then we can take a gamble and return DATA_RECEIVED @@ -6837,7 +6837,7 @@ size_t DevUBLOXGNSS::pushAssistNowDataInternal(size_t offset, bool skipTime, con { unsigned long startTime = millis(); bool keepGoing = true; - while (keepGoing && (millis() < (startTime + maxWait))) // Keep checking for the ACK until we time out + while (keepGoing && ((millis() - startTime) < maxWait)) // Keep checking for the ACK until we time out { checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Don't overwrite the requested Class and ID. We could be pushing this from another thread... if (packetUBXMGAACK->head != packetUBXMGAACK->tail) // Does the MGA ACK ringbuffer contain any ACK's? @@ -7360,7 +7360,7 @@ size_t DevUBLOXGNSS::readNavigationDatabase(uint8_t *dataBytes, size_t maxNumDat uint32_t databaseEntriesRX = 0; // Keep track of how many database entries are received size_t numBytesReceived = 0; // Keep track of how many bytes are received - while (keepGoing && (millis() < (startTime + maxWait))) + while (keepGoing && ((millis() - startTime) < maxWait)) { checkUbloxInternal(&packetCfg, 0, 0); // Call checkUbloxInternal to parse any incoming data. Don't overwrite the requested Class and ID. We could be pushing this from another thread... From 49a6cdb4dde9f96697a7afbf127ab2e839e0f9b9 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Mon, 6 Oct 2025 12:38:48 +0100 Subject: [PATCH 2/2] Update compile-sketch.yml --- .github/workflows/compile-sketch.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/compile-sketch.yml b/.github/workflows/compile-sketch.yml index 4ef0d9a..0c45859 100644 --- a/.github/workflows/compile-sketch.yml +++ b/.github/workflows/compile-sketch.yml @@ -92,7 +92,7 @@ jobs: run: echo running on branch ${GITHUB_REF##*/} - name: Compile Sketch - uses: arduino/compile-sketches@v1 + uses: arduino/compile-sketches@v1.1.0 with: platforms: ${{ matrix.board.platforms }} fqbn: ${{ matrix.board.fqbn }}