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

Commit bd8678b

Browse files
committed
Corrected the default maxWait values (for getPVT etc.)
1 parent dc9a9d5 commit bd8678b

File tree

2 files changed

+74
-44
lines changed

2 files changed

+74
-44
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -575,13 +575,13 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
575575
//We don't want to store ACK packets, just set commandAck flag
576576
if (msg->id == UBX_ACK_ACK && msg->payload[0] == packetCfg.cls && msg->payload[1] == packetCfg.id)
577577
{
578-
//The ack we just received matched the CLS/ID of last packetCfg sent
578+
//The ack we just received matched the CLS/ID of last packetCfg sent (or received)
579579
debugPrintln((char *)"UBX ACK: Command sent/ack'd successfully");
580580
commandAck = UBX_ACK_ACK;
581581
}
582582
else if (msg->id == UBX_ACK_NACK && msg->payload[0] == packetCfg.cls && msg->payload[1] == packetCfg.id)
583583
{
584-
//The ack we just received matched the CLS/ID of last packetCfg sent
584+
//The ack we just received matched the CLS/ID of last packetCfg sent (or received)
585585
debugPrintln((char *)"UBX ACK: Not-Acknowledged");
586586
commandAck = UBX_ACK_NACK;
587587
}
@@ -898,17 +898,38 @@ boolean SFE_UBLOX_GPS::waitForResponse(uint8_t requestedClass, uint8_t requested
898898
{
899899
//If the packet we just sent was a CFG packet then we'll get an ACK
900900
if (commandAck == UBX_ACK_ACK)
901+
{
902+
if (_printDebug == true)
903+
{
904+
_debugSerial->print(F("ACK received after "));
905+
_debugSerial->print(millis() - startTime);
906+
_debugSerial->println(F(" msec"));
907+
}
901908
return (true); // Received an ACK
909+
}
902910
else if (commandAck == UBX_ACK_NACK)
911+
{
912+
if (_printDebug == true)
913+
{
914+
_debugSerial->print(F("NACK received after "));
915+
_debugSerial->print(millis() - startTime);
916+
_debugSerial->println(F(" msec"));
917+
}
903918
return (false); // Received a NACK
919+
}
904920
}
905921

906922
if (packetCfg.valid == true)
907923
{
908924
//Did we receive a config packet that matches the cls/id we requested?
909925
if (packetCfg.cls == requestedClass && packetCfg.id == requestedID)
910926
{
911-
debugPrintln((char *)"CLS/ID match!");
927+
if (_printDebug == true)
928+
{
929+
_debugSerial->print(F("CLS/ID match after "));
930+
_debugSerial->print(millis() - startTime);
931+
_debugSerial->println(F(" msec"));
932+
}
912933
return (true); //If the packet we just sent was a NAV packet then we'll just get data back
913934
}
914935
else
@@ -2152,6 +2173,7 @@ int32_t SFE_UBLOX_GPS::getLatitude(uint16_t maxWait)
21522173
if (moduleQueried.latitude == false)
21532174
getPVT(maxWait);
21542175
moduleQueried.latitude = false; //Since we are about to give this to user, mark this data as stale
2176+
moduleQueried.all = false;
21552177

21562178
return (latitude);
21572179
}

src/SparkFun_Ublox_Arduino_Library.h

Lines changed: 49 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -287,39 +287,47 @@ class SFE_UBLOX_GPS
287287

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

290-
boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
291-
boolean setAutoPVT(boolean enabled, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency
292-
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.
290+
// getPVT will only return data once in each navigation cycle. By default, that is once per second.
291+
// Therefore we should set getPVTmaxWait to slightly longer than that.
292+
// If you change the navigation frequency to (e.g.) 4Hz using setNavigationFrequency(4)
293+
// then you should use a shorter maxWait for getPVT. 300msec would be about right: getPVT(300)
294+
// The same is true for getHPPOSLLH.
295+
#define getPVTmaxWait 1100 // Default maxWait for getPVT and all functions which call it
296+
#define getHPPOSLLHmaxWait 1100 // Default maxWait for getHPPOSLLH and all functions which call it
297+
298+
boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
299+
boolean setAutoPVT(boolean enabled, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency
300+
boolean getPVT(uint16_t maxWait = getPVTmaxWait); //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.
293301
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
294-
boolean getHPPOSLLH(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.
295-
296-
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.
297-
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.
298-
int32_t getAltitude(uint16_t maxWait = 250); //Returns the current altitude in mm above ellipsoid
299-
int32_t getAltitudeMSL(uint16_t maxWait = 250); //Returns the current altitude in mm above mean sea level
300-
uint8_t getSIV(uint16_t maxWait = 250); //Returns number of sats used in fix
301-
uint8_t getFixType(uint16_t maxWait = 250); //Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning
302-
uint8_t getCarrierSolutionType(uint16_t maxWait = 250); //Returns RTK solution: 0=no, 1=float solution, 2=fixed solution
303-
int32_t getGroundSpeed(uint16_t maxWait = 250); //Returns speed in mm/s
304-
int32_t getHeading(uint16_t maxWait = 250); //Returns heading in degrees * 10^-7
305-
uint16_t getPDOP(uint16_t maxWait = 250); //Returns positional dillution of precision * 10^-2
306-
uint16_t getYear(uint16_t maxWait = 250);
307-
uint8_t getMonth(uint16_t maxWait = 250);
308-
uint8_t getDay(uint16_t maxWait = 250);
309-
uint8_t getHour(uint16_t maxWait = 250);
310-
uint8_t getMinute(uint16_t maxWait = 250);
311-
uint8_t getSecond(uint16_t maxWait = 250);
312-
uint16_t getMillisecond(uint16_t maxWait = 250);
313-
int32_t getNanosecond(uint16_t maxWait = 250);
314-
315-
uint32_t getTimeOfWeek(uint16_t maxWait = 250);
316-
int32_t getHighResLatitude(uint16_t maxWait = 250);
317-
int32_t getHighResLongitude(uint16_t maxWait = 250);
318-
int32_t getElipsoid(uint16_t maxWait = 250);
319-
int32_t getMeanSeaLevel(uint16_t maxWait = 250);
320-
int32_t getGeoidSeparation(uint16_t maxWait = 250);
321-
uint32_t getHorizontalAccuracy(uint16_t maxWait = 250);
322-
uint32_t getVerticalAccuracy(uint16_t maxWait = 250);
302+
boolean getHPPOSLLH(uint16_t maxWait = getHPPOSLLHmaxWait); //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.
303+
304+
int32_t getLatitude(uint16_t maxWait = getPVTmaxWait); //Returns the current latitude in degrees * 10^-7. Auto selects between HighPrecision and Regular depending on ability of module.
305+
int32_t getLongitude(uint16_t maxWait = getPVTmaxWait); //Returns the current longitude in degrees * 10-7. Auto selects between HighPrecision and Regular depending on ability of module.
306+
int32_t getAltitude(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above ellipsoid
307+
int32_t getAltitudeMSL(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above mean sea level
308+
uint8_t getSIV(uint16_t maxWait = getPVTmaxWait); //Returns number of sats used in fix
309+
uint8_t getFixType(uint16_t maxWait = getPVTmaxWait); //Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning
310+
uint8_t getCarrierSolutionType(uint16_t maxWait = getPVTmaxWait); //Returns RTK solution: 0=no, 1=float solution, 2=fixed solution
311+
int32_t getGroundSpeed(uint16_t maxWait = getPVTmaxWait); //Returns speed in mm/s
312+
int32_t getHeading(uint16_t maxWait = getPVTmaxWait); //Returns heading in degrees * 10^-7
313+
uint16_t getPDOP(uint16_t maxWait = getPVTmaxWait); //Returns positional dillution of precision * 10^-2
314+
uint16_t getYear(uint16_t maxWait = getPVTmaxWait);
315+
uint8_t getMonth(uint16_t maxWait = getPVTmaxWait);
316+
uint8_t getDay(uint16_t maxWait = getPVTmaxWait);
317+
uint8_t getHour(uint16_t maxWait = getPVTmaxWait);
318+
uint8_t getMinute(uint16_t maxWait = getPVTmaxWait);
319+
uint8_t getSecond(uint16_t maxWait = getPVTmaxWait);
320+
uint16_t getMillisecond(uint16_t maxWait = getPVTmaxWait);
321+
int32_t getNanosecond(uint16_t maxWait = getPVTmaxWait);
322+
uint32_t getTimeOfWeek(uint16_t maxWait = getPVTmaxWait);
323+
324+
int32_t getHighResLatitude(uint16_t maxWait = getHPPOSLLHmaxWait);
325+
int32_t getHighResLongitude(uint16_t maxWait = getHPPOSLLHmaxWait);
326+
int32_t getElipsoid(uint16_t maxWait = getHPPOSLLHmaxWait);
327+
int32_t getMeanSeaLevel(uint16_t maxWait = getHPPOSLLHmaxWait);
328+
int32_t getGeoidSeparation(uint16_t maxWait = getHPPOSLLHmaxWait);
329+
uint32_t getHorizontalAccuracy(uint16_t maxWait = getHPPOSLLHmaxWait);
330+
uint32_t getVerticalAccuracy(uint16_t maxWait = getHPPOSLLHmaxWait);
323331

324332
//Port configurations
325333
boolean setPortOutput(uint8_t portID, uint8_t comSettings, uint16_t maxWait = 250); //Configure a given port to output UBX, NMEA, RTCM3 or a combination thereof
@@ -366,30 +374,30 @@ class SFE_UBLOX_GPS
366374

367375
boolean getSurveyStatus(uint16_t maxWait); //Reads survey in status and sets the global variables
368376

369-
uint32_t getPositionAccuracy(uint16_t maxWait = 500); //Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P,
377+
uint32_t getPositionAccuracy(uint16_t maxWait = 1100); //Returns the 3D accuracy of the current high-precision fix, in mm. Supported on NEO-M8P, ZED-F9P,
370378

371379
uint8_t getProtocolVersionHigh(uint16_t maxWait = 500); //Returns the PROTVER XX.00 from UBX-MON-VER register
372380
uint8_t getProtocolVersionLow(uint16_t maxWait = 500); //Returns the PROTVER 00.XX from UBX-MON-VER register
373381
boolean getProtocolVersion(uint16_t maxWait = 500); //Queries module, loads low/high bytes
374382

375-
boolean getRELPOSNED(uint16_t maxWait = 1000); //Get Relative Positioning Information of the NED frame
383+
boolean getRELPOSNED(uint16_t maxWait = 1100); //Get Relative Positioning Information of the NED frame
376384

377385
void enableDebugging(Stream &debugPort = Serial); //Given a port to print to, enable debug messages
378386
void disableDebugging(void); //Turn off debug statements
379387
void debugPrint(char *message); //Safely print debug statements
380388
void debugPrintln(char *message); //Safely print debug statements
381389

382390
//Support for geofences
383-
boolean addGeofence(int32_t latitude, int32_t longitude, uint32_t radius, byte confidence = 0, byte pinPolarity = 0, byte pin = 0, uint16_t maxWait = 2000); // Add a new geofence
384-
boolean clearGeofences(uint16_t maxWait = 2000); //Clears all geofences
385-
boolean getGeofenceState(geofenceState &currentGeofenceState, uint16_t maxWait = 2000); //Returns the combined geofence state
386-
boolean clearAntPIO(uint16_t maxWait = 2000); //Clears the antenna control pin settings to release the PIOs
387-
geofenceParams currentGeofenceParams; // Global to store the geofence parameters
391+
boolean addGeofence(int32_t latitude, int32_t longitude, uint32_t radius, byte confidence = 0, byte pinPolarity = 0, byte pin = 0, uint16_t maxWait = 1100); // Add a new geofence
392+
boolean clearGeofences(uint16_t maxWait = 1100); //Clears all geofences
393+
boolean getGeofenceState(geofenceState &currentGeofenceState, uint16_t maxWait = 1100); //Returns the combined geofence state
394+
boolean clearAntPIO(uint16_t maxWait = 1100); //Clears the antenna control pin settings to release the PIOs
395+
geofenceParams currentGeofenceParams; // Global to store the geofence parameters
388396

389-
boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 2000);
397+
boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 1100);
390398

391399
//Change the dynamic platform model using UBX-CFG-NAV5
392-
boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 2000);
400+
boolean setDynamicModel(dynModel newDynamicModel = DYN_MODEL_PORTABLE, uint16_t maxWait = 1100);
393401

394402
//Survey-in specific controls
395403
struct svinStructure

0 commit comments

Comments
 (0)