diff --git a/examples/Example20_SendCustomCommand/Example20_SendCustomCommand.ino b/examples/Example20_SendCustomCommand/Example20_SendCustomCommand.ino index 45c259b..b468f93 100644 --- a/examples/Example20_SendCustomCommand/Example20_SendCustomCommand.ino +++ b/examples/Example20_SendCustomCommand/Example20_SendCustomCommand.ino @@ -62,7 +62,13 @@ void setup() // Let's configure the module's navigation rate as if we were using setNavigationFrequency // Let's create our custom packet - uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes + uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes. MAX_PAYLOAD_SIZE defaults to 256. The CFG_RATE payload is only 6 bytes! + + // setPacketCfgPayloadSize tells the library how many bytes our customPayload can hold. + // It is more memory-efficient to call setPacketCfgPayloadSize before .begin (to avoid creating a new buffer, copying across + // the contents of the old buffer and then deleting the old buffer). But let's call it here just to prove that we can. + myGNSS.setPacketCfgPayloadSize(MAX_PAYLOAD_SIZE); + // The next line creates and initialises the packet information which wraps around the payload ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED}; diff --git a/examples/Example21_ModuleInfo/Example21_ModuleInfo.ino b/examples/Example21_ModuleInfo/Example21_ModuleInfo.ino index 9349eca..2802c18 100644 --- a/examples/Example21_ModuleInfo/Example21_ModuleInfo.ino +++ b/examples/Example21_ModuleInfo/Example21_ModuleInfo.ino @@ -69,6 +69,13 @@ void setup() //myGNSS.enableDebugging(); // Uncomment this line to enable debug messages + // setPacketCfgPayloadSize tells the library how many bytes our customPayload can hold. + // If we call it after the .begin, the library will attempt to resize the existing 256 byte payload buffer + // by creating a new buffer, copying across the contents of the old buffer, and then delete the old buffer. + // This uses a lot of RAM and causes the code to fail on the ATmega328P. (We are also allocating another 341 bytes for minfo.) + // To keep the code ATmega328P compliant - don't call setPacketCfgPayloadSize after .begin. Call it here instead. + myGNSS.setPacketCfgPayloadSize(MAX_PAYLOAD_SIZE); + if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port { Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); @@ -119,6 +126,13 @@ boolean SFE_UBLOX_GPS_ADD::getModuleInfo(uint16_t maxWait) // Let's create our custom packet uint8_t customPayload[MAX_PAYLOAD_SIZE]; // This array holds the payload data bytes + // setPacketCfgPayloadSize tells the library how many bytes our customPayload can hold. + // If we call it here, after the .begin, the library will attempt to resize the existing 256 byte payload buffer + // by creating a new buffer, copying across the contents of the old buffer, and then delete the old buffer. + // This uses a lot of RAM and causes the code to fail on the ATmega328P. (We are also allocating another 341 bytes for minfo.) + // To keep the code ATmega328P compliant - don't call setPacketCfgPayloadSize here. Call it before .begin instead. + //myGNSS.setPacketCfgPayloadSize(MAX_PAYLOAD_SIZE); + // The next line creates and initialises the packet information which wraps around the payload ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED}; diff --git a/examples/Example3_GetPosition/Example3_GetPosition.ino b/examples/Example3_GetPosition/Example3_GetPosition.ino index be605f3..489cc2c 100644 --- a/examples/Example3_GetPosition/Example3_GetPosition.ino +++ b/examples/Example3_GetPosition/Example3_GetPosition.ino @@ -43,6 +43,8 @@ void setup() Wire.begin(); + //myGNSS.enableDebugging(); // Uncomment this line to enable helpful debug messages on Serial + if (myGNSS.begin() == false) //Connect to the u-blox module using Wire port { Serial.println(F("u-blox GNSS not detected at default I2C address. Please check wiring. Freezing.")); diff --git a/library.properties b/library.properties index 5634f67..6380a28 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=SparkFun u-blox GNSS Arduino Library -version=2.0.9 +version=2.0.10 author=SparkFun Electronics maintainer=SparkFun Electronics sentence=Library for I2C and Serial Communication with u-blox GNSS modules