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

Commit 98d9edf

Browse files
committed
Update SparkFun_Ublox_Arduino_Library.cpp
1 parent 35c6623 commit 98d9edf

File tree

1 file changed

+39
-15
lines changed

1 file changed

+39
-15
lines changed

src/SparkFun_Ublox_Arduino_Library.cpp

Lines changed: 39 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -430,7 +430,7 @@ boolean SFE_UBLOX_GPS::checkUbloxSerial(ubxPacket *incomingUBX, uint8_t requeste
430430
//Take a given byte and file it into the proper array
431431
void SFE_UBLOX_GPS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID)
432432
{
433-
if (currentSentence == NONE || currentSentence == NMEA)
433+
if ((currentSentence == NONE) || (currentSentence == NMEA))
434434
{
435435
if (incoming == 0xB5) //UBX binary frames start with 0xB5, aka μ
436436
{
@@ -462,9 +462,9 @@ void SFE_UBLOX_GPS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t re
462462
if (currentSentence == UBX)
463463
{
464464
//Decide what type of response this is
465-
if (ubxFrameCounter == 0 && incoming != 0xB5) //ISO 'μ'
465+
if ((ubxFrameCounter == 0) && (incoming != 0xB5)) //ISO 'μ'
466466
currentSentence = NONE; //Something went wrong. Reset.
467-
else if (ubxFrameCounter == 1 && incoming != 0x62) //ASCII 'b'
467+
else if ((ubxFrameCounter == 1) && (incoming != 0x62)) //ASCII 'b'
468468
currentSentence = NONE; //Something went wrong. Reset.
469469
else if (ubxFrameCounter == 2) //Class
470470
{
@@ -587,18 +587,54 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t
587587
if (incomingUBX->counter == 0)
588588
{
589589
incomingUBX->cls = incoming;
590+
if (_printDebug == true)
591+
{
592+
_debugSerial->print(F("processUBX: Class : 0x"));
593+
_debugSerial->print(incomingUBX->cls, HEX);
594+
_debugSerial->print(F(" CSUMA: 0x"));
595+
_debugSerial->print(rollingChecksumA, HEX);
596+
_debugSerial->print(F(" CSUMB: 0x"));
597+
_debugSerial->println(rollingChecksumB, HEX);
598+
}
590599
}
591600
else if (incomingUBX->counter == 1)
592601
{
593602
incomingUBX->id = incoming;
603+
if (_printDebug == true)
604+
{
605+
_debugSerial->print(F("processUBX: ID : 0x"));
606+
_debugSerial->print(incomingUBX->id, HEX);
607+
_debugSerial->print(F(" CSUMA: 0x"));
608+
_debugSerial->print(rollingChecksumA, HEX);
609+
_debugSerial->print(F(" CSUMB: 0x"));
610+
_debugSerial->println(rollingChecksumB, HEX);
611+
}
594612
}
595613
else if (incomingUBX->counter == 2) //Len LSB
596614
{
597615
incomingUBX->len = incoming;
616+
if (_printDebug == true)
617+
{
618+
_debugSerial->print(F("processUBX: LEN_LSB: 0x"));
619+
_debugSerial->print(incomingUBX->len, HEX);
620+
_debugSerial->print(F(" CSUMA: 0x"));
621+
_debugSerial->print(rollingChecksumA, HEX);
622+
_debugSerial->print(F(" CSUMB: 0x"));
623+
_debugSerial->println(rollingChecksumB, HEX);
624+
}
598625
}
599626
else if (incomingUBX->counter == 3) //Len MSB
600627
{
601628
incomingUBX->len |= incoming << 8;
629+
if (_printDebug == true)
630+
{
631+
_debugSerial->print(F("processUBX: LEN_MSB: 0x"));
632+
_debugSerial->print(incoming, HEX);
633+
_debugSerial->print(F(" CSUMA: 0x"));
634+
_debugSerial->print(rollingChecksumA, HEX);
635+
_debugSerial->print(F(" CSUMB: 0x"));
636+
_debugSerial->println(rollingChecksumB, HEX);
637+
}
602638
}
603639
else if (incomingUBX->counter == incomingUBX->len + 4) //ChecksumA
604640
{
@@ -651,31 +687,19 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t
651687

652688
if (incomingUBX->valid == SFE_UBLOX_PACKET_VALIDITY_VALID)
653689
{
654-
if (_printDebug == true)
655-
{
656690
_debugSerial->println(F("packetCfg now valid"));
657-
}
658691
}
659692
if (packetAck.valid == SFE_UBLOX_PACKET_VALIDITY_VALID)
660693
{
661-
if (_printDebug == true)
662-
{
663694
_debugSerial->println(F("packetAck now valid"));
664-
}
665695
}
666696
if (incomingUBX->classAndIDmatch == SFE_UBLOX_PACKET_VALIDITY_VALID)
667697
{
668-
if (_printDebug == true)
669-
{
670698
_debugSerial->println(F("packetCfg classAndIDmatch"));
671-
}
672699
}
673700
if (packetAck.classAndIDmatch == SFE_UBLOX_PACKET_VALIDITY_VALID)
674701
{
675-
if (_printDebug == true)
676-
{
677702
_debugSerial->println(F("packetAck classAndIDmatch"));
678-
}
679703
}
680704
}
681705

0 commit comments

Comments
 (0)