@@ -3055,6 +3055,20 @@ uint16_t SFE_UBLOX_GNSS::getMaxFileBufferAvail(void)
30553055 return (fileBufferMaxAvail);
30563056}
30573057
3058+ // Clear the file buffer - discard all contents
3059+ void SFE_UBLOX_GNSS::clearFileBuffer (void )
3060+ {
3061+ if (fileBufferSize == 0 ) // Bail if the user has not called setFileBufferSize (probably redundant)
3062+ return ;
3063+ fileBufferTail = fileBufferHead;
3064+ }
3065+
3066+ // Reset fileBufferMaxAvail
3067+ void SFE_UBLOX_GNSS::clearMaxFileBufferAvail (void )
3068+ {
3069+ fileBufferMaxAvail = 0 ;
3070+ }
3071+
30583072// PRIVATE: Create the file buffer. Called by .begin
30593073boolean SFE_UBLOX_GNSS::createFileBuffer (void )
30603074{
@@ -8569,7 +8583,7 @@ boolean SFE_UBLOX_GNSS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait
85698583 // Adjust the I2C polling timeout based on update rate
85708584 i2cPollingWait = 1000 / (((int )navFreq) * 4 ); // This is the number of ms to wait between checks for new I2C data
85718585
8572- // Query the module for the latest lat/long
8586+ // Query the module
85738587 packetCfg.cls = UBX_CLASS_CFG;
85748588 packetCfg.id = UBX_CFG_RATE;
85758589 packetCfg.len = 0 ;
@@ -8606,6 +8620,79 @@ uint8_t SFE_UBLOX_GNSS::getNavigationFrequency(uint16_t maxWait)
86068620 return (measurementRate);
86078621}
86088622
8623+ // Set the elapsed time between GNSS measurements in milliseconds, which defines the rate
8624+ boolean SFE_UBLOX_GNSS::setMeasurementRate (uint16_t rate, uint16_t maxWait)
8625+ {
8626+ // Adjust the I2C polling timeout based on update rate
8627+ i2cPollingWait = rate / 4 ; // This is the number of ms to wait between checks for new I2C data
8628+
8629+ // Query the module
8630+ packetCfg.cls = UBX_CLASS_CFG;
8631+ packetCfg.id = UBX_CFG_RATE;
8632+ packetCfg.len = 0 ;
8633+ packetCfg.startingSpot = 0 ;
8634+
8635+ // This will load the payloadCfg array with current settings of the given register
8636+ if (sendCommand (&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8637+ return (false ); // If command send fails then bail
8638+
8639+ // payloadCfg is now loaded with current bytes. Change only the ones we need to
8640+ payloadCfg[0 ] = rate & 0xFF ; // measRate LSB
8641+ payloadCfg[1 ] = rate >> 8 ; // measRate MSB
8642+
8643+ return ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
8644+ }
8645+
8646+ // Return the elapsed time between GNSS measurements in milliseconds, which defines the rate
8647+ uint16_t SFE_UBLOX_GNSS::getMeasurementRate (uint16_t maxWait)
8648+ {
8649+ if (packetUBXCFGRATE == NULL ) initPacketUBXCFGRATE (); // Check that RAM has been allocated for the RATE data
8650+ if (packetUBXCFGRATE == NULL ) // Bail if the RAM allocation failed
8651+ return 0 ;
8652+
8653+ if (packetUBXCFGRATE->moduleQueried .moduleQueried .bits .measRate == false )
8654+ getNavigationFrequencyInternal (maxWait);
8655+ packetUBXCFGRATE->moduleQueried .moduleQueried .bits .measRate = false ; // Since we are about to give this to user, mark this data as stale
8656+ packetUBXCFGRATE->moduleQueried .moduleQueried .bits .all = false ;
8657+
8658+ return (packetUBXCFGRATE->data .measRate );
8659+ }
8660+
8661+ // Set the ratio between the number of measurements and the number of navigation solutions. Unit is cycles. Max is 127.
8662+ boolean SFE_UBLOX_GNSS::setNavigationRate (uint16_t rate, uint16_t maxWait)
8663+ {
8664+ // Query the module
8665+ packetCfg.cls = UBX_CLASS_CFG;
8666+ packetCfg.id = UBX_CFG_RATE;
8667+ packetCfg.len = 0 ;
8668+ packetCfg.startingSpot = 0 ;
8669+
8670+ // This will load the payloadCfg array with current settings of the given register
8671+ if (sendCommand (&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8672+ return (false ); // If command send fails then bail
8673+
8674+ // payloadCfg is now loaded with current bytes. Change only the ones we need to
8675+ payloadCfg[2 ] = rate & 0xFF ; // navRate LSB
8676+ payloadCfg[3 ] = rate >> 8 ; // navRate MSB
8677+
8678+ return ((sendCommand (&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
8679+ }
8680+
8681+ // Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles
8682+ uint16_t SFE_UBLOX_GNSS::getNavigationRate (uint16_t maxWait)
8683+ {
8684+ if (packetUBXCFGRATE == NULL ) initPacketUBXCFGRATE (); // Check that RAM has been allocated for the RATE data
8685+ if (packetUBXCFGRATE == NULL ) // Bail if the RAM allocation failed
8686+ return 0 ;
8687+
8688+ if (packetUBXCFGRATE->moduleQueried .moduleQueried .bits .navRate == false )
8689+ getNavigationFrequencyInternal (maxWait);
8690+ packetUBXCFGRATE->moduleQueried .moduleQueried .bits .navRate = false ; // Since we are about to give this to user, mark this data as stale
8691+ packetUBXCFGRATE->moduleQueried .moduleQueried .bits .all = false ;
8692+
8693+ return (packetUBXCFGRATE->data .navRate );
8694+ }
8695+
86098696// ***** DOP Helper Functions
86108697
86118698uint16_t SFE_UBLOX_GNSS::getGeometricDOP (uint16_t maxWait)
@@ -8897,7 +8984,7 @@ uint32_t SFE_UBLOX_GNSS::getUnixEpoch(uint32_t& microsecond, uint16_t maxWait)
88978984 packetUBXNAVPVT->data .sec );
88988985 int32_t us = packetUBXNAVPVT->data .nano / 1000 ;
88998986 microsecond = (uint32_t )us;
8900- // ajust t if nano is negative
8987+ // adjust t if nano is negative
89018988 if (us < 0 ) {
89028989 microsecond = (uint32_t )(us + 1000000 );
89038990 t--;
@@ -9664,7 +9751,7 @@ boolean SFE_UBLOX_GNSS::getSensorFusionMeasurement(UBX_ESF_MEAS_sensorData_t *se
96649751 if (packetUBXESFMEAS == NULL ) // Bail if the RAM allocation failed
96659752 return (false );
96669753
9667- if (packetUBXESFMEAS->moduleQueried .moduleQueried .bits .data & (1 << sensor) == 0 )
9754+ if (packetUBXESFMEAS->moduleQueried .moduleQueried .bits .data & (( 1 << sensor) == 0 ) )
96689755 getESFMEAS (maxWait);
96699756 packetUBXESFMEAS->moduleQueried .moduleQueried .bits .data &= ~(1 << sensor); // Since we are about to give this to user, mark this data as stale
96709757 packetUBXESFMEAS->moduleQueried .moduleQueried .bits .all = false ;
@@ -9684,7 +9771,7 @@ boolean SFE_UBLOX_GNSS::getRawSensorMeasurement(UBX_ESF_RAW_sensorData_t *sensor
96849771 if (packetUBXESFRAW == NULL ) // Bail if the RAM allocation failed
96859772 return (false );
96869773
9687- if (packetUBXESFRAW->moduleQueried .moduleQueried .bits .data & (1 << sensor) == 0 )
9774+ if (packetUBXESFRAW->moduleQueried .moduleQueried .bits .data & (( 1 << sensor) == 0 ) )
96889775 getESFRAW (maxWait);
96899776 packetUBXESFRAW->moduleQueried .moduleQueried .bits .data &= ~(1 << sensor); // Since we are about to give this to user, mark this data as stale
96909777 packetUBXESFRAW->moduleQueried .moduleQueried .bits .all = false ;
@@ -9706,7 +9793,7 @@ boolean SFE_UBLOX_GNSS::getSensorFusionStatus(UBX_ESF_STATUS_sensorStatus_t *sen
97069793 if (packetUBXESFSTATUS == NULL ) // Bail if the RAM allocation failed
97079794 return (false );
97089795
9709- if (packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .status & (1 << sensor) == 0 )
9796+ if (packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .status & (( 1 << sensor) == 0 ) )
97109797 getESFSTATUS (maxWait);
97119798 packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .status &= ~(1 << sensor); // Since we are about to give this to user, mark this data as stale
97129799 packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .all = false ;
0 commit comments