Merge pull request #148 from sparkfun/release_candidate

v2.2.13
This commit is contained in:
Paul
2022-08-03 09:46:01 +01:00
committed by GitHub
3 changed files with 118 additions and 122 deletions
+1 -1
View File
@@ -1,5 +1,5 @@
name=SparkFun u-blox GNSS Arduino Library
version=2.2.12
version=2.2.13
author=SparkFun Electronics <techsupport@sparkfun.com>
maintainer=SparkFun Electronics <sparkfun.com>
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>
+40 -42
View File
@@ -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?
@@ -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,12 +2109,12 @@ 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)
{
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::sfe_ublox_sentence_types_e 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 = *rtcmFrameCounter + 1;
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) ? SFE_UBLOX_SENTENCE_TYPE_NONE : SFE_UBLOX_SENTENCE_TYPE_RTCM;
}
// This function is called for each byte of an RTCM frame
@@ -2912,9 +2911,6 @@ void 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
@@ -2924,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
@@ -2996,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))
@@ -3164,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
{
@@ -3945,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;
@@ -4621,9 +4621,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
@@ -4755,6 +4752,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);
}
@@ -4785,7 +4784,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++;
@@ -5610,10 +5609,11 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
(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->callbackPointerPtr(&packetUBXRXMQZSSL6message->callbackData[ch]); // Call the callback
packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid &= ~(1 << ch); // clear it
}
}
@@ -13130,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)
@@ -17498,8 +17497,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);
}
+10 -12
View File
@@ -646,6 +646,15 @@ public:
SFE_UBLOX_GNSS(void);
~SFE_UBLOX_GNSS(void);
// Depending on the sentence type the processor will load characters into different arrays
enum sfe_ublox_sentence_types_e
{
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
// safely reduce defaultMaxWait to 250.
@@ -738,7 +747,7 @@ public:
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
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
@@ -1582,15 +1591,6 @@ public:
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 @@ private:
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;