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

Commit b7beb48

Browse files
committed
getSpeedAccEst, getHeadingAccEst, getInvalidLlh, getHeadVeh, getMagDec and getMagAcc functions implemented.
1 parent 25c9918 commit b7beb48

File tree

3 files changed

+98
-8
lines changed

3 files changed

+98
-8
lines changed

keywords.txt

+6
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,12 @@ getVerticalAccEst KEYWORD2
5858
getNedNorthVel KEYWORD2
5959
getNedEastVel KEYWORD2
6060
getNedDownVel KEYWORD2
61+
getSpeedAccEst KEYWORD2
62+
getHeadingAccEst KEYWORD2
63+
getInvalidLlh KEYWORD2
64+
getHeadVeh KEYWORD2
65+
getMagDec KEYWORD2
66+
getMagAcc KEYWORD2
6167

6268
setPortOutput KEYWORD2
6369
setPortInput KEYWORD2

src/SparkFun_Ublox_Arduino_Library.cpp

+73-3
Original file line numberDiff line numberDiff line change
@@ -1039,10 +1039,15 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
10391039
nedNorthVel = extractSignedLong(48 - startingSpot);
10401040
nedEastVel = extractSignedLong(52 - startingSpot);
10411041
nedDownVel = extractSignedLong(56 - startingSpot);
1042-
10431042
groundSpeed = extractSignedLong(60 - startingSpot);
10441043
headingOfMotion = extractSignedLong(64 - startingSpot);
1044+
speedAccEst = extractLong(68 - startingSpot);
1045+
headingAccEst = extractLong(72 - startingSpot);
10451046
pDOP = extractInt(76 - startingSpot);
1047+
invalidLlh = extractByte(78 - startingSpot) & 0x1;
1048+
headVeh = extractSignedLong(84 - startingSpot);
1049+
magDec = extractSignedInt(88 - startingSpot);
1050+
magAcc = extractInt(90 - startingSpot);
10461051

10471052
//Mark all datums as fresh (not read before)
10481053
moduleQueried.gpsiTOW = true;
@@ -1063,19 +1068,23 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
10631068
moduleQueried.latitude = true;
10641069
moduleQueried.altitude = true;
10651070
moduleQueried.altitudeMSL = true;
1066-
10671071
moduleQueried.horizontalAccEst = true;
10681072
moduleQueried.verticalAccEst = true;
10691073
moduleQueried.nedNorthVel = true;
10701074
moduleQueried.nedEastVel = true;
10711075
moduleQueried.nedDownVel = true;
1072-
10731076
moduleQueried.SIV = true;
10741077
moduleQueried.fixType = true;
10751078
moduleQueried.carrierSolution = true;
10761079
moduleQueried.groundSpeed = true;
10771080
moduleQueried.headingOfMotion = true;
1081+
moduleQueried.speedAccEst = true;
1082+
moduleQueried.headingAccEst = true;
10781083
moduleQueried.pDOP = true;
1084+
moduleQueried.invalidLlh = true;
1085+
moduleQueried.headVeh = true;
1086+
moduleQueried.magDec = true;
1087+
moduleQueried.magAcc = true;
10791088
}
10801089
else if (msg->id == UBX_NAV_HPPOSLLH && msg->len == 36)
10811090
{
@@ -3111,6 +3120,19 @@ uint16_t SFE_UBLOX_GPS::extractInt(uint8_t spotToStart)
31113120
return (val);
31123121
}
31133122

3123+
//Just so there is no ambiguity about whether a uint16_t will cast to a int16_t correctly...
3124+
int16_t SFE_UBLOX_GPS::extractSignedInt(int8_t spotToStart)
3125+
{
3126+
union // Use a union to convert from uint16_t to int16_t
3127+
{
3128+
uint16_t unsignedInt;
3129+
int16_t signedInt;
3130+
} stSignedInt;
3131+
3132+
stSignedInt.unsignedInt = extractInt(spotToStart);
3133+
return (stSignedInt.signedInt);
3134+
}
3135+
31143136
//Given a spot, extract a byte from the payload
31153137
uint8_t SFE_UBLOX_GPS::extractByte(uint8_t spotToStart)
31163138
{
@@ -3195,6 +3217,54 @@ bool SFE_UBLOX_GPS::getTimeValid(uint16_t maxWait)
31953217
return (gpsTimeValid);
31963218
}
31973219

3220+
uint32_t SFE_UBLOX_GPS::getSpeedAccEst(uint16_t maxWait)
3221+
{
3222+
if (moduleQueried.speedAccEst == false)
3223+
getPVT(maxWait);
3224+
moduleQueried.speedAccEst = false; //Since we are about to give this to user, mark this data as stale
3225+
return (speedAccEst);
3226+
}
3227+
3228+
uint32_t SFE_UBLOX_GPS::getHeadingAccEst(uint16_t maxWait)
3229+
{
3230+
if (moduleQueried.headingAccEst == false)
3231+
getPVT(maxWait);
3232+
moduleQueried.headingAccEst = false; //Since we are about to give this to user, mark this data as stale
3233+
return (headingAccEst);
3234+
}
3235+
3236+
bool SFE_UBLOX_GPS::getInvalidLlh(uint16_t maxWait)
3237+
{
3238+
if (moduleQueried.invalidLlh == false)
3239+
getPVT(maxWait);
3240+
moduleQueried.invalidLlh = false; //Since we are about to give this to user, mark this data as stale
3241+
return (invalidLlh);
3242+
}
3243+
3244+
int32_t SFE_UBLOX_GPS::getHeadVeh(uint16_t maxWait)
3245+
{
3246+
if (moduleQueried.headVeh == false)
3247+
getPVT(maxWait);
3248+
moduleQueried.headVeh = false; //Since we are about to give this to user, mark this data as stale
3249+
return (headVeh);
3250+
}
3251+
3252+
int16_t SFE_UBLOX_GPS::getMagDec(uint16_t maxWait)
3253+
{
3254+
if (moduleQueried.magDec == false)
3255+
getPVT(maxWait);
3256+
moduleQueried.magDec = false; //Since we are about to give this to user, mark this data as stale
3257+
return (magDec);
3258+
}
3259+
3260+
uint16_t SFE_UBLOX_GPS::getMagAcc(uint16_t maxWait)
3261+
{
3262+
if (moduleQueried.magAcc == false)
3263+
getPVT(maxWait);
3264+
moduleQueried.magAcc = false; //Since we are about to give this to user, mark this data as stale
3265+
return (magAcc);
3266+
}
3267+
31983268
//Get the current millisecond
31993269
uint16_t SFE_UBLOX_GPS::getMillisecond(uint16_t maxWait)
32003270
{

src/SparkFun_Ublox_Arduino_Library.h

+19-5
Original file line numberDiff line numberDiff line change
@@ -511,13 +511,11 @@ class SFE_UBLOX_GPS
511511
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.
512512
int32_t getAltitude(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above ellipsoid
513513
int32_t getAltitudeMSL(uint16_t maxWait = getPVTmaxWait); //Returns the current altitude in mm above mean sea level
514-
515514
int32_t getHorizontalAccEst(uint16_t maxWait = getPVTmaxWait);
516515
int32_t getVerticalAccEst(uint16_t maxWait = getPVTmaxWait);
517516
int32_t getNedNorthVel(uint16_t maxWait = getPVTmaxWait);
518517
int32_t getNedEastVel(uint16_t maxWait = getPVTmaxWait);
519518
int32_t getNedDownVel(uint16_t maxWait = getPVTmaxWait);
520-
521519
uint8_t getSIV(uint16_t maxWait = getPVTmaxWait); //Returns number of sats used in fix
522520
uint8_t getFixType(uint16_t maxWait = getPVTmaxWait); //Returns the type of fix: 0=no, 3=3D, 4=GNSS+Deadreckoning
523521
uint8_t getCarrierSolutionType(uint16_t maxWait = getPVTmaxWait); //Returns RTK solution: 0=no, 1=float solution, 2=fixed solution
@@ -535,6 +533,12 @@ class SFE_UBLOX_GPS
535533
uint32_t getTimeOfWeek(uint16_t maxWait = getPVTmaxWait);
536534
bool getDateValid(uint16_t maxWait = getPVTmaxWait);
537535
bool getTimeValid(uint16_t maxWait = getPVTmaxWait);
536+
uint32_t getSpeedAccEst(uint16_t maxWait = getPVTmaxWait);
537+
uint32_t getHeadingAccEst(uint16_t maxWait = getPVTmaxWait);
538+
bool getInvalidLlh(uint16_t maxWait = getPVTmaxWait);
539+
int32_t getHeadVeh(uint16_t maxWait = getPVTmaxWait);
540+
int16_t getMagDec(uint16_t maxWait = getPVTmaxWait);
541+
uint16_t getMagAcc(uint16_t maxWait = getPVTmaxWait);
538542

539543
int32_t getHighResLatitude(uint16_t maxWait = getHPPOSLLHmaxWait);
540544
int8_t getHighResLatitudeHp(uint16_t maxWait = getHPPOSLLHmaxWait);
@@ -730,7 +734,6 @@ class SFE_UBLOX_GPS
730734
bool gpsDateValid;
731735
bool gpsTimeValid;
732736

733-
734737
bool gnssFixOk; //valid fix (i.e within DOP & accuracy masks)
735738
bool diffSoln; //Differential corrections were applied
736739
int32_t latitude; //Degrees * 10^-7 (more accurate than floats)
@@ -747,7 +750,13 @@ class SFE_UBLOX_GPS
747750
uint8_t carrierSolution; //Tells us when we have an RTK float/fixed solution
748751
int32_t groundSpeed; //mm/s
749752
int32_t headingOfMotion; //degrees * 10^-5
753+
uint32_t speedAccEst;
754+
uint32_t headingAccEst;
750755
uint16_t pDOP; //Positional dilution of precision * 10^-2 (dimensionless)
756+
bool invalidLlh;
757+
int32_t headVeh;
758+
int16_t magDec;
759+
uint16_t magAcc;
751760
uint8_t versionLow; //Loaded from getProtocolVersion().
752761
uint8_t versionHigh;
753762

@@ -943,6 +952,7 @@ class SFE_UBLOX_GPS
943952
uint32_t extractLong(uint8_t spotToStart); //Combine four bytes from payload into long
944953
int32_t extractSignedLong(uint8_t spotToStart); //Combine four bytes from payload into signed long (avoiding any ambiguity caused by casting)
945954
uint16_t extractInt(uint8_t spotToStart); //Combine two bytes from payload into int
955+
int16_t extractSignedInt(int8_t spotToStart);
946956
uint8_t extractByte(uint8_t spotToStart); //Get byte from payload
947957
int8_t extractSignedChar(uint8_t spotToStart); //Get signed 8-bit value from payload
948958
void addToChecksum(uint8_t incoming); //Given an incoming byte, adjust rollingChecksumA/B
@@ -1026,19 +1036,23 @@ class SFE_UBLOX_GPS
10261036
uint32_t latitude : 1;
10271037
uint32_t altitude : 1;
10281038
uint32_t altitudeMSL : 1;
1029-
10301039
uint32_t horizontalAccEst : 1;
10311040
uint32_t verticalAccEst : 1;
10321041
uint32_t nedNorthVel : 1;
10331042
uint32_t nedEastVel : 1;
10341043
uint32_t nedDownVel : 1;
1035-
10361044
uint32_t SIV : 1;
10371045
uint32_t fixType : 1;
10381046
uint32_t carrierSolution : 1;
10391047
uint32_t groundSpeed : 1;
10401048
uint32_t headingOfMotion : 1;
1049+
uint32_t speedAccEst : 1;
1050+
uint32_t headingAccEst : 1;
10411051
uint32_t pDOP : 1;
1052+
uint32_t invalidLlh : 1;
1053+
uint32_t headVeh : 1;
1054+
uint32_t magDec : 1;
1055+
uint32_t magAcc : 1;
10421056
uint32_t versionNumber : 1;
10431057
} moduleQueried;
10441058

0 commit comments

Comments
 (0)