Skip to content

Commit 0c576c9

Browse files
committed
Adding set/getNavigationRate and set/getMeasurementRate
1 parent 213e3eb commit 0c576c9

3 files changed

+84
-3
lines changed

keywords.txt

+4
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,10 @@ logHNRPVT KEYWORD2
369369

370370
setNavigationFrequency KEYWORD2
371371
getNavigationFrequency KEYWORD2
372+
setMeasurementRate KEYWORD2
373+
getMeasurementRate KEYWORD2
374+
setNavigationRate KEYWORD2
375+
getNavigationRate KEYWORD2
372376

373377
getGeometricDOP KEYWORD2
374378
getPositionDOP KEYWORD2

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+74-1
Original file line numberDiff line numberDiff line change
@@ -8569,7 +8569,7 @@ boolean SFE_UBLOX_GNSS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait
85698569
//Adjust the I2C polling timeout based on update rate
85708570
i2cPollingWait = 1000 / (((int)navFreq) * 4); //This is the number of ms to wait between checks for new I2C data
85718571

8572-
//Query the module for the latest lat/long
8572+
//Query the module
85738573
packetCfg.cls = UBX_CLASS_CFG;
85748574
packetCfg.id = UBX_CFG_RATE;
85758575
packetCfg.len = 0;
@@ -8606,6 +8606,79 @@ uint8_t SFE_UBLOX_GNSS::getNavigationFrequency(uint16_t maxWait)
86068606
return (measurementRate);
86078607
}
86088608

8609+
//Set the elapsed time between GNSS measurements in milliseconds, which defines the rate
8610+
boolean SFE_UBLOX_GNSS::setMeasurementRate(uint16_t rate, uint16_t maxWait)
8611+
{
8612+
//Adjust the I2C polling timeout based on update rate
8613+
i2cPollingWait = rate / 4; //This is the number of ms to wait between checks for new I2C data
8614+
8615+
//Query the module
8616+
packetCfg.cls = UBX_CLASS_CFG;
8617+
packetCfg.id = UBX_CFG_RATE;
8618+
packetCfg.len = 0;
8619+
packetCfg.startingSpot = 0;
8620+
8621+
//This will load the payloadCfg array with current settings of the given register
8622+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8623+
return (false); //If command send fails then bail
8624+
8625+
//payloadCfg is now loaded with current bytes. Change only the ones we need to
8626+
payloadCfg[0] = rate & 0xFF; //measRate LSB
8627+
payloadCfg[1] = rate >> 8; //measRate MSB
8628+
8629+
return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
8630+
}
8631+
8632+
//Return the elapsed time between GNSS measurements in milliseconds, which defines the rate
8633+
uint16_t SFE_UBLOX_GNSS::getMeasurementRate(uint16_t maxWait)
8634+
{
8635+
if (packetUBXCFGRATE == NULL) initPacketUBXCFGRATE(); //Check that RAM has been allocated for the RATE data
8636+
if (packetUBXCFGRATE == NULL) //Bail if the RAM allocation failed
8637+
return 0;
8638+
8639+
if (packetUBXCFGRATE->moduleQueried.moduleQueried.bits.measRate == false)
8640+
getNavigationFrequencyInternal(maxWait);
8641+
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.measRate = false; //Since we are about to give this to user, mark this data as stale
8642+
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.all = false;
8643+
8644+
return (packetUBXCFGRATE->data.measRate);
8645+
}
8646+
8647+
//Set the ratio between the number of measurements and the number of navigation solutions. Unit is cycles. Max is 127.
8648+
boolean SFE_UBLOX_GNSS::setNavigationRate(uint16_t rate, uint16_t maxWait)
8649+
{
8650+
//Query the module
8651+
packetCfg.cls = UBX_CLASS_CFG;
8652+
packetCfg.id = UBX_CFG_RATE;
8653+
packetCfg.len = 0;
8654+
packetCfg.startingSpot = 0;
8655+
8656+
//This will load the payloadCfg array with current settings of the given register
8657+
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
8658+
return (false); //If command send fails then bail
8659+
8660+
//payloadCfg is now loaded with current bytes. Change only the ones we need to
8661+
payloadCfg[2] = rate & 0xFF; //navRate LSB
8662+
payloadCfg[3] = rate >> 8; //navRate MSB
8663+
8664+
return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
8665+
}
8666+
8667+
//Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles
8668+
uint16_t SFE_UBLOX_GNSS::getNavigationRate(uint16_t maxWait)
8669+
{
8670+
if (packetUBXCFGRATE == NULL) initPacketUBXCFGRATE(); //Check that RAM has been allocated for the RATE data
8671+
if (packetUBXCFGRATE == NULL) //Bail if the RAM allocation failed
8672+
return 0;
8673+
8674+
if (packetUBXCFGRATE->moduleQueried.moduleQueried.bits.navRate == false)
8675+
getNavigationFrequencyInternal(maxWait);
8676+
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.navRate = false; //Since we are about to give this to user, mark this data as stale
8677+
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.all = false;
8678+
8679+
return (packetUBXCFGRATE->data.navRate);
8680+
}
8681+
86098682
// ***** DOP Helper Functions
86108683

86118684
uint16_t SFE_UBLOX_GNSS::getGeometricDOP(uint16_t maxWait)

src/SparkFun_u-blox_GNSS_Arduino_Library.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -894,8 +894,12 @@ class SFE_UBLOX_GNSS
894894

895895
// Helper functions for CFG RATE
896896

897-
boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second
898-
uint8_t getNavigationFrequency(uint16_t maxWait = defaultMaxWait); //Get the number of nav solutions sent per second currently being output by module
897+
boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second
898+
uint8_t getNavigationFrequency(uint16_t maxWait = defaultMaxWait); //Get the number of nav solutions sent per second currently being output by module
899+
boolean setMeasurementRate(uint16_t rate, uint16_t maxWait = defaultMaxWait); //Set the elapsed time between GNSS measurements in milliseconds, which defines the rate
900+
uint16_t getMeasurementRate(uint16_t maxWait = defaultMaxWait); //Return the elapsed time between GNSS measurements in milliseconds
901+
boolean setNavigationRate(uint16_t rate, uint16_t maxWait = defaultMaxWait); //Set the ratio between the number of measurements and the number of navigation solutions. Unit is cycles. Max is 127
902+
uint16_t getNavigationRate(uint16_t maxWait = defaultMaxWait); //Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles
899903

900904
// Helper functions for DOP
901905

0 commit comments

Comments
 (0)