Skip to content

Commit 87b641c

Browse files
committed
Removing class/ID match checking from processUBX. All checking now done much higher up the call chain
1 parent a1ca3d4 commit 87b641c

File tree

2 files changed

+12
-71
lines changed

2 files changed

+12
-71
lines changed

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 11 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -1306,13 +1306,13 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
13061306
{
13071307
//Divert incoming into the correct buffer
13081308
if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETACK)
1309-
processUBX(incoming, &packetAck, requestedClass, requestedID);
1309+
processUBX(incoming, &packetAck);
13101310
else if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETCFG)
1311-
processUBX(incoming, &packetCfg, requestedClass, requestedID);
1311+
processUBX(incoming, &packetCfg);
13121312
else if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETBUF)
1313-
processUBX(incoming, &packetBuf, requestedClass, requestedID);
1313+
processUBX(incoming, &packetBuf);
13141314
else // if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETAUTO)
1315-
processUBX(incoming, &packetAuto, requestedClass, requestedID);
1315+
processUBX(incoming, &packetAuto);
13161316
}
13171317
//Finally, increment the frame counter
13181318
ubxFrameCounter++;
@@ -1513,7 +1513,7 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming) // IGNORE COMPILER WARNING un
15131513
//Set valid to VALID or NOT_VALID once sentence is completely received and passes or fails CRC
15141514
//The payload portion of the packet can be 100s of bytes but the max array size is packetCfgPayloadSize bytes.
15151515
//startingSpot can be set so we only record a subset of bytes within a larger packet.
1516-
void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID)
1516+
void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX)
15171517
{
15181518
//If incomingUBX is a user-defined custom packet, then the payload size could be different to packetCfgPayloadSize.
15191519
//TO DO: update this to prevent an overrun when receiving an automatic message
@@ -1587,54 +1587,6 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_
15871587
incomingUBX->valid = SFE_UBLOX_PACKET_VALIDITY_VALID; // Flag the packet as valid
15881588
if (_printDebug) _debugSerial->println("processUBX packet is valid");
15891589

1590-
// ACK or NACK???
1591-
if (incomingUBX->isAckForClassAndId(requestedClass, requestedID)) {
1592-
if (_printDebug)
1593-
{
1594-
_debugSerial->print(F("processUBX: ACK received: Requested Class: 0x"));
1595-
_debugSerial->print(incomingUBX->payload[0], HEX);
1596-
_debugSerial->print(F(" Requested ID: 0x"));
1597-
_debugSerial->println(incomingUBX->payload[1], HEX);
1598-
}
1599-
}
1600-
1601-
else if (incomingUBX->isAckForClassAndId(requestedClass, requestedID))
1602-
{
1603-
if (_printDebug == true)
1604-
{
1605-
_debugSerial->print(F("processUBX: NACK received: Requested Class: 0x"));
1606-
_debugSerial->print(incomingUBX->payload[0], HEX);
1607-
_debugSerial->print(F(" Requested ID: 0x"));
1608-
_debugSerial->println(incomingUBX->payload[1], HEX);
1609-
}
1610-
}
1611-
1612-
else if (incomingUBX->isClassAndIdMatch(requestedClass, requestedID))
1613-
{
1614-
if (_printDebug == true)
1615-
{
1616-
_debugSerial->print(F("processUBX: Message received for requested Class: 0x"));
1617-
_debugSerial->print(incomingUBX->payload[0], HEX);
1618-
_debugSerial->print(F(" Requested ID: 0x"));
1619-
_debugSerial->println(incomingUBX->payload[1], HEX);
1620-
}
1621-
}
1622-
1623-
//This is not an ACK and we do not have a complete class and ID match
1624-
//So let's check for an "automatic" message arriving
1625-
else if (checkAutomatic(incomingUBX->cls, incomingUBX->id))
1626-
{
1627-
// This isn't the message we are looking for...
1628-
// Let's say so...
1629-
if (_printDebug == true)
1630-
{
1631-
_debugSerial->print(F("processUBX: incoming \"automatic\" message: Class: 0x"));
1632-
_debugSerial->print(incomingUBX->cls, HEX);
1633-
_debugSerial->print(F(" ID: 0x"));
1634-
_debugSerial->println(incomingUBX->id, HEX);
1635-
}
1636-
}
1637-
16381590
if (_printDebug == true)
16391591
{
16401592
_debugSerial->print(F("Incoming: Size: "));
@@ -1643,7 +1595,6 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_
16431595
printPacket(incomingUBX);
16441596

16451597
}
1646-
16471598
//We've got a valid packet, now do something with it but only if ignoreThisPayload is false
16481599
if (ignoreThisPayload == false)
16491600
{
@@ -1691,9 +1642,13 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_
16911642
{
16921643
//If an automatic packet comes in asynchronously, we need to fudge the startingSpot
16931644
uint16_t startingSpot = incomingUBX->startingSpot;
1694-
if (!incomingUBX->isClassAndIdMatch(requestedClass, requestedID) && checkAutomatic(incomingUBX->cls, incomingUBX->id))
1645+
if (checkAutomatic(incomingUBX->cls, incomingUBX->id))
16951646
{
1696-
//_debugSerial->println("processUBX: incoming is automatic");
1647+
if(_printDebug == true)
1648+
{
1649+
//_debugSerial->println("processUBX: incoming is automatic");
1650+
}
1651+
16971652
startingSpot = 0;
16981653
}
16991654

@@ -2979,7 +2934,6 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
29792934
{
29802935
if (checkUbloxInternal(outgoingUBX, requestedClass, requestedID) == true) //See if new data is available. Process bytes as they come in.
29812936
{
2982-
29832937
// If we are expecting an ACK only, return as soon as we have it!
29842938
if (expectACKonly && packetAck.isAckForClassAndId(requestedClass, requestedID) && packetAck.valid == SFE_UBLOX_PACKET_VALIDITY_VALID)
29852939
{
@@ -3064,19 +3018,6 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
30643018
}
30653019
return (SFE_UBLOX_STATUS_FAIL); //We received invalid data and an invalid ACK!
30663020
}
3067-
3068-
// If the config packet is VALID and packetAck does not match the requested class/ID
3069-
// then the ACK has not yet been received and we should keep waiting for it
3070-
else if ((packetCfg.isClassAndIdMatch(requestedClass, requestedID) == true) && (packetAck.isClassAndIdMatch(requestedClass, requestedID) == false))
3071-
{
3072-
// if (_printDebug == true)
3073-
// {
3074-
// _debugSerial->print(F("waitForACKResponse: valid data after "));
3075-
// _debugSerial->print(millis() - startTime);
3076-
// _debugSerial->println(F(" msec. Waiting for ACK."));
3077-
// }
3078-
}
3079-
30803021
} //checkUbloxInternal == true
30813022

30823023
delayMicroseconds(500);

src/SparkFun_u-blox_GNSS_Arduino_Library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -632,7 +632,7 @@ class SFE_UBLOX_GNSS
632632
void processNMEA(char incoming) __attribute__((weak)); //Given a NMEA character, do something with it. User can overwrite if desired to use something like tinyGPS or MicroNMEA libraries
633633
void processRTCMframe(uint8_t incoming); //Monitor the incoming bytes for start and length bytes
634634
void processRTCM(uint8_t incoming) __attribute__((weak)); //Given rtcm byte, do something with it. User can overwrite if desired to pipe bytes to radio, internet, etc.
635-
void processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); //Given a character, file it away into the uxb packet structure
635+
void processUBX(uint8_t incoming, ubxPacket *incomingUBX); //Given a character, file it away into the uxb packet structure
636636
void processUBXpacket(ubxPacket *msg); //Once a packet has been received and validated, identify this packet's class/id and update internal flags
637637

638638
// Send I2C/Serial/SPI commands to the module

0 commit comments

Comments
 (0)