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

Commit 9f72926

Browse files
committed
autoHPPOSLLH functions added - work in progress
1 parent 2816b95 commit 9f72926

File tree

3 files changed

+139
-8
lines changed

3 files changed

+139
-8
lines changed

keywords.txt

+4
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,10 @@ getDateValid KEYWORD2
118118
getTimeValid KEYWORD2
119119

120120
getHPPOSLLH KEYWORD2
121+
assumeAutoHPPOSLLH KEYWORD2
122+
setAutoHPPOSLLH KEYWORD2
123+
flushHPPOSLLH KEYWORD2
124+
121125
getTimeOfWeek KEYWORD2
122126
getHighResLatitude KEYWORD2
123127
getHighResLatitudeHp KEYWORD2

src/SparkFun_Ublox_Arduino_Library.cpp

+126-5
Original file line numberDiff line numberDiff line change
@@ -2291,6 +2291,48 @@ boolean SFE_UBLOX_GPS::setAutoPVT(boolean enable, boolean implicitUpdate, uint16
22912291
return ok;
22922292
}
22932293

2294+
//In case no config access to the GPS is possible and HPPOSLLH is send cyclically already
2295+
//set config to suitable parameters
2296+
boolean SFE_UBLOX_GPS::assumeAutoHPPOSLLH(boolean enabled, boolean implicitUpdate)
2297+
{
2298+
boolean changes = autoHPPOSLLH != enabled || autoHPPOSLLHImplicitUpdate != implicitUpdate;
2299+
if (changes)
2300+
{
2301+
autoHPPOSLLH = enabled;
2302+
autoHPPOSLLHImplicitUpdate = implicitUpdate;
2303+
}
2304+
return changes;
2305+
}
2306+
2307+
//Enable or disable automatic navigation message generation by the GPS. This changes the way getHPPOSLLH
2308+
//works.
2309+
boolean SFE_UBLOX_GPS::setAutoHPPOSLLH(boolean enable, uint16_t maxWait)
2310+
{
2311+
return setAutoHPPOSLLH(enable, true, maxWait);
2312+
}
2313+
2314+
//Enable or disable automatic navigation message generation by the GPS. This changes the way getHPPOSLLH
2315+
//works.
2316+
boolean SFE_UBLOX_GPS::setAutoHPPOSLLH(boolean enable, boolean implicitUpdate, uint16_t maxWait)
2317+
{
2318+
packetCfg.cls = UBX_CLASS_CFG;
2319+
packetCfg.id = UBX_CFG_MSG;
2320+
packetCfg.len = 3;
2321+
packetCfg.startingSpot = 0;
2322+
payloadCfg[0] = UBX_CLASS_NAV;
2323+
payloadCfg[1] = UBX_NAV_HPPOSLLH;
2324+
payloadCfg[2] = enable ? 1 : 0; // rate relative to navigation freq.
2325+
2326+
boolean ok = ((sendCommand(&packetCfg, maxWait)) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
2327+
if (ok)
2328+
{
2329+
autoHPPOSLLH = enable;
2330+
autoHPPOSLLHImplicitUpdate = implicitUpdate;
2331+
}
2332+
highResModuleQueried.all = false;
2333+
return ok;
2334+
}
2335+
22942336
//Configure a given message type for a given port (UART1, I2C, SPI, etc)
22952337
boolean SFE_UBLOX_GPS::configureMessage(uint8_t msgClass, uint8_t msgID, uint8_t portID, uint8_t sendRate, uint16_t maxWait)
22962338
{
@@ -2955,6 +2997,8 @@ int32_t SFE_UBLOX_GPS::getHighResLatitude(uint16_t maxWait /* = 250*/)
29552997
if (highResModuleQueried.highResLatitude == false)
29562998
getHPPOSLLH(maxWait);
29572999
highResModuleQueried.highResLatitude = false; //Since we are about to give this to user, mark this data as stale
3000+
highResModuleQueried.all = false;
3001+
29583002
return (highResLatitude);
29593003
}
29603004

@@ -2963,6 +3007,8 @@ int8_t SFE_UBLOX_GPS::getHighResLatitudeHp(uint16_t maxWait /* = 250*/)
29633007
if (highResModuleQueried.highResLatitudeHp == false)
29643008
getHPPOSLLH(maxWait);
29653009
highResModuleQueried.highResLatitudeHp = false; //Since we are about to give this to user, mark this data as stale
3010+
highResModuleQueried.all = false;
3011+
29663012
return (highResLatitudeHp);
29673013
}
29683014

@@ -2971,6 +3017,8 @@ int32_t SFE_UBLOX_GPS::getHighResLongitude(uint16_t maxWait /* = 250*/)
29713017
if (highResModuleQueried.highResLongitude == false)
29723018
getHPPOSLLH(maxWait);
29733019
highResModuleQueried.highResLongitude = false; //Since we are about to give this to user, mark this data as stale
3020+
highResModuleQueried.all = false;
3021+
29743022
return (highResLongitude);
29753023
}
29763024

@@ -2979,6 +3027,8 @@ int8_t SFE_UBLOX_GPS::getHighResLongitudeHp(uint16_t maxWait /* = 250*/)
29793027
if (highResModuleQueried.highResLongitudeHp == false)
29803028
getHPPOSLLH(maxWait);
29813029
highResModuleQueried.highResLongitudeHp = false; //Since we are about to give this to user, mark this data as stale
3030+
highResModuleQueried.all = false;
3031+
29823032
return (highResLongitudeHp);
29833033
}
29843034

@@ -2987,6 +3037,8 @@ int32_t SFE_UBLOX_GPS::getElipsoid(uint16_t maxWait /* = 250*/)
29873037
if (highResModuleQueried.elipsoid == false)
29883038
getHPPOSLLH(maxWait);
29893039
highResModuleQueried.elipsoid = false; //Since we are about to give this to user, mark this data as stale
3040+
highResModuleQueried.all = false;
3041+
29903042
return (elipsoid);
29913043
}
29923044

@@ -2995,6 +3047,8 @@ int8_t SFE_UBLOX_GPS::getElipsoidHp(uint16_t maxWait /* = 250*/)
29953047
if (highResModuleQueried.elipsoidHp == false)
29963048
getHPPOSLLH(maxWait);
29973049
highResModuleQueried.elipsoidHp = false; //Since we are about to give this to user, mark this data as stale
3050+
highResModuleQueried.all = false;
3051+
29983052
return (elipsoidHp);
29993053
}
30003054

@@ -3003,6 +3057,8 @@ int32_t SFE_UBLOX_GPS::getMeanSeaLevel(uint16_t maxWait /* = 250*/)
30033057
if (highResModuleQueried.meanSeaLevel == false)
30043058
getHPPOSLLH(maxWait);
30053059
highResModuleQueried.meanSeaLevel = false; //Since we are about to give this to user, mark this data as stale
3060+
highResModuleQueried.all = false;
3061+
30063062
return (meanSeaLevel);
30073063
}
30083064

@@ -3011,6 +3067,8 @@ int8_t SFE_UBLOX_GPS::getMeanSeaLevelHp(uint16_t maxWait /* = 250*/)
30113067
if (highResModuleQueried.meanSeaLevelHp == false)
30123068
getHPPOSLLH(maxWait);
30133069
highResModuleQueried.meanSeaLevelHp = false; //Since we are about to give this to user, mark this data as stale
3070+
highResModuleQueried.all = false;
3071+
30143072
return (meanSeaLevelHp);
30153073
}
30163074

@@ -3020,6 +3078,8 @@ int32_t SFE_UBLOX_GPS::getGeoidSeparation(uint16_t maxWait /* = 250*/)
30203078
if (highResModuleQueried.geoidSeparation == false)
30213079
getHPPOSLLH(maxWait);
30223080
highResModuleQueried.geoidSeparation = false; //Since we are about to give this to user, mark this data as stale
3081+
highResModuleQueried.all = false;
3082+
30233083
return (geoidSeparation);
30243084
}
30253085

@@ -3028,6 +3088,8 @@ uint32_t SFE_UBLOX_GPS::getHorizontalAccuracy(uint16_t maxWait /* = 250*/)
30283088
if (highResModuleQueried.horizontalAccuracy == false)
30293089
getHPPOSLLH(maxWait);
30303090
highResModuleQueried.horizontalAccuracy = false; //Since we are about to give this to user, mark this data as stale
3091+
highResModuleQueried.all = false;
3092+
30313093
return (horizontalAccuracy);
30323094
}
30333095

@@ -3036,17 +3098,57 @@ uint32_t SFE_UBLOX_GPS::getVerticalAccuracy(uint16_t maxWait /* = 250*/)
30363098
if (highResModuleQueried.verticalAccuracy == false)
30373099
getHPPOSLLH(maxWait);
30383100
highResModuleQueried.verticalAccuracy = false; //Since we are about to give this to user, mark this data as stale
3101+
highResModuleQueried.all = false;
3102+
30393103
return (verticalAccuracy);
30403104
}
30413105

30423106
boolean SFE_UBLOX_GPS::getHPPOSLLH(uint16_t maxWait)
30433107
{
3044-
//The GPS is not automatically reporting navigation position so we have to poll explicitly
3045-
packetCfg.cls = UBX_CLASS_NAV;
3046-
packetCfg.id = UBX_NAV_HPPOSLLH;
3047-
packetCfg.len = 0;
3108+
if (autoHPPOSLLH && autoHPPOSLLHImplicitUpdate)
3109+
{
3110+
//The GPS is automatically reporting, we just check whether we got unread data
3111+
if (_printDebug == true)
3112+
{
3113+
_debugSerial->println(F("getHPPOSLLH: Autoreporting"));
3114+
}
3115+
checkUbloxInternal(&packetCfg, UBX_CLASS_NAV, UBX_NAV_HPPOSLLH);
3116+
return highResModuleQueried.all;
3117+
}
3118+
else if (autoHPPOSLLH && !autoHPPOSLLHImplicitUpdate)
3119+
{
3120+
//Someone else has to call checkUblox for us...
3121+
if (_printDebug == true)
3122+
{
3123+
_debugSerial->println(F("getHPPOSLLH: Exit immediately"));
3124+
}
3125+
return (false);
3126+
}
3127+
else
3128+
{
3129+
if (_printDebug == true)
3130+
{
3131+
_debugSerial->println(F("getHPPOSLLH: Polling"));
3132+
}
30483133

3049-
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_RECEIVED); // We are only expecting data (no ACK)
3134+
//The GPS is not automatically reporting navigation position so we have to poll explicitly
3135+
packetCfg.cls = UBX_CLASS_NAV;
3136+
packetCfg.id = UBX_NAV_HPPOSLLH;
3137+
packetCfg.len = 0;
3138+
3139+
//The data is parsed as part of processing the response
3140+
sfe_ublox_status_e retVal = sendCommand(&packetCfg, maxWait);
3141+
3142+
if (retVal == SFE_UBLOX_STATUS_DATA_RECEIVED)
3143+
return (true);
3144+
3145+
if (_printDebug == true)
3146+
{
3147+
_debugSerial->print(F("getHPPOSLLH retVal: "));
3148+
_debugSerial->println(statusString(retVal));
3149+
}
3150+
return (false);
3151+
}
30503152
}
30513153

30523154
//Get the current 3D high precision positional accuracy - a fun thing to watch
@@ -3287,6 +3389,25 @@ void SFE_UBLOX_GPS::flushPVT()
32873389
moduleQueried.pDOP = false;
32883390
}
32893391

3392+
//Mark all the HPPOSLLH data as read/stale. This is handy to get data alignment after CRC failure
3393+
void SFE_UBLOX_GPS::flushHPPOSLLH()
3394+
{
3395+
//Mark all datums as stale (read before)
3396+
highResModuleQueried.all = false;
3397+
highResModuleQueried.highResLatitude = false;
3398+
highResModuleQueried.highResLatitudeHp = false;
3399+
highResModuleQueried.highResLongitude = false;
3400+
highResModuleQueried.highResLongitudeHp = false;
3401+
highResModuleQueried.elipsoid = false;
3402+
highResModuleQueried.elipsoidHp = false;
3403+
highResModuleQueried.meanSeaLevel = false;
3404+
highResModuleQueried.meanSeaLevelHp = false;
3405+
highResModuleQueried.geoidSeparation = false;
3406+
highResModuleQueried.horizontalAccuracy = false;
3407+
highResModuleQueried.verticalAccuracy = false;
3408+
//moduleQueried.gpsiTOW = false; // this can arrive via HPPOS too.
3409+
}
3410+
32903411
//Relative Positioning Information in NED frame
32913412
//Returns true if commands was successful
32923413
boolean SFE_UBLOX_GPS::getRELPOSNED(uint16_t maxWait)

src/SparkFun_Ublox_Arduino_Library.h

+9-3
Original file line numberDiff line numberDiff line change
@@ -461,7 +461,7 @@ class SFE_UBLOX_GPS
461461
//Control the size of the internal I2C transaction amount
462462
void setI2CTransactionSize(uint8_t bufferSize);
463463
uint8_t getI2CTransactionSize(void);
464-
464+
465465
//Set the max number of bytes set in a given I2C transaction
466466
uint8_t i2cTransactionSize = 32; //Default to ATmega328 limit
467467

@@ -517,10 +517,14 @@ class SFE_UBLOX_GPS
517517

518518
boolean assumeAutoPVT(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and PVT is send cyclically already
519519
boolean setAutoPVT(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic PVT reports at the navigation frequency
520-
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.
520+
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. Returns true if new PVT is available.
521521
boolean setAutoPVT(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //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
522-
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.
522+
boolean assumeAutoHPPOSLLH(boolean enabled, boolean implicitUpdate = true); //In case no config access to the GPS is possible and HPPOSLLH is send cyclically already
523+
boolean setAutoHPPOSLLH(boolean enabled, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HPPOSLLH reports at the navigation frequency
524+
boolean setAutoHPPOSLLH(boolean enabled, boolean implicitUpdate, uint16_t maxWait = defaultMaxWait); //Enable/disable automatic HPPOSLLH 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
525+
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. Returns true if new HPPOSLLH is available.
523526
void flushPVT(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
527+
void flushHPPOSLLH(); //Mark all the PVT data as read/stale. This is handy to get data alignment after CRC failure
524528

525529
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.
526530
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.
@@ -853,6 +857,8 @@ class SFE_UBLOX_GPS
853857
unsigned long lastCheck = 0;
854858
boolean autoPVT = false; //Whether autoPVT is enabled or not
855859
boolean autoPVTImplicitUpdate = true; // Whether autoPVT is triggered by accessing stale data (=true) or by a call to checkUblox (=false)
860+
boolean autoHPPOSLLH = false; //Whether autoHPPOSLLH is enabled or not
861+
boolean autoHPPOSLLHImplicitUpdate = true; // Whether autoHPPOSLLH is triggered by accessing stale data (=true) or by a call to checkUblox (=false)
856862
uint16_t ubxFrameCounter; //It counts all UBX frame. [Fixed header(2bytes), CLS(1byte), ID(1byte), length(2bytes), payload(x bytes), checksums(2bytes)]
857863

858864
uint8_t rollingChecksumA; //Rolls forward as we receive incoming bytes. Checked against the last two A/B checksum bytes

0 commit comments

Comments
 (0)