Merge pull request #147 from LeeLeahy2/process-rtcm

Make processRTCMframe weak
This commit is contained in:
Paul
2022-08-01 11:24:28 +01:00
committed by GitHub
2 changed files with 26 additions and 29 deletions
+9 -10
View File
@@ -2114,7 +2114,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
} }
else if (currentSentence == RTCM) 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 2: 10-bits of length of this packet including the first two-ish header bytes, + 6.
// byte 3 + 4 bits: Msg type 12 bits // 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 // 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 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 |= incoming; // Bits 0-7 of packet length
rtcmLen += 6; // There are 6 additional bytes of what we presume is header, msgType, CRC, and stuff 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 rtcmMsgType |= (incoming >> 4); //Message Type, bits 0-7
}*/ }*/
rtcmFrameCounter++; *rtcmFrameCounter++;
processRTCM(incoming); // Here is where we expose this byte to the user processRTCM(incoming); // Here is where we expose this byte to the user
if (rtcmFrameCounter == rtcmLen) // Reset and start looking for next sentence type when done
{ return (*rtcmFrameCounter == rtcmLen) ? NONE : RTCM;
// We're done!
currentSentence = NONE; // Reset and start looking for next sentence type
}
} }
// This function is called for each byte of an RTCM frame // This function is called for each byte of an RTCM frame
+10 -12
View File
@@ -646,6 +646,15 @@ public:
SFE_UBLOX_GNSS(void); SFE_UBLOX_GNSS(void);
~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. // 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 // If you know you are only going to be using I2C / Qwiic communication, you can
// safely reduce defaultMaxWait to 250. // 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 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 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 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 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 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 uint16_t rtcmFrameCounter = 0; // Tracks the type of incoming byte inside RTCM frame
private: 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 // Depending on the ubx binary response class, store binary responses into different places
enum classTypes enum classTypes
{ {
@@ -1761,8 +1761,6 @@ private:
uint8_t getNMEAMaxLength(); // Get the maximum length of this NMEA message uint8_t getNMEAMaxLength(); // Get the maximum length of this NMEA message
nmeaAutomaticFlags *getNMEAFlagsPtr(); // Get a pointer to the flags nmeaAutomaticFlags *getNMEAFlagsPtr(); // Get a pointer to the flags
uint16_t rtcmLen = 0;
// Flag to prevent reentry into checkCallbacks // Flag to prevent reentry into checkCallbacks
// Prevent badness if the user accidentally calls checkCallbacks from inside a callback // Prevent badness if the user accidentally calls checkCallbacks from inside a callback
volatile bool checkCallbacksReentrant = false; volatile bool checkCallbacksReentrant = false;