@@ -761,6 +761,9 @@ void SFE_UBLOX_GPS::processRTCM(uint8_t incoming)
761
761
// a subset of bytes within a larger packet.
762
762
void SFE_UBLOX_GPS::processUBX (uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID)
763
763
{
764
+ size_t max_payload_size = (activePacketBuffer == SFE_UBLOX_PACKET_PACKETCFG) ? MAX_PAYLOAD_SIZE : 2 ;
765
+ bool overrun = false ;
766
+
764
767
// Add all incoming bytes to the rolling checksum
765
768
// Stop at len+4 as this is the checksum bytes to that should not be added to the rolling checksum
766
769
if (incomingUBX->counter < incomingUBX->len + 4 )
@@ -926,25 +929,29 @@ void SFE_UBLOX_GPS::processUBX(uint8_t incoming, ubxPacket *incomingUBX, uint8_t
926
929
uint16_t startingSpot = incomingUBX->startingSpot ;
927
930
if (incomingUBX->cls == UBX_CLASS_NAV && incomingUBX->id == UBX_NAV_PVT)
928
931
startingSpot = 0 ;
929
- // Begin recording if counter goes past startingSpot
930
- if ((incomingUBX-> counter - 4 ) >= startingSpot )
932
+ // Check if this is payload data which should be ignored
933
+ if (ignoreThisPayload == false )
931
934
{
932
- // Check to see if we have room for this byte
933
- if ((( incomingUBX->counter - 4 ) - startingSpot) < MAX_PAYLOAD_SIZE) // If counter = 208, starting spot = 200, we're good to record.
935
+ // Begin recording if counter goes past startingSpot
936
+ if ((incomingUBX->counter - 4 ) >= startingSpot)
934
937
{
935
- // Check if this is payload data which should be ignored
936
- if (ignoreThisPayload == false )
938
+ // Check to see if we have room for this byte
939
+ if (((incomingUBX-> counter - 4 ) - startingSpot) < max_payload_size) // If counter = 208, starting spot = 200, we're good to record.
937
940
{
938
941
incomingUBX->payload [incomingUBX->counter - 4 - startingSpot] = incoming; // Store this byte into payload array
939
942
}
943
+ else
944
+ {
945
+ overrun = true ;
946
+ }
940
947
}
941
948
}
942
949
}
943
950
944
951
// Increment the counter
945
952
incomingUBX->counter ++;
946
953
947
- if (incomingUBX->counter == MAX_PAYLOAD_SIZE)
954
+ if (overrun or incomingUBX->counter == MAX_PAYLOAD_SIZE)
948
955
{
949
956
// Something has gone very wrong
950
957
currentSentence = NONE; // Reset the sentence to being looking for a new start char
0 commit comments