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

Corrected the default maxWait values (for getPVT etc.) #62

Merged
merged 1 commit into from
Dec 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 25 additions & 3 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -575,13 +575,13 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
//We don't want to store ACK packets, just set commandAck flag
if (msg->id == UBX_ACK_ACK && msg->payload[0] == packetCfg.cls && msg->payload[1] == packetCfg.id)
{
//The ack we just received matched the CLS/ID of last packetCfg sent
//The ack we just received matched the CLS/ID of last packetCfg sent (or received)
debugPrintln((char *)"UBX ACK: Command sent/ack'd successfully");
commandAck = UBX_ACK_ACK;
}
else if (msg->id == UBX_ACK_NACK && msg->payload[0] == packetCfg.cls && msg->payload[1] == packetCfg.id)
{
//The ack we just received matched the CLS/ID of last packetCfg sent
//The ack we just received matched the CLS/ID of last packetCfg sent (or received)
debugPrintln((char *)"UBX ACK: Not-Acknowledged");
commandAck = UBX_ACK_NACK;
}
Expand Down Expand Up @@ -898,17 +898,38 @@ boolean SFE_UBLOX_GPS::waitForResponse(uint8_t requestedClass, uint8_t requested
{
//If the packet we just sent was a CFG packet then we'll get an ACK
if (commandAck == UBX_ACK_ACK)
{
if (_printDebug == true)
{
_debugSerial->print(F("ACK received after "));
_debugSerial->print(millis() - startTime);
_debugSerial->println(F(" msec"));
}
return (true); // Received an ACK
}
else if (commandAck == UBX_ACK_NACK)
{
if (_printDebug == true)
{
_debugSerial->print(F("NACK received after "));
_debugSerial->print(millis() - startTime);
_debugSerial->println(F(" msec"));
}
return (false); // Received a NACK
}
}

if (packetCfg.valid == true)
{
//Did we receive a config packet that matches the cls/id we requested?
if (packetCfg.cls == requestedClass && packetCfg.id == requestedID)
{
debugPrintln((char *)"CLS/ID match!");
if (_printDebug == true)
{
_debugSerial->print(F("CLS/ID match after "));
_debugSerial->print(millis() - startTime);
_debugSerial->println(F(" msec"));
}
return (true); //If the packet we just sent was a NAV packet then we'll just get data back
}
else
Expand Down Expand Up @@ -2152,6 +2173,7 @@ int32_t SFE_UBLOX_GPS::getLatitude(uint16_t maxWait)
if (moduleQueried.latitude == false)
getPVT(maxWait);
moduleQueried.latitude = false; //Since we are about to give this to user, mark this data as stale
moduleQueried.all = false;

return (latitude);
}
Expand Down
90 changes: 49 additions & 41 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -287,39 +287,47 @@ class SFE_UBLOX_GPS

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

boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
boolean setAutoPVT(boolean enabled, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency
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.
// getPVT will only return data once in each navigation cycle. By default, that is once per second.
// Therefore we should set getPVTmaxWait to slightly longer than that.
// If you change the navigation frequency to (e.g.) 4Hz using setNavigationFrequency(4)
// then you should use a shorter maxWait for getPVT. 300msec would be about right: getPVT(300)
// The same is true for getHPPOSLLH.
#define getPVTmaxWait 1100 // Default maxWait for getPVT and all functions which call it
#define getHPPOSLLHmaxWait 1100 // Default maxWait for getHPPOSLLH and all functions which call it

boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
boolean setAutoPVT(boolean enabled, uint16_t maxWait = 250); //Enable/disable automatic PVT reports at the navigation frequency
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.
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
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.

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.
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.
int32_t getAltitude(uint16_t maxWait = 250); //Returns the current altitude in mm above ellipsoid
int32_t getAltitudeMSL(uint16_t maxWait = 250); //Returns the current altitude in mm above mean sea level
uint8_t getSIV(uint16_t maxWait = 250); //Returns number of sats used in fix
uint8_t getFixType(uint16_t maxWait = 250); //Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning
uint8_t getCarrierSolutionType(uint16_t maxWait = 250); //Returns RTK solution: 0=no, 1=float solution, 2=fixed solution
int32_t getGroundSpeed(uint16_t maxWait = 250); //Returns speed in mm/s
int32_t getHeading(uint16_t maxWait = 250); //Returns heading in degrees * 10^-7
uint16_t getPDOP(uint16_t maxWait = 250); //Returns positional dillution of precision * 10^-2
uint16_t getYear(uint16_t maxWait = 250);
uint8_t getMonth(uint16_t maxWait = 250);
uint8_t getDay(uint16_t maxWait = 250);
uint8_t getHour(uint16_t maxWait = 250);
uint8_t getMinute(uint16_t maxWait = 250);
uint8_t getSecond(uint16_t maxWait = 250);
uint16_t getMillisecond(uint16_t maxWait = 250);
int32_t getNanosecond(uint16_t maxWait = 250);

uint32_t getTimeOfWeek(uint16_t maxWait = 250);
int32_t getHighResLatitude(uint16_t maxWait = 250);
int32_t getHighResLongitude(uint16_t maxWait = 250);
int32_t getElipsoid(uint16_t maxWait = 250);
int32_t getMeanSeaLevel(uint16_t maxWait = 250);
int32_t getGeoidSeparation(uint16_t maxWait = 250);
uint32_t getHorizontalAccuracy(uint16_t maxWait = 250);
uint32_t getVerticalAccuracy(uint16_t maxWait = 250);
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.

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.
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.
int32_t getAltitude(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above ellipsoid
int32_t getAltitudeMSL(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above mean sea level
uint8_t getSIV(uint16_t maxWait = getPVTmaxWait); //Returns number of sats used in fix
uint8_t getFixType(uint16_t maxWait = getPVTmaxWait); //Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning
uint8_t getCarrierSolutionType(uint16_t maxWait = getPVTmaxWait); //Returns RTK solution: 0=no, 1=float solution, 2=fixed solution
int32_t getGroundSpeed(uint16_t maxWait = getPVTmaxWait); //Returns speed in mm/s
int32_t getHeading(uint16_t maxWait = getPVTmaxWait); //Returns heading in degrees * 10^-7
uint16_t getPDOP(uint16_t maxWait = getPVTmaxWait); //Returns positional dillution of precision * 10^-2
uint16_t getYear(uint16_t maxWait = getPVTmaxWait);
uint8_t getMonth(uint16_t maxWait = getPVTmaxWait);
uint8_t getDay(uint16_t maxWait = getPVTmaxWait);
uint8_t getHour(uint16_t maxWait = getPVTmaxWait);
uint8_t getMinute(uint16_t maxWait = getPVTmaxWait);
uint8_t getSecond(uint16_t maxWait = getPVTmaxWait);
uint16_t getMillisecond(uint16_t maxWait = getPVTmaxWait);
int32_t getNanosecond(uint16_t maxWait = getPVTmaxWait);
uint32_t getTimeOfWeek(uint16_t maxWait = getPVTmaxWait);

int32_t getHighResLatitude(uint16_t maxWait = getHPPOSLLHmaxWait);
int32_t getHighResLongitude(uint16_t maxWait = getHPPOSLLHmaxWait);
int32_t getElipsoid(uint16_t maxWait = getHPPOSLLHmaxWait);
int32_t getMeanSeaLevel(uint16_t maxWait = getHPPOSLLHmaxWait);
int32_t getGeoidSeparation(uint16_t maxWait = getHPPOSLLHmaxWait);
uint32_t getHorizontalAccuracy(uint16_t maxWait = getHPPOSLLHmaxWait);
uint32_t getVerticalAccuracy(uint16_t maxWait = getHPPOSLLHmaxWait);

//Port configurations
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
Expand Down Expand Up @@ -366,30 +374,30 @@ class SFE_UBLOX_GPS

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

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,
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,

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

boolean getRELPOSNED(uint16_t maxWait = 1000); //Get Relative Positioning Information of the NED frame
boolean getRELPOSNED(uint16_t maxWait = 1100); //Get Relative Positioning Information of the NED frame

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

//Support for geofences
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
boolean clearGeofences(uint16_t maxWait = 2000); //Clears all geofences
boolean getGeofenceState(geofenceState &currentGeofenceState, uint16_t maxWait = 2000); //Returns the combined geofence state
boolean clearAntPIO(uint16_t maxWait = 2000); //Clears the antenna control pin settings to release the PIOs
geofenceParams currentGeofenceParams; // Global to store the geofence parameters
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
boolean clearGeofences(uint16_t maxWait = 1100); //Clears all geofences
boolean getGeofenceState(geofenceState &currentGeofenceState, uint16_t maxWait = 1100); //Returns the combined geofence state
boolean clearAntPIO(uint16_t maxWait = 1100); //Clears the antenna control pin settings to release the PIOs
geofenceParams currentGeofenceParams; // Global to store the geofence parameters

boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 2000);
boolean powerSaveMode(bool power_save = true, uint16_t maxWait = 1100);

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

//Survey-in specific controls
struct svinStructure
Expand Down