From a1142c29c7a69c772061a911348e4f8423bb8a73 Mon Sep 17 00:00:00 2001 From: Lee Leahy Date: Sat, 30 Jul 2022 06:39:34 -1000 Subject: [PATCH 1/4] Make processRTCMframe weak Allow processRTCMframe to be overridden. Its replacement would now be able to place all of the bytes into a buffer for processing at a later time and eliminate a deep call stack for every byte. --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 31 ++++++++++---------- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 24 +++++++-------- 2 files changed, 26 insertions(+), 29 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 1b50c19..8a982f2 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -350,7 +350,7 @@ void SFE_UBLOX_GNSS::end(void) delete packetUBXRXMQZSSL6message; packetUBXRXMQZSSL6message = NULL; // Redundant? } - + if (packetUBXRXMCOR != NULL) { if (packetUBXRXMCOR->callbackData != NULL) @@ -2114,7 +2114,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r } else if (currentSentence == RTCM) { - processRTCMframe(incoming); // Deal with RTCM bytes + currentSentence = processRTCMframe(incoming, &rtcmFrameCounter); // Deal with RTCM bytes } } @@ -2876,13 +2876,15 @@ nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr() // Byte 2: 10-bits of length of this packet including the first two-ish header bytes, + 6. // byte 3 + 4 bits: Msg type 12 bits // Example: D3 00 7C 43 F0 ... / 0x7C = 124+6 = 130 bytes in this packet, 0x43F = Msg type 1087 -void SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming) +SFE_UBLOX_GNSS::SentenceTypes SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) { - if (rtcmFrameCounter == 1) + static uint16_t rtcmLen = 0; + + if (*rtcmFrameCounter == 1) { rtcmLen = (incoming & 0x03) << 8; // Get the last two bits of this byte. Bits 8&9 of 10-bit length } - else if (rtcmFrameCounter == 2) + else if (*rtcmFrameCounter == 2) { rtcmLen |= incoming; // Bits 0-7 of packet length rtcmLen += 6; // There are 6 additional bytes of what we presume is header, msgType, CRC, and stuff @@ -2896,15 +2898,12 @@ void SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming) rtcmMsgType |= (incoming >> 4); //Message Type, bits 0-7 }*/ - rtcmFrameCounter++; + *rtcmFrameCounter++; processRTCM(incoming); // Here is where we expose this byte to the user - if (rtcmFrameCounter == rtcmLen) - { - // We're done! - currentSentence = NONE; // Reset and start looking for next sentence type - } + // Reset and start looking for next sentence type when done + return (*rtcmFrameCounter == rtcmLen) ? NONE : RTCM; } // This function is called for each byte of an RTCM frame @@ -3944,10 +3943,10 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg) // Note: length is variable with version 0x01 // Note: the field positions depend on the version { - // Full QZSSL6 message, including Class, ID and checksum + // Full QZSSL6 message, including Class, ID and checksum for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch ++) { if (0 == (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch))) { - + packetUBXRXMQZSSL6message->callbackData[ch].sync1 = UBX_SYNCH_1; packetUBXRXMQZSSL6message->callbackData[ch].sync2 = UBX_SYNCH_2; packetUBXRXMQZSSL6message->callbackData[ch].cls = UBX_CLASS_RXM; @@ -3958,12 +3957,12 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg) memcpy(packetUBXRXMQZSSL6message->callbackData[ch].payload, msg->payload, msg->len); packetUBXRXMQZSSL6message->callbackData[ch].checksumA = msg->checksumA; - packetUBXRXMQZSSL6message->callbackData[ch].checksumB = msg->checksumB; + packetUBXRXMQZSSL6message->callbackData[ch].checksumB = msg->checksumB; packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid |= (1 << ch); break; // abort when added } - } + } } else if (msg->id == UBX_RXM_COR) { @@ -5605,7 +5604,7 @@ void SFE_UBLOX_GNSS::checkCallbacks(void) packetUBXRXMPMPmessage->callbackPointerPtr(packetUBXRXMPMPmessage->callbackData); // Call the callback packetUBXRXMPMPmessage->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale } - + if ((packetUBXRXMQZSSL6message != NULL) && // If RAM has been allocated for message storage (packetUBXRXMQZSSL6message->callbackData != NULL) && // If RAM has been allocated for the copy of the data (packetUBXRXMQZSSL6message->callbackPointerPtr != NULL)) // If the pointer to the callback has been defined diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index 4cb9717..a7a2e3d 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -646,6 +646,15 @@ class SFE_UBLOX_GNSS SFE_UBLOX_GNSS(void); ~SFE_UBLOX_GNSS(void); + // Depending on the sentence type the processor will load characters into different arrays + enum SentenceTypes + { + NONE = 0, + NMEA, + UBX, + RTCM + } currentSentence = NONE; + // A default of 250ms for maxWait seems fine for I2C but is not enough for SerialUSB. // If you know you are only going to be using I2C / Qwiic communication, you can // safely reduce defaultMaxWait to 250. @@ -738,7 +747,7 @@ class SFE_UBLOX_GNSS void process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Processes NMEA and UBX binary sentences one byte at a time 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 - void processRTCMframe(uint8_t incoming); // Monitor the incoming bytes for start and length bytes + SentenceTypes processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) __attribute__((weak)); // Monitor the incoming bytes for start and length bytes 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. void processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Given a character, file it away into the uxb packet structure void processUBXpacket(ubxPacket *msg); // Once a packet has been received and validated, identify this packet's class/id and update internal flags @@ -1187,7 +1196,7 @@ class SFE_UBLOX_GNSS // You can disable them by calling (e.g.) setVal8(UBLOX_CFG_MSGOUT_UBX_RXM_QZSSL6_I2C, 0) // The NEO-D9C does not support UBX-CFG-MSG bool setRXMQZSSL6messageCallbackPtr(void (*callbackPointerPtr)(UBX_RXM_QZSSL6_message_data_t *)); // Use this if you want all of the QZSSL6 message (including sync chars, checksum, etc.) to push to a GNSS - + bool setRXMCORcallbackPtr(void (*callbackPointerPtr)(UBX_RXM_COR_data_t *)); // RXM COR bool getRXMSFRBX(uint16_t maxWait = defaultMaxWait); // RXM SFRBX @@ -1582,15 +1591,6 @@ class SFE_UBLOX_GNSS uint16_t rtcmFrameCounter = 0; // Tracks the type of incoming byte inside RTCM frame private: - // Depending on the sentence type the processor will load characters into different arrays - enum SentenceTypes - { - NONE = 0, - NMEA, - UBX, - RTCM - } currentSentence = NONE; - // Depending on the ubx binary response class, store binary responses into different places enum classTypes { @@ -1761,8 +1761,6 @@ class SFE_UBLOX_GNSS uint8_t getNMEAMaxLength(); // Get the maximum length of this NMEA message nmeaAutomaticFlags *getNMEAFlagsPtr(); // Get a pointer to the flags - uint16_t rtcmLen = 0; - // Flag to prevent reentry into checkCallbacks // Prevent badness if the user accidentally calls checkCallbacks from inside a callback volatile bool checkCallbacksReentrant = false; From f123e3f391619e7156758d9918d18a4278faafb7 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Mon, 1 Aug 2022 13:04:42 +0100 Subject: [PATCH 2/4] Make sentence types less generic. Fix unused variable non-error. --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 55 +++++++++----------- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 14 ++--- 2 files changed, 33 insertions(+), 36 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 8a982f2..6acf8d2 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -1284,7 +1284,7 @@ bool SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedClas // If we are not receiving a sentence (currentSentence == NONE) and the byteReturned is 0xFF, // i.e. the module has no data for us, then delay for - if ((byteReturned == 0xFF) && (currentSentence == NONE)) + if ((byteReturned == 0xFF) && (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NONE)) { digitalWrite(_csPin, HIGH); _spiPort->endTransaction(); @@ -1292,7 +1292,7 @@ bool SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedClas return (true); } - while ((byteReturned != 0xFF) || (currentSentence != NONE)) + while ((byteReturned != 0xFF) || (currentSentence != SFE_UBLOX_SENTENCE_TYPE_NONE)) { process(byteReturned, incomingUBX, requestedClass, requestedID); byteReturned = _spiPort->transfer(0xFF); @@ -1686,14 +1686,14 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r { if (_outputPort != NULL) _outputPort->write(incoming); // Echo this byte to the serial port - if ((currentSentence == NONE) || (currentSentence == NMEA)) + if ((currentSentence == SFE_UBLOX_SENTENCE_TYPE_NONE) || (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NMEA)) { if (incoming == UBX_SYNCH_1) // UBX binary frames start with 0xB5, aka μ { // This is the start of a binary sentence. Reset flags. // We still don't know the response class ubxFrameCounter = 0; - currentSentence = UBX; + currentSentence = SFE_UBLOX_SENTENCE_TYPE_UBX; // Reset the packetBuf.counter even though we will need to reset it again when ubxFrameCounter == 2 packetBuf.counter = 0; ignoreThisPayload = false; // We should not ignore this payload - yet @@ -1703,12 +1703,12 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r else if (incoming == '$') { nmeaByteCounter = 0; // Reset the NMEA byte counter - currentSentence = NMEA; + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NMEA; } else if (incoming == 0xD3) // RTCM frames start with 0xD3 { rtcmFrameCounter = 0; - currentSentence = RTCM; + currentSentence = SFE_UBLOX_SENTENCE_TYPE_RTCM; } else { @@ -1717,13 +1717,13 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r } // Depending on the sentence, pass the character to the individual processor - if (currentSentence == UBX) + if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_UBX) { // Decide what type of response this is if ((ubxFrameCounter == 0) && (incoming != UBX_SYNCH_1)) // ISO 'μ' - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. else if ((ubxFrameCounter == 1) && (incoming != UBX_SYNCH_2)) // ASCII 'b' - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. // Note to future self: // There may be some duplication / redundancy in the next few lines as processUBX will also // load information into packetBuf, but we'll do it here too for clarity @@ -1936,15 +1936,15 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r // Finally, increment the frame counter ubxFrameCounter++; } - else if (currentSentence == NMEA) // Process incoming NMEA mesages. Selectively log if desired. + else if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NMEA) // Process incoming NMEA mesages. Selectively log if desired. { if ((nmeaByteCounter == 0) && (incoming != '$')) { - currentSentence = NONE; // Something went wrong. Reset. (Almost certainly redundant!) + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. (Almost certainly redundant!) } else if ((nmeaByteCounter == 1) && (incoming != 'G')) { - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. } else if ((nmeaByteCounter >= 0) && (nmeaByteCounter <= 5)) { @@ -2029,7 +2029,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r nmeaByteCounter++; // Increment the byte counter if (nmeaByteCounter == maxNMEAByteCount) // Check if we have processed too many bytes - currentSentence = NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. if (nmeaByteCounter == 0) // Check if we are done { @@ -2109,10 +2109,10 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r } } #endif - currentSentence = NONE; // All done! + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // All done! } } - else if (currentSentence == RTCM) + else if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_RTCM) { currentSentence = processRTCMframe(incoming, &rtcmFrameCounter); // Deal with RTCM bytes } @@ -2876,7 +2876,7 @@ nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr() // Byte 2: 10-bits of length of this packet including the first two-ish header bytes, + 6. // byte 3 + 4 bits: Msg type 12 bits // Example: D3 00 7C 43 F0 ... / 0x7C = 124+6 = 130 bytes in this packet, 0x43F = Msg type 1087 -SFE_UBLOX_GNSS::SentenceTypes SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) +SFE_UBLOX_GNSS::sfe_ublox_sentence_types_e SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) { static uint16_t rtcmLen = 0; @@ -2898,12 +2898,12 @@ SFE_UBLOX_GNSS::SentenceTypes SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, rtcmMsgType |= (incoming >> 4); //Message Type, bits 0-7 }*/ - *rtcmFrameCounter++; + *rtcmFrameCounter = *rtcmFrameCounter + 1; processRTCM(incoming); // Here is where we expose this byte to the user // Reset and start looking for next sentence type when done - return (*rtcmFrameCounter == rtcmLen) ? NONE : RTCM; + return (*rtcmFrameCounter == rtcmLen) ? SFE_UBLOX_SENTENCE_TYPE_NONE : SFE_UBLOX_SENTENCE_TYPE_RTCM; } // This function is called for each byte of an RTCM frame @@ -2911,9 +2911,6 @@ SFE_UBLOX_GNSS::SentenceTypes SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, // Bytes can be piped to Serial or other interface. The consumer could be a radio or the internet (Ntrip broadcaster) void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming) { - uint8_t ignoreMe = incoming; - ignoreMe += 0; // Do something with incoming just to get rid of the pesky compiler warning! - // Radio.sendReliable((String)incoming); //An example of passing this byte to a radio //_debugSerial->write(incoming); //An example of passing this byte out the serial port @@ -2923,6 +2920,8 @@ void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming) // if(incoming < 0x10) _debugSerial->print(F("0")); // _debugSerial->print(incoming, HEX); // if(rtcmFrameCounter % 16 == 0) _debugSerial->println(); + + (void)incoming; // Do something with incoming just to get rid of the pesky compiler warning! } // Given a character, file it away into the uxb packet structure @@ -2995,7 +2994,7 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_ { incomingUBX->checksumB = incoming; - currentSentence = NONE; // We're done! Reset the sentence to being looking for a new start char + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // We're done! Reset the sentence to being looking for a new start char // Validate this sentence if ((incomingUBX->checksumA == rollingChecksumA) && (incomingUBX->checksumB == rollingChecksumB)) @@ -3163,7 +3162,7 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_ if (overrun || ((incomingUBX->counter == maximum_payload_size + 6) && (ignoreThisPayload == false))) { // Something has gone very wrong - currentSentence = NONE; // Reset the sentence to being looking for a new start char + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Reset the sentence to being looking for a new start char #ifndef SFE_UBLOX_REDUCED_PROG_MEM if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging { @@ -4620,9 +4619,6 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t // Returns false if sensor fails to respond to I2C traffic sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16_t maxWait) { - uint16_t ignoreMe = maxWait; - ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings! - // From the integration guide: // "The receiver does not provide any write access except for writing UBX and NMEA messages to the // receiver, such as configuration or aiding data. Therefore, the register set mentioned in section Read @@ -4754,6 +4750,8 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16 if (_i2cPort->endTransmission() != 0) return (SFE_UBLOX_STATUS_I2C_COMM_FAILURE); // Sensor did not ACK + (void)maxWait; // Do something with maxWait just to avoid the pesky compiler warnings! + return (SFE_UBLOX_STATUS_SUCCESS); } @@ -4784,7 +4782,7 @@ void SFE_UBLOX_GNSS::sendSerialCommand(ubxPacket *outgoingUBX) void SFE_UBLOX_GNSS::spiTransfer(uint8_t byteToTransfer) { uint8_t returnedByte = _spiPort->transfer(byteToTransfer); - if ((spiBufferIndex < getSpiTransactionSize()) && (returnedByte != 0xFF || currentSentence != NONE)) + if ((spiBufferIndex < getSpiTransactionSize()) && (returnedByte != 0xFF || currentSentence != SFE_UBLOX_SENTENCE_TYPE_NONE)) { spiBuffer[spiBufferIndex] = returnedByte; spiBufferIndex++; @@ -17497,8 +17495,7 @@ uint16_t SFE_UBLOX_GNSS::getMagAcc(uint16_t maxWait) // getGeoidSeparation is currently redundant. The geoid separation seems to only be provided in NMEA GGA and GNS messages. int32_t SFE_UBLOX_GNSS::getGeoidSeparation(uint16_t maxWait) { - uint16_t ignoreMe = maxWait; - ignoreMe += 0; // Do something with maxWait just to get rid of the pesky compiler warning + (void)maxWait; // Do something with maxWait just to get rid of the pesky compiler warning return (0); } diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index a7a2e3d..b929214 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -647,13 +647,13 @@ class SFE_UBLOX_GNSS ~SFE_UBLOX_GNSS(void); // Depending on the sentence type the processor will load characters into different arrays - enum SentenceTypes + enum sfe_ublox_sentence_types_e { - NONE = 0, - NMEA, - UBX, - RTCM - } currentSentence = NONE; + SFE_UBLOX_SENTENCE_TYPE_NONE = 0, + SFE_UBLOX_SENTENCE_TYPE_NMEA, + SFE_UBLOX_SENTENCE_TYPE_UBX, + SFE_UBLOX_SENTENCE_TYPE_RTCM + } currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // A default of 250ms for maxWait seems fine for I2C but is not enough for SerialUSB. // If you know you are only going to be using I2C / Qwiic communication, you can @@ -747,7 +747,7 @@ class SFE_UBLOX_GNSS void process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Processes NMEA and UBX binary sentences one byte at a time 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 - SentenceTypes processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) __attribute__((weak)); // Monitor the incoming bytes for start and length bytes + sfe_ublox_sentence_types_e processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) __attribute__((weak)); // Monitor the incoming bytes for start and length bytes 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. void processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Given a character, file it away into the uxb packet structure void processUBXpacket(ubxPacket *msg); // Once a packet has been received and validated, identify this packet's class/id and update internal flags From 25d60b146a1174c9f0b9aedad466e444f3381d14 Mon Sep 17 00:00:00 2001 From: PaulZC Date: Mon, 1 Aug 2022 13:05:54 +0100 Subject: [PATCH 3/4] Whitespace and formatting changes --- src/SparkFun_u-blox_GNSS_Arduino_Library.cpp | 48 +++++----- src/SparkFun_u-blox_GNSS_Arduino_Library.h | 96 ++++++++++---------- 2 files changed, 73 insertions(+), 71 deletions(-) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp index 6acf8d2..6033a73 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.cpp @@ -345,7 +345,7 @@ void SFE_UBLOX_GNSS::end(void) { if (packetUBXRXMQZSSL6message->callbackData != NULL) { - delete [] packetUBXRXMQZSSL6message->callbackData; + delete[] packetUBXRXMQZSSL6message->callbackData; } delete packetUBXRXMQZSSL6message; packetUBXRXMQZSSL6message = NULL; // Redundant? @@ -1721,9 +1721,9 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r { // Decide what type of response this is if ((ubxFrameCounter == 0) && (incoming != UBX_SYNCH_1)) // ISO 'μ' - currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. else if ((ubxFrameCounter == 1) && (incoming != UBX_SYNCH_2)) // ASCII 'b' - currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. // Note to future self: // There may be some duplication / redundancy in the next few lines as processUBX will also // load information into packetBuf, but we'll do it here too for clarity @@ -2028,8 +2028,8 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r nmeaByteCounter++; // Increment the byte counter - if (nmeaByteCounter == maxNMEAByteCount) // Check if we have processed too many bytes - currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. + if (nmeaByteCounter == maxNMEAByteCount) // Check if we have processed too many bytes + currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. if (nmeaByteCounter == 0) // Check if we are done { @@ -2876,7 +2876,7 @@ nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr() // Byte 2: 10-bits of length of this packet including the first two-ish header bytes, + 6. // byte 3 + 4 bits: Msg type 12 bits // Example: D3 00 7C 43 F0 ... / 0x7C = 124+6 = 130 bytes in this packet, 0x43F = Msg type 1087 -SFE_UBLOX_GNSS::sfe_ublox_sentence_types_e SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) +SFE_UBLOX_GNSS::sfe_ublox_sentence_types_e SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t *rtcmFrameCounter) { static uint16_t rtcmLen = 0; @@ -3614,8 +3614,8 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg) packetUBXNAVTIMEUTC->moduleQueried.moduleQueried.all = 0xFFFFFFFF; // Check if we need to copy the data for the callback - if ((packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data - && (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == false)) // AND the data is stale + if ((packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data + && (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == false)) // AND the data is stale { memcpy(&packetUBXNAVTIMEUTC->callbackData->iTOW, &packetUBXNAVTIMEUTC->data.iTOW, sizeof(UBX_NAV_TIMEUTC_data_t)); packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid = true; @@ -3943,8 +3943,10 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg) // Note: the field positions depend on the version { // Full QZSSL6 message, including Class, ID and checksum - for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch ++) { - if (0 == (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch))) { + for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch++) + { + if (0 == (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch))) + { packetUBXRXMQZSSL6message->callbackData[ch].sync1 = UBX_SYNCH_1; packetUBXRXMQZSSL6message->callbackData[ch].sync2 = UBX_SYNCH_2; @@ -5466,9 +5468,9 @@ void SFE_UBLOX_GNSS::checkCallbacks(void) packetUBXNAVPVAT->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale } - if ((packetUBXNAVTIMEUTC != NULL) // If RAM has been allocated for message storage - && (packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data - && (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid + if ((packetUBXNAVTIMEUTC != NULL) // If RAM has been allocated for message storage + && (packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data + && (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid { if (packetUBXNAVTIMEUTC->callbackPointerPtr != NULL) // If the pointer to the callback has been defined { @@ -5568,9 +5570,9 @@ void SFE_UBLOX_GNSS::checkCallbacks(void) packetUBXNAVAOPSTATUS->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale } - if ((packetUBXNAVEOE != NULL) // If RAM has been allocated for message storage - && (packetUBXNAVEOE->callbackData != NULL) // If RAM has been allocated for the copy of the data - && (packetUBXNAVEOE->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid + if ((packetUBXNAVEOE != NULL) // If RAM has been allocated for message storage + && (packetUBXNAVEOE->callbackData != NULL) // If RAM has been allocated for the copy of the data + && (packetUBXNAVEOE->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid { if (packetUBXNAVEOE->callbackPointerPtr != NULL) // If the pointer to the callback has been defined { @@ -5603,15 +5605,16 @@ void SFE_UBLOX_GNSS::checkCallbacks(void) packetUBXRXMPMPmessage->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale } - if ((packetUBXRXMQZSSL6message != NULL) && // If RAM has been allocated for message storage - (packetUBXRXMQZSSL6message->callbackData != NULL) && // If RAM has been allocated for the copy of the data - (packetUBXRXMQZSSL6message->callbackPointerPtr != NULL)) // If the pointer to the callback has been defined + if ((packetUBXRXMQZSSL6message != NULL) && // If RAM has been allocated for message storage + (packetUBXRXMQZSSL6message->callbackData != NULL) && // If RAM has been allocated for the copy of the data + (packetUBXRXMQZSSL6message->callbackPointerPtr != NULL)) // If the pointer to the callback has been defined { - for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch ++) { + for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch++) + { if (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch)) // If the copy of the data is valid { - packetUBXRXMQZSSL6message->callbackPointerPtr( &packetUBXRXMQZSSL6message->callbackData[ch] ); // Call the callback - packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid &= ~(1 << ch); // clear it + packetUBXRXMQZSSL6message->callbackPointerPtr(&packetUBXRXMQZSSL6message->callbackData[ch]); // Call the callback + packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid &= ~(1 << ch); // clear it } } } @@ -13127,7 +13130,6 @@ bool SFE_UBLOX_GNSS::initPacketUBXRXMQZSSL6message() return (true); } - bool SFE_UBLOX_GNSS::setRXMCORcallbackPtr(void (*callbackPointer)(UBX_RXM_COR_data_t *)) { if (packetUBXRXMCOR == NULL) diff --git a/src/SparkFun_u-blox_GNSS_Arduino_Library.h b/src/SparkFun_u-blox_GNSS_Arduino_Library.h index b929214..763b86f 100644 --- a/src/SparkFun_u-blox_GNSS_Arduino_Library.h +++ b/src/SparkFun_u-blox_GNSS_Arduino_Library.h @@ -745,12 +745,12 @@ class SFE_UBLOX_GNSS // Process the incoming data - void process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Processes NMEA and UBX binary sentences one byte at a time - 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 - sfe_ublox_sentence_types_e processRTCMframe(uint8_t incoming, uint16_t * rtcmFrameCounter) __attribute__((weak)); // Monitor the incoming bytes for start and length bytes - 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. - void processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Given a character, file it away into the uxb packet structure - void processUBXpacket(ubxPacket *msg); // Once a packet has been received and validated, identify this packet's class/id and update internal flags + void process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Processes NMEA and UBX binary sentences one byte at a time + 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 + sfe_ublox_sentence_types_e processRTCMframe(uint8_t incoming, uint16_t *rtcmFrameCounter) __attribute__((weak)); // Monitor the incoming bytes for start and length bytes + 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. + void processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID); // Given a character, file it away into the uxb packet structure + void processUBXpacket(ubxPacket *msg); // Once a packet has been received and validated, identify this packet's class/id and update internal flags // Send I2C/Serial/SPI commands to the module @@ -1552,12 +1552,12 @@ class SFE_UBLOX_GNSS UBX_NAV_RELPOSNED_t *packetUBXNAVRELPOSNED = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary UBX_NAV_AOPSTATUS_t *packetUBXNAVAOPSTATUS = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary - UBX_RXM_PMP_t *packetUBXRXMPMP = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary - UBX_RXM_PMP_message_t *packetUBXRXMPMPmessage = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + UBX_RXM_PMP_t *packetUBXRXMPMP = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + UBX_RXM_PMP_message_t *packetUBXRXMPMPmessage = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary UBX_RXM_QZSSL6_message_t *packetUBXRXMQZSSL6message = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary - UBX_RXM_COR_t *packetUBXRXMCOR = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary - UBX_RXM_SFRBX_t *packetUBXRXMSFRBX = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary - UBX_RXM_RAWX_t *packetUBXRXMRAWX = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + UBX_RXM_COR_t *packetUBXRXMCOR = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + UBX_RXM_SFRBX_t *packetUBXRXMSFRBX = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary + UBX_RXM_RAWX_t *packetUBXRXMRAWX = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary UBX_CFG_PRT_t *packetUBXCFGPRT = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary UBX_CFG_RATE_t *packetUBXCFGRATE = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary @@ -1626,44 +1626,44 @@ class SFE_UBLOX_GNSS // The initPacket functions need to be private as they don't check if memory has already been allocated. // Functions like setAutoNAVPOSECEF will check that memory has not been allocated before calling initPacket. - bool initPacketUBXNAVPOSECEF(); // Allocate RAM for packetUBXNAVPOSECEF and initialize it - bool initPacketUBXNAVSTATUS(); // Allocate RAM for packetUBXNAVSTATUS and initialize it - bool initPacketUBXNAVDOP(); // Allocate RAM for packetUBXNAVDOP and initialize it - bool initPacketUBXNAVATT(); // Allocate RAM for packetUBXNAVATT and initialize it - bool initPacketUBXNAVPVT(); // Allocate RAM for packetUBXNAVPVT and initialize it - bool initPacketUBXNAVODO(); // Allocate RAM for packetUBXNAVODO and initialize it - bool initPacketUBXNAVVELECEF(); // Allocate RAM for packetUBXNAVVELECEF and initialize it - bool initPacketUBXNAVVELNED(); // Allocate RAM for packetUBXNAVVELNED and initialize it - bool initPacketUBXNAVHPPOSECEF(); // Allocate RAM for packetUBXNAVHPPOSECEF and initialize it - bool initPacketUBXNAVHPPOSLLH(); // Allocate RAM for packetUBXNAVHPPOSLLH and initialize it - bool initPacketUBXNAVPVAT(); // Allocate RAM for packetUBXNAVPVAT and initialize it - bool initPacketUBXNAVTIMEUTC(); // Allocate RAM for packetUBXNAVTIMEUTC and initialize it - bool initPacketUBXNAVCLOCK(); // Allocate RAM for packetUBXNAVCLOCK and initialize it - bool initPacketUBXNAVTIMELS(); // Allocate RAM for packetUBXNAVTIMELS and initialize it - bool initPacketUBXNAVSVIN(); // Allocate RAM for packetUBXNAVSVIN and initialize it - bool initPacketUBXNAVSAT(); // Allocate RAM for packetUBXNAVSAT and initialize it - bool initPacketUBXNAVRELPOSNED(); // Allocate RAM for packetUBXNAVRELPOSNED and initialize it - bool initPacketUBXNAVAOPSTATUS(); // Allocate RAM for packetUBXNAVAOPSTATUS and initialize it - bool initPacketUBXNAVEOE(); // Allocate RAM for packetUBXNAVEOE and initialize it - bool initPacketUBXRXMPMP(); // Allocate RAM for packetUBXRXMPMP and initialize it - bool initPacketUBXRXMPMPmessage(); // Allocate RAM for packetUBXRXMPMPRaw and initialize it + bool initPacketUBXNAVPOSECEF(); // Allocate RAM for packetUBXNAVPOSECEF and initialize it + bool initPacketUBXNAVSTATUS(); // Allocate RAM for packetUBXNAVSTATUS and initialize it + bool initPacketUBXNAVDOP(); // Allocate RAM for packetUBXNAVDOP and initialize it + bool initPacketUBXNAVATT(); // Allocate RAM for packetUBXNAVATT and initialize it + bool initPacketUBXNAVPVT(); // Allocate RAM for packetUBXNAVPVT and initialize it + bool initPacketUBXNAVODO(); // Allocate RAM for packetUBXNAVODO and initialize it + bool initPacketUBXNAVVELECEF(); // Allocate RAM for packetUBXNAVVELECEF and initialize it + bool initPacketUBXNAVVELNED(); // Allocate RAM for packetUBXNAVVELNED and initialize it + bool initPacketUBXNAVHPPOSECEF(); // Allocate RAM for packetUBXNAVHPPOSECEF and initialize it + bool initPacketUBXNAVHPPOSLLH(); // Allocate RAM for packetUBXNAVHPPOSLLH and initialize it + bool initPacketUBXNAVPVAT(); // Allocate RAM for packetUBXNAVPVAT and initialize it + bool initPacketUBXNAVTIMEUTC(); // Allocate RAM for packetUBXNAVTIMEUTC and initialize it + bool initPacketUBXNAVCLOCK(); // Allocate RAM for packetUBXNAVCLOCK and initialize it + bool initPacketUBXNAVTIMELS(); // Allocate RAM for packetUBXNAVTIMELS and initialize it + bool initPacketUBXNAVSVIN(); // Allocate RAM for packetUBXNAVSVIN and initialize it + bool initPacketUBXNAVSAT(); // Allocate RAM for packetUBXNAVSAT and initialize it + bool initPacketUBXNAVRELPOSNED(); // Allocate RAM for packetUBXNAVRELPOSNED and initialize it + bool initPacketUBXNAVAOPSTATUS(); // Allocate RAM for packetUBXNAVAOPSTATUS and initialize it + bool initPacketUBXNAVEOE(); // Allocate RAM for packetUBXNAVEOE and initialize it + bool initPacketUBXRXMPMP(); // Allocate RAM for packetUBXRXMPMP and initialize it + bool initPacketUBXRXMPMPmessage(); // Allocate RAM for packetUBXRXMPMPRaw and initialize it bool initPacketUBXRXMQZSSL6message(); // Allocate RAM for packetUBXRXMQZSSL6raw and initialize it - bool initPacketUBXRXMCOR(); // Allocate RAM for packetUBXRXMCOR and initialize it - bool initPacketUBXRXMSFRBX(); // Allocate RAM for packetUBXRXMSFRBX and initialize it - bool initPacketUBXRXMRAWX(); // Allocate RAM for packetUBXRXMRAWX and initialize it - bool initPacketUBXCFGPRT(); // Allocate RAM for packetUBXCFGPRT and initialize it - bool initPacketUBXCFGRATE(); // Allocate RAM for packetUBXCFGRATE and initialize it - bool initPacketUBXTIMTM2(); // Allocate RAM for packetUBXTIMTM2 and initialize it - bool initPacketUBXESFALG(); // Allocate RAM for packetUBXESFALG and initialize it - bool initPacketUBXESFSTATUS(); // Allocate RAM for packetUBXESFSTATUS and initialize it - bool initPacketUBXESFINS(); // Allocate RAM for packetUBXESFINS and initialize it - bool initPacketUBXESFMEAS(); // Allocate RAM for packetUBXESFMEAS and initialize it - bool initPacketUBXESFRAW(); // Allocate RAM for packetUBXESFRAW and initialize it - bool initPacketUBXHNRATT(); // Allocate RAM for packetUBXHNRATT and initialize it - bool initPacketUBXHNRINS(); // Allocate RAM for packetUBXHNRINS and initialize it - bool initPacketUBXHNRPVT(); // Allocate RAM for packetUBXHNRPVT and initialize it - bool initPacketUBXMGAACK(); // Allocate RAM for packetUBXMGAACK and initialize it - bool initPacketUBXMGADBD(); // Allocate RAM for packetUBXMGADBD and initialize it + bool initPacketUBXRXMCOR(); // Allocate RAM for packetUBXRXMCOR and initialize it + bool initPacketUBXRXMSFRBX(); // Allocate RAM for packetUBXRXMSFRBX and initialize it + bool initPacketUBXRXMRAWX(); // Allocate RAM for packetUBXRXMRAWX and initialize it + bool initPacketUBXCFGPRT(); // Allocate RAM for packetUBXCFGPRT and initialize it + bool initPacketUBXCFGRATE(); // Allocate RAM for packetUBXCFGRATE and initialize it + bool initPacketUBXTIMTM2(); // Allocate RAM for packetUBXTIMTM2 and initialize it + bool initPacketUBXESFALG(); // Allocate RAM for packetUBXESFALG and initialize it + bool initPacketUBXESFSTATUS(); // Allocate RAM for packetUBXESFSTATUS and initialize it + bool initPacketUBXESFINS(); // Allocate RAM for packetUBXESFINS and initialize it + bool initPacketUBXESFMEAS(); // Allocate RAM for packetUBXESFMEAS and initialize it + bool initPacketUBXESFRAW(); // Allocate RAM for packetUBXESFRAW and initialize it + bool initPacketUBXHNRATT(); // Allocate RAM for packetUBXHNRATT and initialize it + bool initPacketUBXHNRINS(); // Allocate RAM for packetUBXHNRINS and initialize it + bool initPacketUBXHNRPVT(); // Allocate RAM for packetUBXHNRPVT and initialize it + bool initPacketUBXMGAACK(); // Allocate RAM for packetUBXMGAACK and initialize it + bool initPacketUBXMGADBD(); // Allocate RAM for packetUBXMGADBD and initialize it #ifndef SFE_UBLOX_DISABLE_AUTO_NMEA bool initStorageNMEAGPGGA(); // Allocate RAM for incoming NMEA GPGGA messages and initialize it From 11a8e402a3e62df19c9ce400fdbda058f358ac35 Mon Sep 17 00:00:00 2001 From: Paul Date: Wed, 3 Aug 2022 09:42:18 +0100 Subject: [PATCH 4/4] v2.2.13 --- library.properties | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/library.properties b/library.properties index 7959456..b202b64 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.2.12 +version=2.2.13 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules