@@ -3055,6 +3055,20 @@ uint16_t SFE_UBLOX_GNSS::getMaxFileBufferAvail(void)
3055
3055
return (fileBufferMaxAvail);
3056
3056
}
3057
3057
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
+
3058
3072
// PRIVATE: Create the file buffer. Called by .begin
3059
3073
boolean SFE_UBLOX_GNSS::createFileBuffer (void )
3060
3074
{
@@ -8569,7 +8583,7 @@ boolean SFE_UBLOX_GNSS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait
8569
8583
// Adjust the I2C polling timeout based on update rate
8570
8584
i2cPollingWait = 1000 / (((int )navFreq) * 4 ); // This is the number of ms to wait between checks for new I2C data
8571
8585
8572
- // Query the module for the latest lat/long
8586
+ // Query the module
8573
8587
packetCfg.cls = UBX_CLASS_CFG;
8574
8588
packetCfg.id = UBX_CFG_RATE;
8575
8589
packetCfg.len = 0 ;
@@ -8606,6 +8620,79 @@ uint8_t SFE_UBLOX_GNSS::getNavigationFrequency(uint16_t maxWait)
8606
8620
return (measurementRate);
8607
8621
}
8608
8622
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
+
8609
8696
// ***** DOP Helper Functions
8610
8697
8611
8698
uint16_t SFE_UBLOX_GNSS::getGeometricDOP (uint16_t maxWait)
@@ -8897,7 +8984,7 @@ uint32_t SFE_UBLOX_GNSS::getUnixEpoch(uint32_t& microsecond, uint16_t maxWait)
8897
8984
packetUBXNAVPVT->data .sec );
8898
8985
int32_t us = packetUBXNAVPVT->data .nano / 1000 ;
8899
8986
microsecond = (uint32_t )us;
8900
- // ajust t if nano is negative
8987
+ // adjust t if nano is negative
8901
8988
if (us < 0 ) {
8902
8989
microsecond = (uint32_t )(us + 1000000 );
8903
8990
t--;
@@ -9664,7 +9751,7 @@ boolean SFE_UBLOX_GNSS::getSensorFusionMeasurement(UBX_ESF_MEAS_sensorData_t *se
9664
9751
if (packetUBXESFMEAS == NULL ) // Bail if the RAM allocation failed
9665
9752
return (false );
9666
9753
9667
- if (packetUBXESFMEAS->moduleQueried .moduleQueried .bits .data & (1 << sensor) == 0 )
9754
+ if (packetUBXESFMEAS->moduleQueried .moduleQueried .bits .data & (( 1 << sensor) == 0 ) )
9668
9755
getESFMEAS (maxWait);
9669
9756
packetUBXESFMEAS->moduleQueried .moduleQueried .bits .data &= ~(1 << sensor); // Since we are about to give this to user, mark this data as stale
9670
9757
packetUBXESFMEAS->moduleQueried .moduleQueried .bits .all = false ;
@@ -9684,7 +9771,7 @@ boolean SFE_UBLOX_GNSS::getRawSensorMeasurement(UBX_ESF_RAW_sensorData_t *sensor
9684
9771
if (packetUBXESFRAW == NULL ) // Bail if the RAM allocation failed
9685
9772
return (false );
9686
9773
9687
- if (packetUBXESFRAW->moduleQueried .moduleQueried .bits .data & (1 << sensor) == 0 )
9774
+ if (packetUBXESFRAW->moduleQueried .moduleQueried .bits .data & (( 1 << sensor) == 0 ) )
9688
9775
getESFRAW (maxWait);
9689
9776
packetUBXESFRAW->moduleQueried .moduleQueried .bits .data &= ~(1 << sensor); // Since we are about to give this to user, mark this data as stale
9690
9777
packetUBXESFRAW->moduleQueried .moduleQueried .bits .all = false ;
@@ -9706,7 +9793,7 @@ boolean SFE_UBLOX_GNSS::getSensorFusionStatus(UBX_ESF_STATUS_sensorStatus_t *sen
9706
9793
if (packetUBXESFSTATUS == NULL ) // Bail if the RAM allocation failed
9707
9794
return (false );
9708
9795
9709
- if (packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .status & (1 << sensor) == 0 )
9796
+ if (packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .status & (( 1 << sensor) == 0 ) )
9710
9797
getESFSTATUS (maxWait);
9711
9798
packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .status &= ~(1 << sensor); // Since we are about to give this to user, mark this data as stale
9712
9799
packetUBXESFSTATUS->moduleQueried .moduleQueried .bits .all = false ;
0 commit comments