Closed
Description
This is not really a bug, so much as a report of weird behavior of the ZED. If you do a getNavigationRate() directly after a setNavigationRate() it will report the wrong value. It's not the ZED storing value or delaying; adding a 5s delay doesn't fix the problem, there's something else going on. Reading a second time (even immediately) always reports the correct value.
I've seen this on RTK Surveyor when setting the meas/nav rates to larger values (30000 / 41 for 1234s between reports). The work around is always doing a 2nd getNavigationRate() before trusting it.
#include <Wire.h> //Needed for I2C to GNSS
#include <SparkFun_u-blox_GNSS_Arduino_Library.h> //http://librarymanager/All#SparkFun_u-blox_GNSS
SFE_UBLOX_GNSS myGNSS;
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
delay(250);
Serial.println("SparkFun u-blox Example");
Wire.begin();
if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port
{
Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing."));
while (1);
}
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
uint16_t currentNavigationRate = 0;
myGNSS.setNavigationRate(8);
//delay(5000); //You can delay as long as you'd like, it doesn't fix the problem
currentNavigationRate = myGNSS.getNavigationRate();
Serial.printf("currentNavigationRate (should be 8): %d\n", currentNavigationRate);
//The ZED-F9P will report an incorrect nav rate if we have rececently changed it.
//Reading a second time insures a correct read.
currentNavigationRate = myGNSS.getNavigationRate();
Serial.printf("Second read (should be 8): %d\n", currentNavigationRate);
myGNSS.setNavigationRate(4);
currentNavigationRate = myGNSS.getNavigationRate();
Serial.printf("currentNavigationRate (should be 4): %d\n", currentNavigationRate);
currentNavigationRate = myGNSS.getNavigationRate();
Serial.printf("Second read (should be 4): %d\n", currentNavigationRate);
}
void loop()
{
}