Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.

Commit 8568540

Browse files
committed
This changes allow to use the SFE_UBLOX_GPS to be used as data storage and disable the implicit update of data that happened previously even with autoPVT set to true
Changes: - add implicitUpdate parameter to setAutoPVT to control when the actual processing of the data happens - add assumeAutoPVT method for use-cases where the receiver can't be controlled (no UART Tx line from MCU to receiver) - change getPVT to respect autoPVTImplicitUpdate==false - remove "virtual" from getPVT as it is not required anymore after the above changes
1 parent 5e6e1b3 commit 8568540

File tree

2 files changed

+33
-3
lines changed

2 files changed

+33
-3
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1174,9 +1174,29 @@ uint8_t SFE_UBLOX_GPS::getNavigationFrequency(uint16_t maxWait)
11741174
return (measurementRate);
11751175
}
11761176

1177+
//In case no config access to the GPS is possible and PVT is send cyclically already
1178+
//set config to suitable parameters
1179+
boolean SFE_UBLOX_GPS::assumeAutoPVT(boolean enabled, boolean implicitUpdate)
1180+
{
1181+
boolean changes = autoPVT != enabled || autoPVTImplicitUpdate != implicitUpdate;
1182+
if(changes)
1183+
{
1184+
autoPVT = enabled;
1185+
autoPVTImplicitUpdate = implicitUpdate;
1186+
}
1187+
return changes;
1188+
}
1189+
11771190
//Enable or disable automatic navigation message generation by the GPS. This changes the way getPVT
11781191
//works.
11791192
boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, uint16_t maxWait)
1193+
{
1194+
return setAutoPVT(enable, true, maxWait);
1195+
}
1196+
1197+
//Enable or disable automatic navigation message generation by the GPS. This changes the way getPVT
1198+
//works.
1199+
boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16_t maxWait)
11801200
{
11811201
packetCfg.cls = UBX_CLASS_CFG;
11821202
packetCfg.id = UBX_CFG_MSG;
@@ -1187,8 +1207,10 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, uint16_t maxWait)
11871207
payloadCfg[2] = enable ? 1 : 0; // rate relative to navigation freq.
11881208

11891209
bool ok = sendCommand(packetCfg, maxWait);
1190-
if (ok)
1210+
if (ok){
11911211
autoPVT = enable;
1212+
autoPVTImplicitUpdate = implicitUpdate;
1213+
}
11921214
moduleQueried.all = false;
11931215
return ok;
11941216
}
@@ -1276,12 +1298,17 @@ uint8_t SFE_UBLOX_GPS::getSecond(uint16_t maxWait)
12761298
//Get the latest Position/Velocity/Time solution and fill all global variables
12771299
boolean SFE_UBLOX_GPS::getPVT(uint16_t maxWait)
12781300
{
1279-
if (autoPVT)
1301+
if (autoPVT && autoPVTImplicitUpdate)
12801302
{
12811303
//The GPS is automatically reporting, we just check whether we got unread data
12821304
checkUblox();
12831305
return moduleQueried.all;
12841306
}
1307+
else if(autoPVT && !autoPVTImplicitUpdate)
1308+
{
1309+
//Someone else has to call checkUblox for us...
1310+
return (false);
1311+
}
12851312
else
12861313
{
12871314
//The GPS is not automatically reporting navigation position so we have to poll explicitly

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,8 +226,10 @@ class SFE_UBLOX_GPS
226226

227227
boolean waitForResponse(uint8_t requestedClass, uint8_t requestedID, uint16_t maxTime = 250); //Poll the module until and ack is received
228228

229+
boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
229230
boolean setAutoPVT(boolean enabled, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency
230-
virtual boolean getPVT(uint16_t maxWait = 1000); //Query module for latest group of datums and load global vars: lat, long, alt, speed, SIV, accuracies, etc. If autoPVT is disabled, performs an explicit poll and waits, if enabled does not block. Retruns true if new PVT is available.
231+
boolean setAutoPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency, with implicitUpdate == false accessing stale data will not issue parsing of data in the rxbuffer of your interface, instead you have to call checkUblox when you want to perform an update
232+
boolean getPVT(uint16_t maxWait = 1000); //Query module for latest group of datums and load global vars: lat, long, alt, speed, SIV, accuracies, etc. If autoPVT is disabled, performs an explicit poll and waits, if enabled does not block. Retruns true if new PVT is available.
231233

232234
int32_t getLatitude(uint16_t maxWait = 250); //Returns the current latitude in degrees * 10^-7. Auto selects between HighPrecision and Regular depending on ability of module.
233235
int32_t getLongitude(uint16_t maxWait = 250); //Returns the current longitude in degrees * 10-7. Auto selects between HighPrecision and Regular depending on ability of module.
@@ -399,6 +401,7 @@ class SFE_UBLOX_GPS
399401
const uint8_t I2C_POLLING_WAIT_MS = 25; //Limit checking of new characters to every X ms
400402
unsigned long lastCheck = 0;
401403
boolean autoPVT = false; //Whether autoPVT is enabled or not
404+
boolean autoPVTImplicitUpdate = true; // Whether autoPVT is triggered by accessing stale data (=true) or by a call to checkUblox (=false)
402405
boolean commandAck = false; //This goes true after we send a command and it's ack'd
403406
uint8_t ubxFrameCounter;
404407

0 commit comments

Comments
 (0)