@@ -7387,38 +7387,25 @@ boolean SFE_UBLOX_GNSS::getNavigationFrequencyInternal(uint16_t maxWait)
7387
7387
if (packetUBXCFGRATE == NULL ) // Bail if the RAM allocation failed
7388
7388
return (false );
7389
7389
7390
- if (packetUBXCFGRATE->automaticFlags .flags .bits .automatic && packetUBXCFGRATE->automaticFlags .flags .bits .implicitUpdate )
7391
- {
7392
- // The GPS is automatically reporting, we just check whether we got unread data
7393
- checkUbloxInternal (&packetCfg, UBX_CLASS_CFG, UBX_CFG_RATE);
7394
- return packetUBXCFGRATE->moduleQueried .moduleQueried .bits .all ;
7395
- }
7396
- else if (packetUBXCFGRATE->automaticFlags .flags .bits .automatic && !packetUBXCFGRATE->automaticFlags .flags .bits .implicitUpdate )
7397
- {
7398
- // Someone else has to call checkUblox for us...
7399
- return (false );
7400
- }
7401
- else
7402
- {
7403
- // The GPS is not automatically reporting navigation rate so we have to poll explicitly
7404
- packetCfg.cls = UBX_CLASS_CFG;
7405
- packetCfg.id = UBX_CFG_RATE;
7406
- packetCfg.len = 0 ;
7407
- packetCfg.startingSpot = 0 ;
7408
-
7409
- // The data is parsed as part of processing the response
7410
- sfe_ublox_status_e retVal = sendCommand (&packetCfg, maxWait);
7390
+ // The CFG RATE message will never be produced automatically - that would be pointless.
7391
+ // There is no setAutoCFGRATE function. We always need to poll explicitly.
7392
+ packetCfg.cls = UBX_CLASS_CFG;
7393
+ packetCfg.id = UBX_CFG_RATE;
7394
+ packetCfg.len = 0 ;
7395
+ packetCfg.startingSpot = 0 ;
7411
7396
7412
- if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
7413
- return ( true );
7397
+ // The data is parsed as part of processing the response
7398
+ sfe_ublox_status_e retVal = sendCommand (&packetCfg, maxWait );
7414
7399
7415
- if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
7416
- {
7417
- return (true );
7418
- }
7400
+ if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
7401
+ return (true );
7419
7402
7420
- return (false );
7403
+ if (retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN)
7404
+ {
7405
+ return (true );
7421
7406
}
7407
+
7408
+ return (false );
7422
7409
}
7423
7410
7424
7411
// PRIVATE: Allocate RAM for packetUBXCFGRATE and initialize it
@@ -7431,10 +7418,10 @@ boolean SFE_UBLOX_GNSS::initPacketUBXCFGRATE()
7431
7418
_debugSerial->println (F (" initPacketUBXCFGRATE: PANIC! RAM allocation failed!" ));
7432
7419
return (false );
7433
7420
}
7434
- packetUBXCFGRATE->automaticFlags .flags .all = 0 ;
7435
- packetUBXCFGRATE->callbackPointer = NULL ;
7436
- packetUBXCFGRATE->callbackData = NULL ;
7437
- packetUBXCFGRATE->moduleQueried .moduleQueried .all = 0 ;
7421
+ packetUBXCFGRATE->automaticFlags .flags .all = 0 ; // Redundant
7422
+ packetUBXCFGRATE->callbackPointer = NULL ; // Redundant
7423
+ packetUBXCFGRATE->callbackData = NULL ; // Redundant
7424
+ packetUBXCFGRATE->moduleQueried .moduleQueried .all = 0 ; // Mark all data as stale/read
7438
7425
return (true );
7439
7426
}
7440
7427
@@ -9114,7 +9101,11 @@ boolean SFE_UBLOX_GNSS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait
9114
9101
payloadCfg[0 ] = measurementRate & 0xFF ; // measRate LSB
9115
9102
payloadCfg[1 ] = measurementRate >> 8 ; // measRate MSB
9116
9103
9117
- return ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
9104
+ boolean result = ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
9105
+
9106
+ flushCFGRATE (); // Mark the polled measurement and navigation rate data as stale
9107
+
9108
+ return (result);
9118
9109
}
9119
9110
9120
9111
// Get the rate at which the module is outputting nav solutions
@@ -9155,7 +9146,11 @@ boolean SFE_UBLOX_GNSS::setMeasurementRate(uint16_t rate, uint16_t maxWait)
9155
9146
payloadCfg[0 ] = rate & 0xFF ; // measRate LSB
9156
9147
payloadCfg[1 ] = rate >> 8 ; // measRate MSB
9157
9148
9158
- return ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
9149
+ boolean result = ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
9150
+
9151
+ flushCFGRATE (); // Mark the polled measurement and navigation rate data as stale
9152
+
9153
+ return (result);
9159
9154
}
9160
9155
9161
9156
// Return the elapsed time between GNSS measurements in milliseconds, which defines the rate
@@ -9190,7 +9185,11 @@ boolean SFE_UBLOX_GNSS::setNavigationRate(uint16_t rate, uint16_t maxWait)
9190
9185
payloadCfg[2 ] = rate & 0xFF ; // navRate LSB
9191
9186
payloadCfg[3 ] = rate >> 8 ; // navRate MSB
9192
9187
9193
- return ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
9188
+ boolean result = ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
9189
+
9190
+ flushCFGRATE (); // Mark the polled measurement and navigation rate data as stale
9191
+
9192
+ return (result);
9194
9193
}
9195
9194
9196
9195
// Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles
@@ -9208,6 +9207,13 @@ uint16_t SFE_UBLOX_GNSS::getNavigationRate(uint16_t maxWait)
9208
9207
return (packetUBXCFGRATE->data .navRate );
9209
9208
}
9210
9209
9210
+ // Mark the CFG RATE data as read/stale
9211
+ void SFE_UBLOX_GNSS::flushCFGRATE ()
9212
+ {
9213
+ if (packetUBXCFGRATE == NULL ) return ; // Bail if RAM has not been allocated (otherwise we could be writing anywhere!)
9214
+ packetUBXCFGRATE->moduleQueried .moduleQueried .all = 0 ; // Mark all datums as stale (read before)
9215
+ }
9216
+
9211
9217
// ***** DOP Helper Functions
9212
9218
9213
9219
uint16_t SFE_UBLOX_GNSS::getGeometricDOP (uint16_t maxWait)
0 commit comments