@@ -2121,7 +2121,7 @@ bool GNSS_MOSAIC::sendAndWaitForIdle(HardwareSerial *serialPort, const char *mes
21212121 unsigned long startTime = millis ();
21222122 size_t replySeen = 0 ;
21232123
2124- while ((millis () < ( startTime + timeout) ) && (replySeen < strlen (reply))) // While not timed out and reply not seen
2124+ while ((( millis () - startTime) < timeout) && (replySeen < strlen (reply))) // While not timed out and reply not seen
21252125 {
21262126 if (serialPort->available ()) // If a char is available
21272127 {
@@ -2145,7 +2145,7 @@ bool GNSS_MOSAIC::sendAndWaitForIdle(HardwareSerial *serialPort, const char *mes
21452145 if (replySeen == strlen (reply)) // If the reply was seen
21462146 {
21472147 startTime = millis ();
2148- while (millis () < ( startTime + idle) )
2148+ while (( millis () - startTime) < idle)
21492149 {
21502150 if (serialPort->available ())
21512151 {
@@ -2256,18 +2256,18 @@ bool GNSS_MOSAIC::sendWithResponse(HardwareSerial *serialPort, const char *messa
22562256 }
22572257
22582258 // If the reply has started to arrive at the timeout, allow extra time
2259- if (millis () > ( startTime + timeout) ) // Have we timed out?
2259+ if (( millis () - startTime) > timeout) // Have we timed out?
22602260 if (replySeen == 0 ) // If replySeen is zero, don't keepGoing
22612261 keepGoing = false ;
22622262
2263- if (millis () > ( startTime + timeout + wait)) // Have we really timed out?
2263+ if (( millis () - startTime) > ( timeout + wait)) // Have we really timed out?
22642264 keepGoing = false ; // Don't keepGoing
22652265 }
22662266
22672267 if (replySeen == strlen (reply)) // If the reply was seen
22682268 {
22692269 startTime = millis ();
2270- while (millis () < ( startTime + wait) )
2270+ while (( millis () - startTime) < wait)
22712271 {
22722272 if (serialPort->available ())
22732273 {
@@ -2795,7 +2795,7 @@ void GNSS_MOSAIC::update()
27952795 const unsigned long sdCardSizeCheckInterval = 5000 ; // Matches the interval in logUpdate
27962796 static unsigned long sdCardLastFreeChange = millis (); // X5 is slow to update free. Seems to be about every ~20s?
27972797 static uint64_t previousFreeSpace = 0 ;
2798- if (millis () > ( sdCardSizeLastCheck + sdCardSizeCheckInterval) )
2798+ if (( millis () - sdCardSizeLastCheck) > sdCardSizeCheckInterval)
27992799 {
28002800 updateSD (); // Check if the card has been removed / inserted
28012801
@@ -2817,7 +2817,7 @@ void GNSS_MOSAIC::update()
28172817 // The free space has not changed
28182818 // X5 is slow to update free. Seems to be about every ~20s?
28192819 // So only set logIncreasing to false after 30s
2820- if (millis () > ( sdCardLastFreeChange + 30000 ) )
2820+ if (( millis () - sdCardLastFreeChange) > 30000 )
28212821 logIncreasing = false ;
28222822 }
28232823 else // if (sdFreeSpace > previousFreeSpace)
@@ -2839,7 +2839,7 @@ void GNSS_MOSAIC::update()
28392839
28402840 // Update spartnCorrectionsReceived
28412841 // Does this need if(online.lband_gnss) ? Not sure... TODO
2842- if (millis () > ( lastSpartnReception + (settings.correctionsSourcesLifetime_s * 1000 ) )) // Timeout
2842+ if (( millis () - lastSpartnReception) > (settings.correctionsSourcesLifetime_s * 1000 )) // Timeout
28432843 {
28442844 if (spartnCorrectionsReceived) // If corrections were being received
28452845 {
@@ -2920,7 +2920,7 @@ void GNSS_MOSAIC::waitSBFReceiverSetup(HardwareSerial *serialPort, unsigned long
29202920 reportFatalError (" Failed to initialize the SBF parser" );
29212921
29222922 unsigned long startTime = millis ();
2923- while ((millis () < ( startTime + timeout) ) && (_receiverSetupSeen == false ))
2923+ while ((( millis () - startTime) < timeout) && (_receiverSetupSeen == false ))
29242924 {
29252925 if (serialPort->available ())
29262926 {
@@ -3223,7 +3223,7 @@ void mosaicX5flushRX(unsigned long timeout)
32233223 if (timeout > 0)
32243224 {
32253225 unsigned long startTime = millis();
3226- while (millis() < ( startTime + timeout) )
3226+ while (( millis() - startTime) < timeout)
32273227 {
32283228 if (serial2GNSS->available())
32293229 {
@@ -3247,7 +3247,7 @@ void mosaicX5flushRX(unsigned long timeout)
32473247bool mosaicX5waitCR(unsigned long timeout)
32483248{
32493249 unsigned long startTime = millis();
3250- while (millis() < ( startTime + timeout) )
3250+ while (( millis() - startTime) < timeout)
32513251 {
32523252 if (serial2GNSS->available())
32533253 {
0 commit comments