@@ -345,12 +345,12 @@ void SFE_UBLOX_GNSS::end(void)
345
345
{
346
346
if (packetUBXRXMQZSSL6message->callbackData != NULL)
347
347
{
348
- delete [] packetUBXRXMQZSSL6message->callbackData;
348
+ delete[] packetUBXRXMQZSSL6message->callbackData;
349
349
}
350
350
delete packetUBXRXMQZSSL6message;
351
351
packetUBXRXMQZSSL6message = NULL; // Redundant?
352
352
}
353
-
353
+
354
354
if (packetUBXRXMCOR != NULL)
355
355
{
356
356
if (packetUBXRXMCOR->callbackData != NULL)
@@ -1284,15 +1284,15 @@ bool SFE_UBLOX_GNSS::checkUbloxSpi(ubxPacket *incomingUBX, uint8_t requestedClas
1284
1284
1285
1285
// If we are not receiving a sentence (currentSentence == NONE) and the byteReturned is 0xFF,
1286
1286
// 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 ))
1288
1288
{
1289
1289
digitalWrite(_csPin, HIGH);
1290
1290
_spiPort->endTransaction();
1291
1291
delay(spiPollingWait);
1292
1292
return (true);
1293
1293
}
1294
1294
1295
- while ((byteReturned != 0xFF) || (currentSentence != NONE ))
1295
+ while ((byteReturned != 0xFF) || (currentSentence != SFE_UBLOX_SENTENCE_TYPE_NONE ))
1296
1296
{
1297
1297
process(byteReturned, incomingUBX, requestedClass, requestedID);
1298
1298
byteReturned = _spiPort->transfer(0xFF);
@@ -1686,14 +1686,14 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
1686
1686
{
1687
1687
if (_outputPort != NULL)
1688
1688
_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 ))
1690
1690
{
1691
1691
if (incoming == UBX_SYNCH_1) // UBX binary frames start with 0xB5, aka μ
1692
1692
{
1693
1693
// This is the start of a binary sentence. Reset flags.
1694
1694
// We still don't know the response class
1695
1695
ubxFrameCounter = 0;
1696
- currentSentence = UBX ;
1696
+ currentSentence = SFE_UBLOX_SENTENCE_TYPE_UBX ;
1697
1697
// Reset the packetBuf.counter even though we will need to reset it again when ubxFrameCounter == 2
1698
1698
packetBuf.counter = 0;
1699
1699
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
1703
1703
else if (incoming == '$')
1704
1704
{
1705
1705
nmeaByteCounter = 0; // Reset the NMEA byte counter
1706
- currentSentence = NMEA ;
1706
+ currentSentence = SFE_UBLOX_SENTENCE_TYPE_NMEA ;
1707
1707
}
1708
1708
else if (incoming == 0xD3) // RTCM frames start with 0xD3
1709
1709
{
1710
1710
rtcmFrameCounter = 0;
1711
- currentSentence = RTCM ;
1711
+ currentSentence = SFE_UBLOX_SENTENCE_TYPE_RTCM ;
1712
1712
}
1713
1713
else
1714
1714
{
@@ -1717,13 +1717,13 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
1717
1717
}
1718
1718
1719
1719
// Depending on the sentence, pass the character to the individual processor
1720
- if (currentSentence == UBX )
1720
+ if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_UBX )
1721
1721
{
1722
1722
// Decide what type of response this is
1723
1723
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.
1725
1725
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.
1727
1727
// Note to future self:
1728
1728
// There may be some duplication / redundancy in the next few lines as processUBX will also
1729
1729
// 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
1936
1936
// Finally, increment the frame counter
1937
1937
ubxFrameCounter++;
1938
1938
}
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.
1940
1940
{
1941
1941
if ((nmeaByteCounter == 0) && (incoming != '$'))
1942
1942
{
1943
- currentSentence = NONE ; // Something went wrong. Reset. (Almost certainly redundant!)
1943
+ currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE ; // Something went wrong. Reset. (Almost certainly redundant!)
1944
1944
}
1945
1945
else if ((nmeaByteCounter == 1) && (incoming != 'G'))
1946
1946
{
1947
- currentSentence = NONE ; // Something went wrong. Reset.
1947
+ currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE ; // Something went wrong. Reset.
1948
1948
}
1949
1949
else if ((nmeaByteCounter >= 0) && (nmeaByteCounter <= 5))
1950
1950
{
@@ -2028,8 +2028,8 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
2028
2028
2029
2029
nmeaByteCounter++; // Increment the byte counter
2030
2030
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.
2033
2033
2034
2034
if (nmeaByteCounter == 0) // Check if we are done
2035
2035
{
@@ -2109,12 +2109,12 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
2109
2109
}
2110
2110
}
2111
2111
#endif
2112
- currentSentence = NONE ; // All done!
2112
+ currentSentence = SFE_UBLOX_SENTENCE_TYPE_NONE ; // All done!
2113
2113
}
2114
2114
}
2115
- else if (currentSentence == RTCM )
2115
+ else if (currentSentence == SFE_UBLOX_SENTENCE_TYPE_RTCM )
2116
2116
{
2117
- processRTCMframe(incoming); // Deal with RTCM bytes
2117
+ currentSentence = processRTCMframe(incoming, &rtcmFrameCounter ); // Deal with RTCM bytes
2118
2118
}
2119
2119
}
2120
2120
@@ -2876,13 +2876,15 @@ nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr()
2876
2876
// Byte 2: 10-bits of length of this packet including the first two-ish header bytes, + 6.
2877
2877
// byte 3 + 4 bits: Msg type 12 bits
2878
2878
// 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 )
2880
2880
{
2881
- if (rtcmFrameCounter == 1)
2881
+ static uint16_t rtcmLen = 0;
2882
+
2883
+ if (*rtcmFrameCounter == 1)
2882
2884
{
2883
2885
rtcmLen = (incoming & 0x03) << 8; // Get the last two bits of this byte. Bits 8&9 of 10-bit length
2884
2886
}
2885
- else if (rtcmFrameCounter == 2)
2887
+ else if (* rtcmFrameCounter == 2)
2886
2888
{
2887
2889
rtcmLen |= incoming; // Bits 0-7 of packet length
2888
2890
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)
2896
2898
rtcmMsgType |= (incoming >> 4); //Message Type, bits 0-7
2897
2899
}*/
2898
2900
2899
- rtcmFrameCounter++ ;
2901
+ * rtcmFrameCounter = *rtcmFrameCounter + 1 ;
2900
2902
2901
2903
processRTCM(incoming); // Here is where we expose this byte to the user
2902
2904
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;
2908
2907
}
2909
2908
2910
2909
// This function is called for each byte of an RTCM frame
2911
2910
// Ths user can overwrite this function and process the RTCM frame as they please
2912
2911
// Bytes can be piped to Serial or other interface. The consumer could be a radio or the internet (Ntrip broadcaster)
2913
2912
void SFE_UBLOX_GNSS::processRTCM(uint8_t incoming)
2914
2913
{
2915
- uint8_t ignoreMe = incoming;
2916
- ignoreMe += 0; // Do something with incoming just to get rid of the pesky compiler warning!
2917
-
2918
2914
// Radio.sendReliable((String)incoming); //An example of passing this byte to a radio
2919
2915
2920
2916
//_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)
2924
2920
// if(incoming < 0x10) _debugSerial->print(F("0"));
2925
2921
// _debugSerial->print(incoming, HEX);
2926
2922
// if(rtcmFrameCounter % 16 == 0) _debugSerial->println();
2923
+
2924
+ (void)incoming; // Do something with incoming just to get rid of the pesky compiler warning!
2927
2925
}
2928
2926
2929
2927
// 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_
2996
2994
{
2997
2995
incomingUBX->checksumB = incoming;
2998
2996
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
3000
2998
3001
2999
// Validate this sentence
3002
3000
if ((incomingUBX->checksumA == rollingChecksumA) && (incomingUBX->checksumB == rollingChecksumB))
@@ -3164,7 +3162,7 @@ void SFE_UBLOX_GNSS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_
3164
3162
if (overrun || ((incomingUBX->counter == maximum_payload_size + 6) && (ignoreThisPayload == false)))
3165
3163
{
3166
3164
// 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
3168
3166
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
3169
3167
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
3170
3168
{
@@ -3616,8 +3614,8 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
3616
3614
packetUBXNAVTIMEUTC->moduleQueried.moduleQueried.all = 0xFFFFFFFF;
3617
3615
3618
3616
// 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
3621
3619
{
3622
3620
memcpy(&packetUBXNAVTIMEUTC->callbackData->iTOW, &packetUBXNAVTIMEUTC->data.iTOW, sizeof(UBX_NAV_TIMEUTC_data_t));
3623
3621
packetUBXNAVTIMEUTC->automaticFlags.flags.bits.callbackCopyValid = true;
@@ -3944,10 +3942,12 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
3944
3942
// Note: length is variable with version 0x01
3945
3943
// Note: the field positions depend on the version
3946
3944
{
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
+
3951
3951
packetUBXRXMQZSSL6message->callbackData[ch].sync1 = UBX_SYNCH_1;
3952
3952
packetUBXRXMQZSSL6message->callbackData[ch].sync2 = UBX_SYNCH_2;
3953
3953
packetUBXRXMQZSSL6message->callbackData[ch].cls = UBX_CLASS_RXM;
@@ -3958,12 +3958,12 @@ void SFE_UBLOX_GNSS::processUBXpacket(ubxPacket *msg)
3958
3958
memcpy(packetUBXRXMQZSSL6message->callbackData[ch].payload, msg->payload, msg->len);
3959
3959
3960
3960
packetUBXRXMQZSSL6message->callbackData[ch].checksumA = msg->checksumA;
3961
- packetUBXRXMQZSSL6message->callbackData[ch].checksumB = msg->checksumB;
3961
+ packetUBXRXMQZSSL6message->callbackData[ch].checksumB = msg->checksumB;
3962
3962
3963
3963
packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid |= (1 << ch);
3964
3964
break; // abort when added
3965
3965
}
3966
- }
3966
+ }
3967
3967
}
3968
3968
else if (msg->id == UBX_RXM_COR)
3969
3969
{
@@ -4621,9 +4621,6 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::sendCommand(ubxPacket *outgoingUBX, uint16_t
4621
4621
// Returns false if sensor fails to respond to I2C traffic
4622
4622
sfe_ublox_status_e SFE_UBLOX_GNSS::sendI2cCommand(ubxPacket *outgoingUBX, uint16_t maxWait)
4623
4623
{
4624
- uint16_t ignoreMe = maxWait;
4625
- ignoreMe += 0; // Do something with maxWait just to avoid the pesky compiler warnings!
4626
-
4627
4624
// From the integration guide:
4628
4625
// "The receiver does not provide any write access except for writing UBX and NMEA messages to the
4629
4626
// 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
4755
4752
if (_i2cPort->endTransmission() != 0)
4756
4753
return (SFE_UBLOX_STATUS_I2C_COMM_FAILURE); // Sensor did not ACK
4757
4754
4755
+ (void)maxWait; // Do something with maxWait just to avoid the pesky compiler warnings!
4756
+
4758
4757
return (SFE_UBLOX_STATUS_SUCCESS);
4759
4758
}
4760
4759
@@ -4785,7 +4784,7 @@ void SFE_UBLOX_GNSS::sendSerialCommand(ubxPacket *outgoingUBX)
4785
4784
void SFE_UBLOX_GNSS::spiTransfer(uint8_t byteToTransfer)
4786
4785
{
4787
4786
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 ))
4789
4788
{
4790
4789
spiBuffer[spiBufferIndex] = returnedByte;
4791
4790
spiBufferIndex++;
@@ -5469,9 +5468,9 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
5469
5468
packetUBXNAVPVAT->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
5470
5469
}
5471
5470
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
5475
5474
{
5476
5475
if (packetUBXNAVTIMEUTC->callbackPointerPtr != NULL) // If the pointer to the callback has been defined
5477
5476
{
@@ -5571,9 +5570,9 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
5571
5570
packetUBXNAVAOPSTATUS->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
5572
5571
}
5573
5572
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
5577
5576
{
5578
5577
if (packetUBXNAVEOE->callbackPointerPtr != NULL) // If the pointer to the callback has been defined
5579
5578
{
@@ -5605,16 +5604,17 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
5605
5604
packetUBXRXMPMPmessage->callbackPointerPtr(packetUBXRXMPMPmessage->callbackData); // Call the callback
5606
5605
packetUBXRXMPMPmessage->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
5607
5606
}
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
5612
5611
{
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
+ {
5614
5614
if (packetUBXRXMQZSSL6message->automaticFlags.flags.bits.callbackCopyValid & (1 << ch)) // If the copy of the data is valid
5615
5615
{
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
5618
5618
}
5619
5619
}
5620
5620
}
@@ -13130,7 +13130,6 @@ bool SFE_UBLOX_GNSS::initPacketUBXRXMQZSSL6message()
13130
13130
return (true);
13131
13131
}
13132
13132
13133
-
13134
13133
bool SFE_UBLOX_GNSS::setRXMCORcallbackPtr(void (*callbackPointer)(UBX_RXM_COR_data_t *))
13135
13134
{
13136
13135
if (packetUBXRXMCOR == NULL)
@@ -17498,8 +17497,7 @@ uint16_t SFE_UBLOX_GNSS::getMagAcc(uint16_t maxWait)
17498
17497
// getGeoidSeparation is currently redundant. The geoid separation seems to only be provided in NMEA GGA and GNS messages.
17499
17498
int32_t SFE_UBLOX_GNSS::getGeoidSeparation(uint16_t maxWait)
17500
17499
{
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
17503
17501
17504
17502
return (0);
17505
17503
}
0 commit comments