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

Commit 25c9918

Browse files
committed
Correcting the collision detection for HNR
1 parent 0184d44 commit 25c9918

File tree

1 file changed

+50
-16
lines changed

1 file changed

+50
-16
lines changed

Diff for: src/SparkFun_Ublox_Arduino_Library.cpp

+50-16
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void SFE_UBLOX_GPS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t re
554554
//So let's check for an HPPOSLLH message arriving when we were expecting PVT and vice versa
555555
else if ((packetBuf.cls == requestedClass) &&
556556
(((packetBuf.id == UBX_NAV_PVT) && (requestedID == UBX_NAV_HPPOSLLH || requestedID == UBX_NAV_DOP)) ||
557-
((packetBuf.id == UBX_NAV_HPPOSLLH) && (requestedID == UBX_NAV_PVT || requestedID == UBX_NAV_DOP)) ||
557+
((packetBuf.id == UBX_NAV_HPPOSLLH) && (requestedID == UBX_NAV_PVT || requestedID == UBX_NAV_DOP)) ||
558558
((packetBuf.id == UBX_NAV_DOP) && (requestedID == UBX_NAV_PVT || requestedID == UBX_NAV_HPPOSLLH))))
559559
{
560560
//This is not the message we were expecting but we start diverting data into incomingUBX (usually packetCfg) and process it anyway
@@ -564,7 +564,25 @@ void SFE_UBLOX_GPS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t re
564564
incomingUBX->counter = packetBuf.counter; //Copy over the .counter too
565565
if (_printDebug == true)
566566
{
567-
_debugSerial->print(F("process: auto PVT/HPPOSLLH/DOP collision: Requested ID: 0x"));
567+
_debugSerial->print(F("process: auto NAV PVT/HPPOSLLH/DOP collision: Requested ID: 0x"));
568+
_debugSerial->print(requestedID, HEX);
569+
_debugSerial->print(F(" Message ID: 0x"));
570+
_debugSerial->println(packetBuf.id, HEX);
571+
}
572+
}
573+
else if ((packetBuf.cls == requestedClass) &&
574+
(((packetBuf.id == UBX_HNR_ATT) && (requestedID == UBX_HNR_INS || requestedID == UBX_HNR_PVT)) ||
575+
((packetBuf.id == UBX_HNR_INS) && (requestedID == UBX_HNR_ATT || requestedID == UBX_HNR_PVT)) ||
576+
((packetBuf.id == UBX_HNR_PVT) && (requestedID == UBX_HNR_ATT || requestedID == UBX_HNR_INS))))
577+
{
578+
//This is not the message we were expecting but we start diverting data into incomingUBX (usually packetCfg) and process it anyway
579+
activePacketBuffer = SFE_UBLOX_PACKET_PACKETCFG;
580+
incomingUBX->cls = packetBuf.cls; //Copy the class and ID into incomingUBX (usually packetCfg)
581+
incomingUBX->id = packetBuf.id;
582+
incomingUBX->counter = packetBuf.counter; //Copy over the .counter too
583+
if (_printDebug == true)
584+
{
585+
_debugSerial->print(F("process: auto HNR ATT/INS/PVT collision: Requested ID: 0x"));
568586
_debugSerial->print(requestedID, HEX);
569587
_debugSerial->print(F(" Message ID: 0x"));
570588
_debugSerial->println(packetBuf.id, HEX);
@@ -837,12 +855,28 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t
837855
// Let's say so and leave incomingUBX->classAndIDmatch _unchanged_
838856
if (_printDebug == true)
839857
{
840-
_debugSerial->print(F("processUBX: auto PVT/HPPOSLLH/DOP collision: Requested ID: 0x"));
858+
_debugSerial->print(F("processUBX: auto NAV PVT/HPPOSLLH/DOP collision: Requested ID: 0x"));
841859
_debugSerial->print(requestedID, HEX);
842860
_debugSerial->print(F(" Message ID: 0x"));
843861
_debugSerial->println(incomingUBX->id, HEX);
844862
}
845863
}
864+
// Let's do the same for the HNR messages
865+
else if ((incomingUBX->cls == requestedClass) &&
866+
(((incomingUBX->id == UBX_HNR_ATT) && (requestedID == UBX_HNR_INS || requestedID == UBX_HNR_PVT)) ||
867+
((incomingUBX->id == UBX_HNR_INS) && (requestedID == UBX_HNR_ATT || requestedID == UBX_HNR_PVT)) ||
868+
((incomingUBX->id == UBX_HNR_PVT) && (requestedID == UBX_HNR_ATT || requestedID == UBX_HNR_INS))))
869+
{
870+
// This isn't the message we are looking for...
871+
// Let's say so and leave incomingUBX->classAndIDmatch _unchanged_
872+
if (_printDebug == true)
873+
{
874+
_debugSerial->print(F("processUBX: auto HNR ATT/INS/PVT collision: Requested ID: 0x"));
875+
_debugSerial->print(requestedID, HEX);
876+
_debugSerial->print(F(" Message ID: 0x"));
877+
_debugSerial->println(incomingUBX->id, HEX);
878+
}
879+
}
846880

847881
if (_printDebug == true)
848882
{
@@ -3233,9 +3267,9 @@ boolean SFE_UBLOX_GPS::getPVT(uint16_t maxWait)
32333267
{
32343268
if (_printDebug == true)
32353269
{
3236-
_debugSerial->println(F("getPVT: data was OVERWRITTEN by a HNR message (but that's OK)"));
3270+
_debugSerial->println(F("getPVT: data was OVERWRITTEN by a HNR message (and that's not OK)"));
32373271
}
3238-
return (true);
3272+
return (false);
32393273
}
32403274

32413275
if (_printDebug == true)
@@ -3417,9 +3451,9 @@ boolean SFE_UBLOX_GPS::getHPPOSLLH(uint16_t maxWait)
34173451
{
34183452
if (_printDebug == true)
34193453
{
3420-
_debugSerial->println(F("getHPPOSLLH: data was OVERWRITTEN by a HNR message (but that's OK)"));
3454+
_debugSerial->println(F("getHPPOSLLH: data was OVERWRITTEN by a HNR message (and that's not OK)"));
34213455
}
3422-
return (true);
3456+
return (false);
34233457
}
34243458

34253459
if (_printDebug == true)
@@ -3544,7 +3578,7 @@ boolean SFE_UBLOX_GPS::getDOP(uint16_t maxWait)
35443578
{
35453579
if (_printDebug == true)
35463580
{
3547-
_debugSerial->println(F("getHPPOSLLH: data was OVERWRITTEN by another NAV message (but that's OK)"));
3581+
_debugSerial->println(F("getDOP: data was OVERWRITTEN by another NAV message (but that's OK)"));
35483582
}
35493583
return (true);
35503584
}
@@ -3553,9 +3587,9 @@ boolean SFE_UBLOX_GPS::getDOP(uint16_t maxWait)
35533587
{
35543588
if (_printDebug == true)
35553589
{
3556-
_debugSerial->println(F("getPVT: data was OVERWRITTEN by a HNR message (but that's OK)"));
3590+
_debugSerial->println(F("getDOP: data was OVERWRITTEN by a HNR message (and that's not OK)"));
35573591
}
3558-
return (true);
3592+
return (false);
35593593
}
35603594

35613595
if (_printDebug == true)
@@ -4459,9 +4493,9 @@ boolean SFE_UBLOX_GPS::getHNRAtt(uint16_t maxWait)
44594493
{
44604494
if (_printDebug == true)
44614495
{
4462-
_debugSerial->println(F("getHNRAtt: data was OVERWRITTEN by a NAV message (but that's OK)"));
4496+
_debugSerial->println(F("getHNRAtt: data was OVERWRITTEN by a NAV message (and that's not OK)"));
44634497
}
4464-
return (true);
4498+
return (false);
44654499
}
44664500

44674501
if ((retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN) && (packetCfg.cls == UBX_CLASS_HNR))
@@ -4579,9 +4613,9 @@ boolean SFE_UBLOX_GPS::getHNRDyn(uint16_t maxWait)
45794613
{
45804614
if (_printDebug == true)
45814615
{
4582-
_debugSerial->println(F("getHNRDyn: data was OVERWRITTEN by a NAV message (but that's OK)"));
4616+
_debugSerial->println(F("getHNRDyn: data was OVERWRITTEN by a NAV message (and that's not OK)"));
45834617
}
4584-
return (true);
4618+
return (false);
45854619
}
45864620

45874621
if ((retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN) && (packetCfg.cls == UBX_CLASS_HNR))
@@ -4699,9 +4733,9 @@ boolean SFE_UBLOX_GPS::getHNRPVT(uint16_t maxWait)
46994733
{
47004734
if (_printDebug == true)
47014735
{
4702-
_debugSerial->println(F("getHNRPVT: data was OVERWRITTEN by a NAV message (but that's OK)"));
4736+
_debugSerial->println(F("getHNRPVT: data was OVERWRITTEN by a NAV message (and that's not OK)"));
47034737
}
4704-
return (true);
4738+
return (false);
47054739
}
47064740

47074741
if ((retVal == SFE_UBLOX_STATUS_DATA_OVERWRITTEN) && (packetCfg.cls == UBX_CLASS_HNR))

0 commit comments

Comments
 (0)