Skip to content

Commit ac07f9e

Browse files
committed
Changes to allow custom commands to run correctly
1 parent 0b04481 commit ac07f9e

File tree

2 files changed

+15
-13
lines changed

2 files changed

+15
-13
lines changed

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,6 +1154,8 @@ uint16_t SFE_UBLOX_GNSS::getMaxPayloadSize(uint8_t Class, uint8_t ID)
11541154
//Take a given byte and file it into the proper array
11551155
// Note - AJB - we will ALWAYS use packetBuf to receive incoming, and then process them into the
11561156
// appropriate packet structures
1157+
// Note - PC - we need to make sure that users can still use custom packets (passed via incomingUBX).
1158+
// We can't hardwire this code to packetCfg...
11571159
void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t requestedClass, uint8_t requestedID)
11581160
{
11591161
if ((currentSentence == NONE) || (currentSentence == NMEA))
@@ -1227,9 +1229,9 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
12271229
{
12281230
if (_printDebug) _debugSerial->println("process: activeBuffer PACKETCFG");
12291231
activePacketBuffer = SFE_UBLOX_PACKET_PACKETCFG;
1230-
packetCfg.cls = packetBuf.cls;
1231-
packetCfg.id = packetBuf.id;
1232-
packetCfg.counter = packetBuf.counter;
1232+
incomingUBX->cls = packetBuf.cls;
1233+
incomingUBX->id = packetBuf.id;
1234+
incomingUBX->counter = packetBuf.counter;
12331235
}
12341236
else
12351237
{
@@ -1376,7 +1378,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
13761378
if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETACK)
13771379
processUBX(incoming, &packetAck);
13781380
else if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETCFG)
1379-
processUBX(incoming, &packetCfg);
1381+
processUBX(incoming, incomingUBX);
13801382
else if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETBUF)
13811383
processUBX(incoming, &packetBuf);
13821384
else // if (activePacketBuffer == SFE_UBLOX_PACKET_PACKETAUTO)
@@ -3059,7 +3061,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
30593061

30603062
// If both the packetCfg->isClassAndIdMatch and packetAck.isClassAndIdMatch
30613063
// then we can be confident that the data in packetCfg is valid
3062-
if (packetAck.isAckForClassAndId(requestedClass, requestedID) && packetCfg.valid == SFE_UBLOX_PACKET_VALIDITY_VALID && packetAck.valid == SFE_UBLOX_PACKET_VALIDITY_VALID && packetCfg.isClassAndIdMatch(requestedClass, requestedID))
3064+
if (packetAck.isAckForClassAndId(requestedClass, requestedID) && outgoingUBX->valid == SFE_UBLOX_PACKET_VALIDITY_VALID && packetAck.valid == SFE_UBLOX_PACKET_VALIDITY_VALID && outgoingUBX->isClassAndIdMatch(requestedClass, requestedID))
30633065
{
30643066
if (_printDebug == true)
30653067
{
@@ -3069,7 +3071,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
30693071
}
30703072
return (SFE_UBLOX_STATUS_DATA_RECEIVED); //We received valid data and a correct ACK!
30713073
}
3072-
else if (!packetCfg.isClassAndIdMatch(requestedClass, requestedID) && packetAck.isClassAndIdMatch(requestedClass, requestedID))
3074+
else if (!outgoingUBX->isClassAndIdMatch(requestedClass, requestedID) && packetAck.isClassAndIdMatch(requestedClass, requestedID))
30733075
{
30743076
if (_printDebug == true)
30753077
{
@@ -3082,7 +3084,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
30823084

30833085
// If packetAck is for requested class/ID but both outgoingUBX->valid and packetCfg isClassAndIDmatch
30843086
// are NOT_VALID then we can be confident we have had a checksum failure on the data packet
3085-
else if ((packetAck.isAckForClassAndId(requestedClass, requestedID) && (packetCfg.valid == SFE_UBLOX_PACKET_VALIDITY_NOT_VALID)))
3087+
else if ((packetAck.isAckForClassAndId(requestedClass, requestedID) && (outgoingUBX->valid == SFE_UBLOX_PACKET_VALIDITY_NOT_VALID)))
30863088
{
30873089
if (_printDebug == true)
30883090
{
@@ -3106,7 +3108,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
31063108
// If the packetCfg.isClassAndIdMatch but the packetAck is not for this class/ID
31073109
// then the ack probably had a checksum error. We will take a gamble and return DATA_RECEIVED.
31083110
// If we were playing safe, we should return FAIL instead
3109-
else if ((packetCfg.isClassAndIdMatch(requestedClass, requestedID) && (packetAck.isClassAndIdMatch(requestedClass, requestedID) == false) && (packetCfg.valid == SFE_UBLOX_PACKET_VALIDITY_VALID)))
3111+
else if ((outgoingUBX->isClassAndIdMatch(requestedClass, requestedID) && (packetAck.isClassAndIdMatch(requestedClass, requestedID) == false) && (outgoingUBX->valid == SFE_UBLOX_PACKET_VALIDITY_VALID)))
31103112
{
31113113
if (_printDebug == true)
31123114
{
@@ -3119,7 +3121,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
31193121

31203122
// If classes of ack and data do not match
31213123
// then we return a FAIL. This must be a double checksum failure?
3122-
else if ((packetCfg.isClassAndIdMatch(requestedClass, requestedID) == false) && (packetAck.isClassAndIdMatch(requestedClass, requestedID) == false))
3124+
else if ((outgoingUBX->isClassAndIdMatch(requestedClass, requestedID) == false) && (packetAck.isClassAndIdMatch(requestedClass, requestedID) == false))
31233125
{
31243126
if (_printDebug == true)
31253127
{
@@ -3137,7 +3139,7 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForACKResponse(ubxPacket *outgoingUBX, ui
31373139
// We have timed out...
31383140
// If the packetCfg matches the requested class/ID then we can take a gamble and return DATA_RECEIVED
31393141
// even though we did not get an ACK
3140-
if ((packetCfg.isClassAndIdMatch(requestedClass, requestedID) && !packetAck.isClassAndIdMatch(requestedClass, requestedID)) && (packetCfg.valid == SFE_UBLOX_PACKET_VALIDITY_VALID))
3142+
if ((outgoingUBX->isClassAndIdMatch(requestedClass, requestedID) && !packetAck.isClassAndIdMatch(requestedClass, requestedID)) && (outgoingUBX->valid == SFE_UBLOX_PACKET_VALIDITY_VALID))
31413143
{
31423144
if (_printDebug == true)
31433145
{
@@ -3174,13 +3176,13 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::waitForNoACKResponse(ubxPacket *outgoingUBX,
31743176
unsigned long startTime = millis();
31753177
while (millis() - startTime < maxTime)
31763178
{
3177-
if (checkUbloxInternal(&packetBuf, requestedClass, requestedID) == true) //See if new data is available. Process bytes as they come in.
3179+
if (checkUbloxInternal(outgoingUBX, requestedClass, requestedID) == true) //See if new data is available. Process bytes as they come in.
31783180
{
31793181

31803182
// If packetBuf matches
31813183
// and outgoingUBX->valid is _still_ VALID and the class and ID _still_ match
31823184
// then we can be confident that the data in packetBuf is valid
3183-
if (packetBuf.isClassAndIdMatch(requestedClass, requestedID) && packetBuf.valid == SFE_UBLOX_PACKET_VALIDITY_VALID)
3185+
if (outgoingUBX->isClassAndIdMatch(requestedClass, requestedID) && packetBuf.valid == SFE_UBLOX_PACKET_VALIDITY_VALID)
31843186
{
31853187
if (_printDebug == true)
31863188
{

src/SparkFun_u-blox_GNSS_Arduino_Library.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,7 @@ class SFE_UBLOX_GNSS
13281328
//The packet buffers
13291329
//These are pointed at from within the ubxPacket
13301330
uint8_t payloadAck[2]; // Holds the requested ACK/NACK
1331-
uint8_t payloadBuf[MAX_PAYLOAD_SIZE]; // Temporary buffer used to screen incoming packets or dump unrequested packets aberridg TODO: figure out if we can reduce memory usage by not using the whole buffer - needs some clean-up
1331+
uint8_t payloadBuf[MAX_PAYLOAD_SIZE]; // Temporary buffer used to screen incoming packets or dump unrequested packets aberridg TODO: figure out if we can reduce memory usage by not using the whole buffer - needs some clean-up
13321332
size_t packetCfgPayloadSize = 0; // Size for the packetCfg payload. .begin will set this to MAX_PAYLOAD_SIZE if necessary. User can change with setPacketCfgPayloadSize
13331333
uint8_t *payloadCfg = NULL;
13341334
uint8_t *payloadAuto = NULL;

0 commit comments

Comments
 (0)