Skip to content
This repository was archived by the owner on Jan 28, 2021. It is now read-only.
Prev Previous commit
Next Next commit
getHeadVehValid function added.
  • Loading branch information
balamuruganky committed Dec 10, 2020
commit 9479135cebf053f9bbf8f40765cc8304d9387d40
1 change: 1 addition & 0 deletions keywords.txt
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ getInvalidLlh KEYWORD2
getHeadVeh KEYWORD2
getMagDec KEYWORD2
getMagAcc KEYWORD2
getHeadVehValid KEYWORD2

setPortOutput KEYWORD2
setPortInput KEYWORD2
Expand Down
21 changes: 21 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1029,6 +1029,7 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
gnssFixOk = extractByte(21 - startingSpot) & 0x1; //Get the 1st bit
diffSoln = extractByte(21 - startingSpot) >> 1 & 0x1; //Get the 2nd bit
carrierSolution = extractByte(21 - startingSpot) >> 6; //Get 6th&7th bits of this byte
headVehValid = extractByte(21 - startingSpot) >> 5 & 0x1; // Get the 5th bit
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's change this to:
headVehValid = (extractByte(21 - startingSpot) >> 5) & 0x1; // Get the 5th bit
just to make it clear that the shift happens before the AND

Copy link
Collaborator

@PaulZC PaulZC Dec 11, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually, can you change line 1030 too please?
(I know the code works - these changes just help with the clarity)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. I will update accordingly. Thanks.

SIV = extractByte(23 - startingSpot);
longitude = extractSignedLong(24 - startingSpot);
latitude = extractSignedLong(28 - startingSpot);
Expand Down Expand Up @@ -1064,6 +1065,7 @@ void SFE_UBLOX_GPS::processUBXpacket(ubxPacket *msg)
moduleQueried.all = true;
moduleQueried.gnssFixOk = true;
moduleQueried.diffSoln = true;
moduleQueried.headVehValid = true;
moduleQueried.longitude = true;
moduleQueried.latitude = true;
moduleQueried.altitude = true;
Expand Down Expand Up @@ -3850,6 +3852,18 @@ uint8_t SFE_UBLOX_GPS::getCarrierSolutionType(uint16_t maxWait)
return (carrierSolution);
}

//Get whether head vehicle valid or not
bool SFE_UBLOX_GPS::getHeadVehValid(uint16_t maxWait)
{
if (moduleQueried.headVehValid == false)
getPVT(maxWait);
moduleQueried.headVehValid = false; //Since we are about to give this to user, mark this data as stale
moduleQueried.all = false;

return (headVehValid);
}


//Get the ground speed in mm/s
int32_t SFE_UBLOX_GPS::getGroundSpeed(uint16_t maxWait)
{
Expand Down Expand Up @@ -3971,6 +3985,7 @@ void SFE_UBLOX_GPS::flushPVT()
moduleQueried.all = false;
moduleQueried.gnssFixOk = false;
moduleQueried.diffSoln = false;
moduleQueried.headVehValid = false;
moduleQueried.longitude = false;
moduleQueried.latitude = false;
moduleQueried.altitude = false;
Expand All @@ -3980,7 +3995,13 @@ void SFE_UBLOX_GPS::flushPVT()
moduleQueried.carrierSolution = false;
moduleQueried.groundSpeed = false;
moduleQueried.headingOfMotion = false;
moduleQueried.speedAccEst = false;
moduleQueried.headingAccEst = false;
moduleQueried.pDOP = false;
moduleQueried.invalidLlh = false;
moduleQueried.headVeh = false;
moduleQueried.magDec = false;
moduleQueried.magAcc = false;
}

//Mark all the HPPOSLLH data as read/stale. This is handy to get data alignment after CRC failure
Expand Down
3 changes: 3 additions & 0 deletions src/SparkFun_Ublox_Arduino_Library.h
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,7 @@ class SFE_UBLOX_GPS

bool getGnssFixOk(uint16_t maxWait = getPVTmaxWait); //Get whether we have a valid fix (i.e within DOP & accuracy masks)
bool getDiffSoln(uint16_t maxWait = getPVTmaxWait); //Get whether differential corrections were applied
bool getHeadVehValid(uint16_t maxWait = getPVTmaxWait);
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
Expand Down Expand Up @@ -736,6 +737,7 @@ class SFE_UBLOX_GPS

bool gnssFixOk; //valid fix (i.e within DOP & accuracy masks)
bool diffSoln; //Differential corrections were applied
bool headVehValid;
int32_t latitude; //Degrees * 10^-7 (more accurate than floats)
int32_t longitude; //Degrees * 10^-7 (more accurate than floats)
int32_t altitude; //Number of mm above ellipsoid
Expand Down Expand Up @@ -1032,6 +1034,7 @@ class SFE_UBLOX_GPS
uint32_t all : 1;
uint32_t gnssFixOk : 1;
uint32_t diffSoln : 1;
uint32_t headVehValid : 1;
uint32_t longitude : 1;
uint32_t latitude : 1;
uint32_t altitude : 1;
Expand Down