Skip to content

Commit 9b6369e

Browse files
committed
Disable auto-NMEA support on the Uno - to avoid exceeding the program memory
1 parent d99d864 commit 9b6369e

File tree

2 files changed

+23
-9
lines changed

2 files changed

+23
-9
lines changed

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+15-7
Original file line numberDiff line numberDiff line change
@@ -422,6 +422,7 @@ void SFE_UBLOX_GNSS::end(void)
422422
packetUBXHNRPVT = NULL; // Redundant?
423423
}
424424

425+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
425426
if (storageNMEAGPGGA != NULL)
426427
{
427428
if (storageNMEAGPGGA->callbackCopy != NULL)
@@ -501,6 +502,7 @@ void SFE_UBLOX_GNSS::end(void)
501502
delete storageNMEAGNZDA;
502503
storageNMEAGNZDA = NULL; // Redundant?
503504
}
505+
#endif
504506
}
505507

506508
// Allow the user to change packetCfgPayloadSize. Handy if you want to process big messages like RAWX
@@ -1861,6 +1863,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
18611863
_signsOfLife = isNMEAHeaderValid();
18621864
}
18631865

1866+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
18641867
// Check if we have automatic storage for this message
18651868
if (isThisNMEAauto())
18661869
{
@@ -1872,6 +1875,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
18721875
memcpy(nmeaPtr, &nmeaAddressField[0], 6); // Copy the start character and address field into the working copy
18731876
}
18741877
else
1878+
#endif
18751879
{
18761880
// if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
18771881
// {
@@ -1898,6 +1902,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
18981902

18991903
if ((nmeaByteCounter > 5) || (nmeaByteCounter < 0)) // Should we add incoming to the file buffer and/or pass it to processNMEA?
19001904
{
1905+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
19011906
if (isThisNMEAauto())
19021907
{
19031908
uint8_t *lengthPtr = getNMEAWorkingLengthPtr(); // Get a pointer to the working copy length
@@ -1909,15 +1914,14 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
19091914
*lengthPtr = *lengthPtr + 1; // Increment the length
19101915
if (*lengthPtr == nmeaMaxLength)
19111916
{
1912-
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
19131917
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
19141918
{
19151919
_debugSerial->println(F("process: NMEA buffer is full!"));
19161920
}
1917-
#endif
19181921
}
19191922
}
19201923
}
1924+
#endif
19211925
if (logThisNMEA())
19221926
storeFileBytes(&incoming, 1); // Add incoming to the file buffer
19231927
if (processThisNMEA())
@@ -1934,6 +1938,7 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
19341938

19351939
if (nmeaByteCounter == 0) // Check if we are done
19361940
{
1941+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
19371942
if (isThisNMEAauto())
19381943
{
19391944
uint8_t *workingLengthPtr = getNMEAWorkingLengthPtr(); // Get a pointer to the working copy length
@@ -1988,7 +1993,6 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
19881993
}
19891994
else
19901995
{
1991-
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
19921996
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
19931997
{
19941998
_debugSerial->print(F("process: NMEA checksum fail (2)! Expected "));
@@ -1999,19 +2003,17 @@ void SFE_UBLOX_GNSS::process(uint8_t incoming, ubxPacket *incomingUBX, uint8_t r
19992003
_debugSerial->write(*(workingNMEAPtr + charsChecked + 1));
20002004
_debugSerial->println();
20012005
}
2002-
#endif
20032006
}
20042007
}
20052008
else
20062009
{
2007-
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
20082010
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
20092011
{
20102012
_debugSerial->println(F("process: NMEA checksum fail (1)!"));
20112013
}
2012-
#endif
20132014
}
20142015
}
2016+
#endif
20152017
currentSentence = NONE; // All done!
20162018
}
20172019
}
@@ -2192,6 +2194,7 @@ void SFE_UBLOX_GNSS::processNMEA(char incoming)
21922194
_nmeaOutputPort->write(incoming); // Echo this byte to the serial port
21932195
}
21942196

2197+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
21952198
// Check if the NMEA message (in nmeaAddressField) is "auto" (i.e. has RAM allocated for it)
21962199
bool SFE_UBLOX_GNSS::isThisNMEAauto()
21972200
{
@@ -2763,6 +2766,7 @@ nmeaAutomaticFlags *SFE_UBLOX_GNSS::getNMEAFlagsPtr()
27632766

27642767
return NULL;
27652768
}
2769+
#endif
27662770

27672771
// We need to be able to identify an RTCM packet and then the length
27682772
// so that we know when the RTCM message is completely received and we then start
@@ -5564,6 +5568,7 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
55645568
packetUBXHNRPVT->automaticFlags.flags.bits.callbackCopyValid = false; // Mark the data as stale
55655569
}
55665570

5571+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
55675572
if ((storageNMEAGPGGA != NULL) // If RAM has been allocated for message storage
55685573
&& (storageNMEAGPGGA->callbackCopy != NULL) // If RAM has been allocated for the copy of the data
55695574
&& (storageNMEAGPGGA->automaticFlags.flags.bits.callbackCopyValid == 1)) // If the copy of the data is valid
@@ -5715,6 +5720,7 @@ void SFE_UBLOX_GNSS::checkCallbacks(void)
57155720
}
57165721
storageNMEAGNZDA->automaticFlags.flags.bits.callbackCopyValid = 0; // Mark the data as stale
57175722
}
5723+
#endif
57185724

57195725
checkCallbacksReentrant = false;
57205726
}
@@ -14812,6 +14818,7 @@ uint32_t SFE_UBLOX_GNSS::getProcessNMEAMask()
1481214818
return (_processNMEA.all);
1481314819
}
1481414820

14821+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
1481514822
// Initiate automatic storage of NMEA GPGGA messages
1481614823

1481714824
// Get the most recent GPGGA message
@@ -15234,7 +15241,7 @@ bool SFE_UBLOX_GNSS::initStorageNMEAGNVTG()
1523415241
return (true);
1523515242
}
1523615243

15237-
// Initiate automatic storage of NMEA GPVTG messages
15244+
// Initiate automatic storage of NMEA GPRMC messages
1523815245

1523915246
// Get the most recent GPRMC message
1524015247
// Return 0 if the message has not been received from the module
@@ -15655,6 +15662,7 @@ bool SFE_UBLOX_GNSS::initStorageNMEAGNZDA()
1565515662

1565615663
return (true);
1565715664
}
15665+
#endif
1565815666

1565915667
// ***** CFG RATE Helper Functions
1566015668

src/SparkFun_u-blox_GNSS_Arduino_Library.h

+8-2
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,9 @@
5757
#include "u-blox_structs.h"
5858

5959
// Uncomment the next line (or add SFE_UBLOX_REDUCED_PROG_MEM as a compiler directive) to reduce the amount of program memory used by the library
60-
//#define SFE_UBLOX_REDUCED_PROG_MEM // Uncommenting this line will delete the minor debug messages to save memory
60+
//#define SFE_UBLOX_REDUCED_PROG_MEM // Uncommenting this line will delete the minor debug messages and disable auto-NMEA support to save memory
6161

62-
// The code just about fills the program memory on the ATmega328P (Arduino Uno), so let's delete the minor debug messages anyway
62+
// The code just about fills the program memory on the ATmega328P (Arduino Uno), so let's delete the minor debug messages and disable auto-NMEA support anyway
6363
#if !defined(SFE_UBLOX_REDUCED_PROG_MEM) && defined(ARDUINO_ARCH_AVR)
6464
#define SFE_UBLOX_REDUCED_PROG_MEM
6565
#endif
@@ -1431,6 +1431,7 @@ class SFE_UBLOX_GNSS
14311431
void setProcessNMEAMask(uint32_t messages = SFE_UBLOX_FILTER_NMEA_ALL); // Control which NMEA messages are passed to processNMEA. Default to passing ALL messages
14321432
uint32_t getProcessNMEAMask(); // Return which NMEA messages are passed to processNMEA
14331433

1434+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
14341435
// Support for "auto" storage of NMEA messages
14351436
uint8_t getLatestNMEAGPGGA(NMEA_GGA_data_t *data); // Return the most recent GPGGA: 0 = no data, 1 = stale data, 2 = fresh data
14361437
bool setNMEAGPGGAcallback(void (*callbackPointer)(NMEA_GGA_data_t)); // Enable a callback on the arrival of a GPGGA message
@@ -1456,6 +1457,7 @@ class SFE_UBLOX_GNSS
14561457
uint8_t getLatestNMEAGNZDA(NMEA_ZDA_data_t *data); // Return the most recent GNZDA: 0 = no data, 1 = stale data, 2 = fresh data
14571458
bool setNMEAGNZDAcallback(void (*callbackPointer)(NMEA_ZDA_data_t)); // Enable a callback on the arrival of a GNZDA message
14581459
bool setNMEAGNZDAcallbackPtr(void (*callbackPointerPtr)(NMEA_ZDA_data_t *)); // Enable a callback on the arrival of a GNZDA message
1460+
#endif
14591461

14601462
// Functions to extract signed and unsigned 8/16/32-bit data from a ubxPacket
14611463
// From v2.0: These are public. The user can call these to extract data from custom packets
@@ -1511,6 +1513,7 @@ class SFE_UBLOX_GNSS
15111513
UBX_MGA_ACK_DATA0_t *packetUBXMGAACK = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15121514
UBX_MGA_DBD_t *packetUBXMGADBD = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15131515

1516+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
15141517
NMEA_GPGGA_t *storageNMEAGPGGA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15151518
NMEA_GNGGA_t *storageNMEAGNGGA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15161519
NMEA_GPVTG_t *storageNMEAGPVTG = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
@@ -1519,6 +1522,7 @@ class SFE_UBLOX_GNSS
15191522
NMEA_GNRMC_t *storageNMEAGNRMC = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15201523
NMEA_GPZDA_t *storageNMEAGPZDA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
15211524
NMEA_GNZDA_t *storageNMEAGNZDA = NULL; // Pointer to struct. RAM will be allocated for this if/when necessary
1525+
#endif
15221526

15231527
uint16_t rtcmFrameCounter = 0; // Tracks the type of incoming byte inside RTCM frame
15241528

@@ -1602,6 +1606,7 @@ class SFE_UBLOX_GNSS
16021606
bool initPacketUBXMGAACK(); // Allocate RAM for packetUBXMGAACK and initialize it
16031607
bool initPacketUBXMGADBD(); // Allocate RAM for packetUBXMGADBD and initialize it
16041608

1609+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
16051610
bool initStorageNMEAGPGGA(); // Allocate RAM for incoming NMEA GPGGA messages and initialize it
16061611
bool initStorageNMEAGNGGA(); // Allocate RAM for incoming NMEA GNGGA messages and initialize it
16071612
bool initStorageNMEAGPVTG(); // Allocate RAM for incoming NMEA GPVTG messages and initialize it
@@ -1610,6 +1615,7 @@ class SFE_UBLOX_GNSS
16101615
bool initStorageNMEAGNRMC(); // Allocate RAM for incoming NMEA GNRMC messages and initialize it
16111616
bool initStorageNMEAGPZDA(); // Allocate RAM for incoming NMEA GPZDA messages and initialize it
16121617
bool initStorageNMEAGNZDA(); // Allocate RAM for incoming NMEA GNZDA messages and initialize it
1618+
#endif
16131619

16141620
// Variables
16151621
TwoWire *_i2cPort; // The generic connection to user's chosen I2C hardware

0 commit comments

Comments
 (0)