Skip to content

Commit 20e265d

Browse files
authored
Merge pull request #148 from sparkfun/release_candidate
v2.2.13
2 parents 99ab25b + 11a8e40 commit 20e265d

3 files changed

+118
-122
lines changed

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS Arduino Library
2-
version=2.2.12
2+
version=2.2.13
33
author=SparkFun Electronics <techsupport@sparkfun.com>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 59 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -345,12 +345,12 @@ void SFE_UBLOX_GNSS::end(void)
345345
{
346346
if (packetUBXRXMQZSSL6message->callbackData != NULL)
347347
{
348-
delete [] packetUBXRXMQZSSL6message->callbackData;
348+
delete[] packetUBXRXMQZSSL6message->callbackData;
349349
}
350350
delete packetUBXRXMQZSSL6message;
351351
packetUBXRXMQZSSL6message = NULL; // Redundant?
352352
}
353-
353+
354354
if (packetUBXRXMCOR != NULL)
355355
{
356356
if (packetUBXRXMCOR->callbackData != NULL)
@@ -1284,15 +1284,15 @@ bool SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedClas
12841284

12851285
// If we are not receiving a sentence (currentSentence == NONE) and the byteReturned is 0xFF,
12861286
// i.e. the module has no data for us, then delay for
1287-
if ((byteReturned == 0xFF) && (currentSentence == NONE))
1287+
if ((byteReturned == 0xFF) && (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NONE))
12881288
{
12891289
digitalWrite(_csPin, HIGH);
12901290
_spiPort->endTransaction();
12911291
delay(spiPollingWait);
12921292
return (true);
12931293
}
12941294

1295-
while ((byteReturned != 0xFF) || (currentSentence != NONE))
1295+
while ((byteReturned != 0xFF) || (currentSentence != SFE_UBLOX_SENTENCE_TYPE_NONE))
12961296
{
12971297
process(byteReturned, incomingUBX, requestedClass, requestedID);
12981298
byteReturned = _spiPort->transfer(0xFF);
@@ -1686,14 +1686,14 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
16861686
{
16871687
if (_outputPort != NULL)
16881688
_outputPort->write(incoming); // Echo this byte to the serial port
1689-
if ((currentSentence == NONE) || (currentSentence == NMEA))
1689+
if ((currentSentence == SFE_UBLOX_SENTENCE_TYPE_NONE) || (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NMEA))
16901690
{
16911691
if (incoming == UBX_SYNCH_1) // UBX binary frames start with 0xB5, aka μ
16921692
{
16931693
// This is the start of a binary sentence. Reset flags.
16941694
// We still don't know the response class
16951695
ubxFrameCounter = 0;
1696-
currentSentence = UBX;
1696+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_UBX;
16971697
// Reset the packetBuf.counter even though we will need to reset it again when ubxFrameCounter == 2
16981698
packetBuf.counter = 0;
16991699
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
17031703
else if (incoming == '$')
17041704
{
17051705
nmeaByteCounter = 0; // Reset the NMEA byte counter
1706-
currentSentence = NMEA;
1706+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NMEA;
17071707
}
17081708
else if (incoming == 0xD3) // RTCM frames start with 0xD3
17091709
{
17101710
rtcmFrameCounter = 0;
1711-
currentSentence = RTCM;
1711+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_RTCM;
17121712
}
17131713
else
17141714
{
@@ -1717,13 +1717,13 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
17171717
}
17181718

17191719
// Depending on the sentence, pass the character to the individual processor
1720-
if (currentSentence == UBX)
1720+
if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_UBX)
17211721
{
17221722
// Decide what type of response this is
17231723
if ((ubxFrameCounter == 0) && (incoming != UBX_SYNCH_1)) // ISO 'μ'
1724-
currentSentence = NONE; // Something went wrong. Reset.
1724+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset.
17251725
else if ((ubxFrameCounter == 1) && (incoming != UBX_SYNCH_2)) // ASCII 'b'
1726-
currentSentence = NONE; // Something went wrong. Reset.
1726+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset.
17271727
// Note to future self:
17281728
// There may be some duplication / redundancy in the next few lines as processUBX will also
17291729
// 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
19361936
// Finally, increment the frame counter
19371937
ubxFrameCounter++;
19381938
}
1939-
else if (currentSentence == NMEA) // Process incoming NMEA mesages. Selectively log if desired.
1939+
else if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_NMEA) // Process incoming NMEA mesages. Selectively log if desired.
19401940
{
19411941
if ((nmeaByteCounter == 0) && (incoming != '$'))
19421942
{
1943-
currentSentence = NONE; // Something went wrong. Reset. (Almost certainly redundant!)
1943+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset. (Almost certainly redundant!)
19441944
}
19451945
else if ((nmeaByteCounter == 1) && (incoming != 'G'))
19461946
{
1947-
currentSentence = NONE; // Something went wrong. Reset.
1947+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset.
19481948
}
19491949
else if ((nmeaByteCounter >= 0) && (nmeaByteCounter <= 5))
19501950
{
@@ -2028,8 +2028,8 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
20282028

20292029
nmeaByteCounter++; // Increment the byte counter
20302030

2031-
if (nmeaByteCounter == maxNMEAByteCount) // Check if we have processed too many bytes
2032-
currentSentence = NONE; // Something went wrong. Reset.
2031+
if (nmeaByteCounter == maxNMEAByteCount) // Check if we have processed too many bytes
2032+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Something went wrong. Reset.
20332033

20342034
if (nmeaByteCounter == 0) // Check if we are done
20352035
{
@@ -2109,12 +2109,12 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
21092109
}
21102110
}
21112111
#endif
2112-
currentSentence = NONE; // All done!
2112+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // All done!
21132113
}
21142114
}
2115-
else if (currentSentence == RTCM)
2115+
else if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_RTCM)
21162116
{
2117-
processRTCMframe(incoming); // Deal with RTCM bytes
2117+
currentSentence = processRTCMframe(incoming, &rtcmFrameCounter); // Deal with RTCM bytes
21182118
}
21192119
}
21202120

@@ -2876,13 +2876,15 @@ nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr()
28762876
// Byte 2: 10-bits of length of this packet including the first two-ish header bytes, + 6.
28772877
// byte 3 + 4 bits: Msg type 12 bits
28782878
// Example: D3 00 7C 43 F0 ... / 0x7C = 124+6 = 130 bytes in this packet, 0x43F = Msg type 1087
2879-
void SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming)
2879+
SFE_UBLOX_GNSS::sfe_ublox_sentence_types_e SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming, uint16_t *rtcmFrameCounter)
28802880
{
2881-
if (rtcmFrameCounter == 1)
2881+
static uint16_t rtcmLen = 0;
2882+
2883+
if (*rtcmFrameCounter == 1)
28822884
{
28832885
rtcmLen = (incoming & 0x03) << 8; // Get the last two bits of this byte. Bits 8&9 of 10-bit length
28842886
}
2885-
else if (rtcmFrameCounter == 2)
2887+
else if (*rtcmFrameCounter == 2)
28862888
{
28872889
rtcmLen |= incoming; // Bits 0-7 of packet length
28882890
rtcmLen += 6; // There are 6 additional bytes of what we presume is header, msgType, CRC, and stuff
@@ -2896,25 +2898,19 @@ void SFE_UBLOX_GNSS::processRTCMframe(uint8_t incoming)
28962898
rtcmMsgType |= (incoming >> 4); //Message Type, bits 0-7
28972899
}*/
28982900

2899-
rtcmFrameCounter++;
2901+
*rtcmFrameCounter = *rtcmFrameCounter + 1;
29002902

29012903
processRTCM(incoming); // Here is where we expose this byte to the user
29022904

2903-
if (rtcmFrameCounter == rtcmLen)
2904-
{
2905-
// We're done!
2906-
currentSentence = NONE; // Reset and start looking for next sentence type
2907-
}
2905+
// Reset and start looking for next sentence type when done
2906+
return (*rtcmFrameCounter == rtcmLen) ? SFE_UBLOX_SENTENCE_TYPE_NONE : SFE_UBLOX_SENTENCE_TYPE_RTCM;
29082907
}
29092908

29102909
// This function is called for each byte of an RTCM frame
29112910
// Ths user can overwrite this function and process the RTCM frame as they please
29122911
// Bytes can be piped to Serial or other interface. The consumer could be a radio or the internet (Ntrip broadcaster)
29132912
void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
29142913
{
2915-
uint8_t ignoreMe = incoming;
2916-
ignoreMe += 0; // Do something with incoming just to get rid of the pesky compiler warning!
2917-
29182914
// Radio.sendReliable((String)incoming); //An example of passing this byte to a radio
29192915

29202916
//_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)
29242920
// if(incoming < 0x10) _debugSerial->print(F("0"));
29252921
// _debugSerial->print(incoming, HEX);
29262922
// if(rtcmFrameCounter % 16 == 0) _debugSerial->println();
2923+
2924+
(void)incoming; // Do something with incoming just to get rid of the pesky compiler warning!
29272925
}
29282926

29292927
// 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_
29962994
{
29972995
incomingUBX->checksumB = incoming;
29982996

2999-
currentSentence = NONE; // We're done! Reset the sentence to being looking for a new start char
2997+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // We're done! Reset the sentence to being looking for a new start char
30002998

30012999
// Validate this sentence
30023000
if ((incomingUBX->checksumA == rollingChecksumA) && (incomingUBX->checksumB == rollingChecksumB))
@@ -3164,7 +3162,7 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_
31643162
if (overrun || ((incomingUBX->counter == maximum_payload_size + 6) && (ignoreThisPayload == false)))
31653163
{
31663164
// Something has gone very wrong
3167-
currentSentence = NONE; // Reset the sentence to being looking for a new start char
3165+
currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE; // Reset the sentence to being looking for a new start char
31683166
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
31693167
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
31703168
{
@@ -3616,8 +3614,8 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
36163614
packetUBXNAVTIMEUTC->moduleQueried.moduleQueried.all = 0xFFFFFFFF;
36173615

36183616
// Check if we need to copy the data for the callback
3619-
if ((packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data
3620-
&& (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == false)) // AND the data is stale
3617+
if ((packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data
3618+
&& (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == false)) // AND the data is stale
36213619
{
36223620
memcpy(&packetUBXNAVTIMEUTC->callbackData->iTOW, &packetUBXNAVTIMEUTC->data.iTOW, sizeof(UBX_NAV_TIMEUTC_data_t));
36233621
packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid = true;
@@ -3944,10 +3942,12 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
39443942
// Note: length is variable with version 0x01
39453943
// Note: the field positions depend on the version
39463944
{
3947-
// Full QZSSL6 message, including Class, ID and checksum
3948-
for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch ++) {
3949-
if (0 == (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch))) {
3950-
3945+
// Full QZSSL6 message, including Class, ID and checksum
3946+
for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch++)
3947+
{
3948+
if (0 == (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch)))
3949+
{
3950+
39513951
packetUBXRXMQZSSL6message->callbackData[ch].sync1 = UBX_SYNCH_1;
39523952
packetUBXRXMQZSSL6message->callbackData[ch].sync2 = UBX_SYNCH_2;
39533953
packetUBXRXMQZSSL6message->callbackData[ch].cls = UBX_CLASS_RXM;
@@ -3958,12 +3958,12 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
39583958
memcpy(packetUBXRXMQZSSL6message->callbackData[ch].payload, msg->payload, msg->len);
39593959

39603960
packetUBXRXMQZSSL6message->callbackData[ch].checksumA = msg->checksumA;
3961-
packetUBXRXMQZSSL6message->callbackData[ch].checksumB = msg->checksumB;
3961+
packetUBXRXMQZSSL6message->callbackData[ch].checksumB = msg->checksumB;
39623962

39633963
packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid |= (1 << ch);
39643964
break; // abort when added
39653965
}
3966-
}
3966+
}
39673967
}
39683968
else if (msg->id == UBX_RXM_COR)
39693969
{
@@ -4621,9 +4621,6 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t
46214621
// Returns false if sensor fails to respond to I2C traffic
46224622
sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16_t maxWait)
46234623
{
4624-
uint16_t ignoreMe = maxWait;
4625-
ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings!
4626-
46274624
// From the integration guide:
46284625
// "The receiver does not provide any write access except for writing UBX and NMEA messages to the
46294626
// 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
47554752
if (_i2cPort->endTransmission() != 0)
47564753
return (SFE_UBLOX_STATUS_I2C_COMM_FAILURE); // Sensor did not ACK
47574754

4755+
(void)maxWait; // Do something with maxWait just to avoid the pesky compiler warnings!
4756+
47584757
return (SFE_UBLOX_STATUS_SUCCESS);
47594758
}
47604759

@@ -4785,7 +4784,7 @@ void SFE_UBLOX_GNSS::sendSerialCommand(ubxPacket *outgoingUBX)
47854784
void SFE_UBLOX_GNSS::spiTransfer(uint8_t byteToTransfer)
47864785
{
47874786
uint8_t returnedByte = _spiPort->transfer(byteToTransfer);
4788-
if ((spiBufferIndex < getSpiTransactionSize()) && (returnedByte != 0xFF || currentSentence != NONE))
4787+
if ((spiBufferIndex < getSpiTransactionSize()) && (returnedByte != 0xFF || currentSentence != SFE_UBLOX_SENTENCE_TYPE_NONE))
47894788
{
47904789
spiBuffer[spiBufferIndex] = returnedByte;
47914790
spiBufferIndex++;
@@ -5469,9 +5468,9 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
54695468
packetUBXNAVPVAT->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
54705469
}
54715470

5472-
if ((packetUBXNAVTIMEUTC != NULL) // If RAM has been allocated for message storage
5473-
&& (packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data
5474-
&& (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid
5471+
if ((packetUBXNAVTIMEUTC != NULL) // If RAM has been allocated for message storage
5472+
&& (packetUBXNAVTIMEUTC->callbackData != NULL) // If RAM has been allocated for the copy of the data
5473+
&& (packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid
54755474
{
54765475
if (packetUBXNAVTIMEUTC->callbackPointerPtr != NULL) // If the pointer to the callback has been defined
54775476
{
@@ -5571,9 +5570,9 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
55715570
packetUBXNAVAOPSTATUS->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
55725571
}
55735572

5574-
if ((packetUBXNAVEOE != NULL) // If RAM has been allocated for message storage
5575-
&& (packetUBXNAVEOE->callbackData != NULL) // If RAM has been allocated for the copy of the data
5576-
&& (packetUBXNAVEOE->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid
5573+
if ((packetUBXNAVEOE != NULL) // If RAM has been allocated for message storage
5574+
&& (packetUBXNAVEOE->callbackData != NULL) // If RAM has been allocated for the copy of the data
5575+
&& (packetUBXNAVEOE->automaticFlags.flags.bits.callbackCopyValid == true)) // If the copy of the data is valid
55775576
{
55785577
if (packetUBXNAVEOE->callbackPointerPtr != NULL) // If the pointer to the callback has been defined
55795578
{
@@ -5605,16 +5604,17 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
56055604
packetUBXRXMPMPmessage->callbackPointerPtr(packetUBXRXMPMPmessage->callbackData); // Call the callback
56065605
packetUBXRXMPMPmessage->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
56075606
}
5608-
5609-
if ((packetUBXRXMQZSSL6message != NULL) && // If RAM has been allocated for message storage
5610-
(packetUBXRXMQZSSL6message->callbackData != NULL) && // If RAM has been allocated for the copy of the data
5611-
(packetUBXRXMQZSSL6message->callbackPointerPtr != NULL)) // If the pointer to the callback has been defined
5607+
5608+
if ((packetUBXRXMQZSSL6message != NULL) && // If RAM has been allocated for message storage
5609+
(packetUBXRXMQZSSL6message->callbackData != NULL) && // If RAM has been allocated for the copy of the data
5610+
(packetUBXRXMQZSSL6message->callbackPointerPtr != NULL)) // If the pointer to the callback has been defined
56125611
{
5613-
for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch ++) {
5612+
for (int ch = 0; ch < UBX_RXM_QZSSL6_NUM_CHANNELS; ch++)
5613+
{
56145614
if (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch)) // If the copy of the data is valid
56155615
{
5616-
packetUBXRXMQZSSL6message->callbackPointerPtr( &packetUBXRXMQZSSL6message->callbackData[ch] ); // Call the callback
5617-
packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid &= ~(1 << ch); // clear it
5616+
packetUBXRXMQZSSL6message->callbackPointerPtr(&packetUBXRXMQZSSL6message->callbackData[ch]); // Call the callback
5617+
packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid &= ~(1 << ch); // clear it
56185618
}
56195619
}
56205620
}
@@ -13130,7 +13130,6 @@ bool SFE_UBLOX_GNSS::initPacketUBXRXMQZSSL6message()
1313013130
return (true);
1313113131
}
1313213132

13133-
1313413133
bool SFE_UBLOX_GNSS::setRXMCORcallbackPtr(void (*callbackPointer)(UBX_RXM_COR_data_t *))
1313513134
{
1313613135
if (packetUBXRXMCOR == NULL)
@@ -17498,8 +17497,7 @@ uint16_t SFE_UBLOX_GNSS::getMagAcc(uint16_t maxWait)
1749817497
// getGeoidSeparation is currently redundant. The geoid separation seems to only be provided in NMEA GGA and GNS messages.
1749917498
int32_t SFE_UBLOX_GNSS::getGeoidSeparation(uint16_t maxWait)
1750017499
{
17501-
uint16_t ignoreMe = maxWait;
17502-
ignoreMe += 0; // Do something with maxWait just to get rid of the pesky compiler warning
17500+
(void)maxWait; // Do something with maxWait just to get rid of the pesky compiler warning
1750317501

1750417502
return (0);
1750517503
}

0 commit comments

Comments
 (0)