@@ -114,6 +114,15 @@ typedef enum
114
114
SFE_UBLOX_PACKET_NOTACKNOWLEDGED // This indicates that we received a NACK
115
115
} sfe_ublox_packet_validity_e;
116
116
117
+ // Identify which packet buffer is in use:
118
+ // packetCfg (or a custom packet), packetAck or packetBuf
119
+ typedef enum
120
+ {
121
+ SFE_UBLOX_PACKET_PACKETCFG,
122
+ SFE_UBLOX_PACKET_PACKETACK,
123
+ SFE_UBLOX_PACKET_PACKETBUF
124
+ } sfe_ublox_packet_buffer_e;
125
+
117
126
// Registers
118
127
const uint8_t UBX_SYNCH_1 = 0xB5 ;
119
128
const uint8_t UBX_SYNCH_2 = 0x62 ;
@@ -729,13 +738,21 @@ class SFE_UBLOX_GPS
729
738
730
739
boolean _printDebug = false ; // Flag to print the serial commands we are sending to the Serial port for debug
731
740
741
+ // The packet buffers
732
742
// These are pointed at from within the ubxPacket
733
- uint8_t payloadAck[2 ];
734
- uint8_t payloadCfg[MAX_PAYLOAD_SIZE];
743
+ uint8_t payloadAck[2 ]; // Holds the requested ACK/NACK
744
+ uint8_t payloadCfg[MAX_PAYLOAD_SIZE]; // Holds the requested data packet
745
+ uint8_t payloadBuf[2 ]; // Temporary buffer used to screen incoming packets (same size as Ack)
735
746
736
- // Init the packet structures and init them with pointers to the payloadAck and payloadCfg arrays
747
+ // Init the packet structures and init them with pointers to the payloadAck, payloadCfg and payloadBuf arrays
737
748
ubxPacket packetAck = {0 , 0 , 0 , 0 , 0 , payloadAck, 0 , 0 , SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
738
749
ubxPacket packetCfg = {0 , 0 , 0 , 0 , 0 , payloadCfg, 0 , 0 , SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
750
+ ubxPacket packetBuf = {0 , 0 , 0 , 0 , 0 , payloadBuf, 0 , 0 , SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED};
751
+
752
+ // Identify which buffer is in use
753
+ // Data is stored in packetBuf until the requested class and ID can be validated
754
+ // If a match is seen, data is diverted into packetAck or packetCfg
755
+ sfe_ublox_packet_buffer_e activePacketBuffer = SFE_UBLOX_PACKET_PACKETBUF;
739
756
740
757
// Limit checking of new data to every X ms
741
758
// If we are expecting an update every X Hz then we should check every half that amount of time
0 commit comments