Merge pull request #1 from sparkfun/release_candidate

Release candidate update
This commit is contained in:
UT2UH
2021-03-31 15:40:07 +03:00
committed by GitHub
7 changed files with 283 additions and 55 deletions
+1
View File
@@ -87,6 +87,7 @@ If you would like to learn more about how this library works, including the big
* [GPS-15005](https://www.sparkfun.com/products/15005) - SparkFun GPS-RTK Board - NEO-M8P-2 (Qwiic)
* [GPS-15210](https://www.sparkfun.com/products/15210) - SparkFun GPS Breakout - Chip Antenna, SAM-M8Q (Qwiic)
* [GPS-15193](https://www.sparkfun.com/products/15193) - SparkFun GPS Breakout - Chip Antenna, ZOE-M8Q (Qwiic)
* [GPS-17285](https://www.sparkfun.com/products/17285) - SparkFun GPS Breakout - NEO-M9N, SMA (Qwiic)
* [GPS-15733](https://www.sparkfun.com/products/15733) - SparkFun GPS Breakout - NEO-M9N, Chip Antenna (Qwiic)
* [GPS-15712](https://www.sparkfun.com/products/15712) - SparkFun GPS Breakout - NEO-M9N, U.FL (Qwiic)
* [GPS-16329](https://www.sparkfun.com/products/16329) - SparkFun GPS Dead Reckoning Breakout - NEO-M8U (Qwiic)
@@ -8,6 +8,8 @@
This example shows how to query a u-blox module for the current time and date as Unix Epoch uint32_t type to avoid time.h dependency.
We also turn off the NMEA output on the I2C port. This decreases the amount of I2C traffic dramatically.
Note: this example works best on modules like the ZED_F9P. Modules like the ZOE_M8Q do not support confirmedTime.
Leave NMEA parsing behind. Now you can simply ask the module for the datums you want!
Feel like supporting open source hardware?
@@ -30,8 +32,6 @@ SFE_UBLOX_GNSS myGNSS;
long lastTime = 0; //Simple local timer. Limits amount if I2C traffic to u-blox module.
uint32_t us; //microseconds returned by getUnixEpoch()
void setup()
{
Serial.begin(115200);
@@ -48,6 +48,9 @@ void setup()
;
}
// Uncomment the next line if you need to completely reset your module
//myGNSS.factoryDefault(); delay(5000); // Reset everything and wait while the module restarts
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
//myGNSS.saveConfiguration(); //Optional: Save the current settings to flash and BBR
@@ -63,11 +66,15 @@ void loop()
{
lastTime = millis(); //Update the timer
byte SIV = myGNSS.getSIV();
Serial.print(F(" SIV: "));
Serial.print(SIV);
// getUnixEpoch marks the PVT data as stale so you will get Unix time and PVT time on alternate seconds
uint32_t us; //microseconds returned by getUnixEpoch()
uint32_t epoch = myGNSS.getUnixEpoch(us);
Serial.print("Unix Epoch: ");
Serial.print(epoch, DEC);
Serial.print(" micros: ");
Serial.println(us, DEC);
Serial.print(" ");
Serial.print(myGNSS.getYear());
Serial.print("-");
Serial.print(myGNSS.getMonth());
@@ -79,10 +86,6 @@ void loop()
Serial.print(myGNSS.getMinute());
Serial.print(":");
Serial.print(myGNSS.getSecond());
Serial.print(" getUnixEpoch(micros): ");
Serial.print(myGNSS.getUnixEpoch(us));
Serial.print(" micros: ");
Serial.print(us, DEC);
Serial.print(" Time is ");
if (myGNSS.getTimeValid() == false)
@@ -98,6 +101,8 @@ void loop()
}
Serial.print("confirmed");
Serial.println();
byte SIV = myGNSS.getSIV();
Serial.print(F(" SIV: "));
Serial.println(SIV);
}
}
@@ -0,0 +1,123 @@
/*
Demonstrate get/setMeasurementRate and get/setNavigationRate
By: Paul Clark
SparkFun Electronics
Date: March 30th, 2021
License: MIT. See license file for more information but you can
basically do whatever you want with this code.
This example shows how to slow down the measurement and navigation rates.
This should run on any GNSS module but has only been tested on the ZED_F9P and ZOE_M8Q.
Feel like supporting open source hardware?
Buy a board from SparkFun!
ZED-F9P RTK2: https://www.sparkfun.com/products/15136
NEO-M8P RTK: https://www.sparkfun.com/products/15005
SAM-M8Q: https://www.sparkfun.com/products/15106
Hardware Connections:
Plug a Qwiic cable into the GNSS and a BlackBoard
If you don't have a platform with a Qwiic connection use the SparkFun Qwiic Breadboard Jumper (https://www.sparkfun.com/products/14425)
Open the serial monitor at 115200 baud to see the output
*/
#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;
unsigned long lastTime = 0; //Simple local timer. Used to calc the message interval.
void setup()
{
Serial.begin(115200);
while (!Serial); //Wait for user to open terminal
Serial.println("SparkFun u-blox Example");
Wire.begin();
//myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial
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);
}
// Uncomment the next line if you need to completely reset your module
//myGNSS.factoryDefault(); delay(5000); // Reset everything and wait while the module restarts
myGNSS.setI2COutput(COM_TYPE_UBX); //Set the I2C port to output UBX only (turn off NMEA noise)
// Begin by printing the current measurement rate and navigation rate
uint16_t rate = myGNSS.getMeasurementRate(); //Get the measurement rate of this module
Serial.print("Current measurement interval (ms): ");
Serial.println(rate);
rate = myGNSS.getNavigationRate(); //Get the navigation rate of this module
Serial.print("Current navigation ratio (cycles): ");
Serial.println(rate);
// The measurement rate is the elapsed time between GNSS measurements, which defines the rate
// e.g. 100 ms => 10 Hz, 1000 ms => 1 Hz, 10000 ms => 0.1 Hz.
// Let's set the measurement rate (interval) to 5 seconds = 5000 milliseconds
if (myGNSS.setMeasurementRate(5000) == false)
{
Serial.println(F("Could not set the measurement rate. Freezing."));
while (1);
}
// setMeasurementRate will set i2cPollingWait to a quarter of the interval
// Let's override that so we can poll the module more frequently and avoid timeouts
myGNSS.setI2CpollingWait(25); // Set i2cPollingWait to 25ms
// The navigation rate is the ratio between the number of measurements and the number of navigation solutions
// e.g. 5 means five measurements for every navigation solution. Maximum value is 127
// Let's set the navigation rate (ratio) to 12 to produce a solution every minute
if (myGNSS.setNavigationRate(12) == false)
{
Serial.println(F("Could not set the navigation rate. Freezing."));
while (1);
}
// Another trick we can use is to mark the CFG RATE data as stale so we can be sure we read fresh data
myGNSS.packetUBXCFGRATE->moduleQueried.moduleQueried.all = 0; // Mark all of the CFG RATE data as stale
// Read and print the updated measurement rate and navigation rate
rate = myGNSS.getMeasurementRate(); //Get the measurement rate of this module
Serial.print("New measurement interval (ms): ");
Serial.println(rate);
rate = myGNSS.getNavigationRate(); //Get the navigation rate of this module
Serial.print("New navigation ratio (cycles): ");
Serial.println(rate);
lastTime = millis();
}
void loop()
{
// i2cPollingWait will prevent us from thrashing the I2C bus
if (myGNSS.getPVT()) //Check for new Position, Velocity, Time data. getPVT returns true if new data is available.
{
long latitude = myGNSS.getLatitude();
Serial.print(F("Lat: "));
Serial.print(latitude);
long longitude = myGNSS.getLongitude();
Serial.print(F(" Long: "));
Serial.print(longitude);
//Calculate the interval since the last message
Serial.print(F(" Interval: "));
Serial.print(((float)(millis() - lastTime)) / 1000.0, 2);
Serial.print(F("s"));
Serial.println();
lastTime = millis(); //Update lastTime
}
}
+6
View File
@@ -84,6 +84,8 @@ setFileBufferSize KEYWORD2
extractFileBufferData KEYWORD2
fileBufferAvailable KEYWORD2
getMaxFileBufferAvail KEYWORD2
clearFileBuffer KEYWORD2
clearMaxFileBufferAvail KEYWORD2
getPortSettings KEYWORD2
setPortOutput KEYWORD2
@@ -369,6 +371,10 @@ logHNRPVT KEYWORD2
setNavigationFrequency KEYWORD2
getNavigationFrequency KEYWORD2
setMeasurementRate KEYWORD2
getMeasurementRate KEYWORD2
setNavigationRate KEYWORD2
getNavigationRate KEYWORD2
getGeometricDOP KEYWORD2
getPositionDOP KEYWORD2
+1 -1
View File
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS Arduino Library
version=2.0.2
version=2.0.4
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C and Serial Communication with u-blox GNSS modules<br/><br/>
+92 -5
View File
@@ -3055,6 +3055,20 @@ uint16_t SFE_UBLOX_GNSS::getMaxFileBufferAvail(void)
return (fileBufferMaxAvail);
}
// Clear the file buffer - discard all contents
void SFE_UBLOX_GNSS::clearFileBuffer(void)
{
if (fileBufferSize == 0) // Bail if the user has not called setFileBufferSize (probably redundant)
return;
fileBufferTail = fileBufferHead;
}
// Reset fileBufferMaxAvail
void SFE_UBLOX_GNSS::clearMaxFileBufferAvail(void)
{
fileBufferMaxAvail = 0;
}
// PRIVATE: Create the file buffer. Called by .begin
boolean SFE_UBLOX_GNSS::createFileBuffer(void)
{
@@ -8569,7 +8583,7 @@ boolean SFE_UBLOX_GNSS::setNavigationFrequency(uint8_t navFreq, uint16_t maxWait
//Adjust the I2C polling timeout based on update rate
i2cPollingWait = 1000 / (((int)navFreq) * 4); //This is the number of ms to wait between checks for new I2C data
//Query the module for the latest lat/long
//Query the module
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_RATE;
packetCfg.len = 0;
@@ -8606,6 +8620,79 @@ uint8_t SFE_UBLOX_GNSS::getNavigationFrequency(uint16_t maxWait)
return (measurementRate);
}
//Set the elapsed time between GNSS measurements in milliseconds, which defines the rate
boolean SFE_UBLOX_GNSS::setMeasurementRate(uint16_t rate, uint16_t maxWait)
{
//Adjust the I2C polling timeout based on update rate
i2cPollingWait = rate / 4; //This is the number of ms to wait between checks for new I2C data
//Query the module
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_RATE;
packetCfg.len = 0;
packetCfg.startingSpot = 0;
//This will load the payloadCfg array with current settings of the given register
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (false); //If command send fails then bail
//payloadCfg is now loaded with current bytes. Change only the ones we need to
payloadCfg[0] = rate & 0xFF; //measRate LSB
payloadCfg[1] = rate >> 8; //measRate MSB
return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}
//Return the elapsed time between GNSS measurements in milliseconds, which defines the rate
uint16_t SFE_UBLOX_GNSS::getMeasurementRate(uint16_t maxWait)
{
if (packetUBXCFGRATE == NULL) initPacketUBXCFGRATE(); //Check that RAM has been allocated for the RATE data
if (packetUBXCFGRATE == NULL) //Bail if the RAM allocation failed
return 0;
if (packetUBXCFGRATE->moduleQueried.moduleQueried.bits.measRate == false)
getNavigationFrequencyInternal(maxWait);
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.measRate = false; //Since we are about to give this to user, mark this data as stale
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.all = false;
return (packetUBXCFGRATE->data.measRate);
}
//Set the ratio between the number of measurements and the number of navigation solutions. Unit is cycles. Max is 127.
boolean SFE_UBLOX_GNSS::setNavigationRate(uint16_t rate, uint16_t maxWait)
{
//Query the module
packetCfg.cls = UBX_CLASS_CFG;
packetCfg.id = UBX_CFG_RATE;
packetCfg.len = 0;
packetCfg.startingSpot = 0;
//This will load the payloadCfg array with current settings of the given register
if (sendCommand(&packetCfg, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED) // We are expecting data and an ACK
return (false); //If command send fails then bail
//payloadCfg is now loaded with current bytes. Change only the ones we need to
payloadCfg[2] = rate & 0xFF; //navRate LSB
payloadCfg[3] = rate >> 8; //navRate MSB
return ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
}
//Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles
uint16_t SFE_UBLOX_GNSS::getNavigationRate(uint16_t maxWait)
{
if (packetUBXCFGRATE == NULL) initPacketUBXCFGRATE(); //Check that RAM has been allocated for the RATE data
if (packetUBXCFGRATE == NULL) //Bail if the RAM allocation failed
return 0;
if (packetUBXCFGRATE->moduleQueried.moduleQueried.bits.navRate == false)
getNavigationFrequencyInternal(maxWait);
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.navRate = false; //Since we are about to give this to user, mark this data as stale
packetUBXCFGRATE->moduleQueried.moduleQueried.bits.all = false;
return (packetUBXCFGRATE->data.navRate);
}
// ***** DOP Helper Functions
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)
packetUBXNAVPVT->data.sec);
int32_t us = packetUBXNAVPVT->data.nano / 1000;
microsecond = (uint32_t)us;
// ajust t if nano is negative
// adjust t if nano is negative
if(us < 0) {
microsecond = (uint32_t)(us + 1000000);
t--;
@@ -9664,7 +9751,7 @@ boolean SFE_UBLOX_GNSS::getSensorFusionMeasurement(UBX_ESF_MEAS_sensorData_t *se
if (packetUBXESFMEAS == NULL) //Bail if the RAM allocation failed
return (false);
if (packetUBXESFMEAS->moduleQueried.moduleQueried.bits.data & (1 << sensor) == 0)
if (packetUBXESFMEAS->moduleQueried.moduleQueried.bits.data & ((1 << sensor) == 0))
getESFMEAS(maxWait);
packetUBXESFMEAS->moduleQueried.moduleQueried.bits.data &= ~(1 << sensor); //Since we are about to give this to user, mark this data as stale
packetUBXESFMEAS->moduleQueried.moduleQueried.bits.all = false;
@@ -9684,7 +9771,7 @@ boolean SFE_UBLOX_GNSS::getRawSensorMeasurement(UBX_ESF_RAW_sensorData_t *sensor
if (packetUBXESFRAW == NULL) //Bail if the RAM allocation failed
return (false);
if (packetUBXESFRAW->moduleQueried.moduleQueried.bits.data & (1 << sensor) == 0)
if (packetUBXESFRAW->moduleQueried.moduleQueried.bits.data & ((1 << sensor) == 0))
getESFRAW(maxWait);
packetUBXESFRAW->moduleQueried.moduleQueried.bits.data &= ~(1 << sensor); //Since we are about to give this to user, mark this data as stale
packetUBXESFRAW->moduleQueried.moduleQueried.bits.all = false;
@@ -9706,7 +9793,7 @@ boolean SFE_UBLOX_GNSS::getSensorFusionStatus(UBX_ESF_STATUS_sensorStatus_t *sen
if (packetUBXESFSTATUS == NULL) //Bail if the RAM allocation failed
return (false);
if (packetUBXESFSTATUS->moduleQueried.moduleQueried.bits.status & (1 << sensor) == 0)
if (packetUBXESFSTATUS->moduleQueried.moduleQueried.bits.status & ((1 << sensor) == 0))
getESFSTATUS(maxWait);
packetUBXESFSTATUS->moduleQueried.moduleQueried.bits.status &= ~(1 << sensor); //Since we are about to give this to user, mark this data as stale
packetUBXESFSTATUS->moduleQueried.moduleQueried.bits.all = false;
+7 -1
View File
@@ -567,6 +567,8 @@ public:
uint16_t extractFileBufferData(uint8_t *destination, uint16_t numBytes); // Extract numBytes of data from the file buffer. Copy it to destination. It is the user's responsibility to ensure destination is large enough.
uint16_t fileBufferAvailable(void); // Returns the number of bytes available in file buffer which are waiting to be read
uint16_t getMaxFileBufferAvail(void); // Returns the maximum number of bytes which the file buffer has contained. Handy for checking the buffer is large enough to handle all the incoming data.
void clearFileBuffer(void); // Empty the file buffer - discard all contents
void clearMaxFileBufferAvail(void); // Reset fileBufferMaxAvail
// Specific commands
@@ -904,6 +906,10 @@ public:
boolean setNavigationFrequency(uint8_t navFreq, uint16_t maxWait = defaultMaxWait); //Set the number of nav solutions sent per second
uint8_t getNavigationFrequency(uint16_t maxWait = defaultMaxWait); //Get the number of nav solutions sent per second currently being output by module
boolean setMeasurementRate(uint16_t rate, uint16_t maxWait = defaultMaxWait); //Set the elapsed time between GNSS measurements in milliseconds, which defines the rate
uint16_t getMeasurementRate(uint16_t maxWait = defaultMaxWait); //Return the elapsed time between GNSS measurements in milliseconds
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
uint16_t getNavigationRate(uint16_t maxWait = defaultMaxWait); //Return the ratio between the number of measurements and the number of navigation solutions. Unit is cycles
// Helper functions for DOP
@@ -1175,7 +1181,7 @@ private:
//Limit checking of new data to every X ms
//If we are expecting an update every X Hz then we should check every half that amount of time
//Otherwise we may block ourselves from seeing new data
uint8_t i2cPollingWait = 100; //Default to 100ms. Adjusted when user calls setNavigationFrequency() or setHNRNavigationRate()
uint8_t i2cPollingWait = 100; //Default to 100ms. Adjusted when user calls setNavigationFrequency() or setHNRNavigationRate() or setMeasurementRate()
unsigned long lastCheck = 0;