Skip to content

Commit 89ecefc

Browse files
authored
Merge pull request #165 from sparkfun/release_candidate
Add autoSendCfgValsetAtSpaceRemaining. Update Example9
2 parents da3d3f1 + 5ef966c commit 89ecefc

5 files changed

+125
-3
lines changed

examples/ZED-F9P/Example9_multiSetVal/Example9_multiSetVal.ino

+7
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,13 @@ void setup()
6666
//but with multiple messages all in one go using newCfgValset, addCfgValset and sendCfgValset.
6767
//Original: myGNSS.enableRTCMmessage(UBX_RTCM_1005, COM_PORT_I2C, 1); //Enable message 1005 to output through I2C port, message every second
6868

69+
//If we will be sending a large number of key IDs and values, packetCfg could fill up before the CFG_VALSET is sent...
70+
//There are three possible solutions:
71+
// Increase the space available by calling myGNSS.setPacketCfgPayloadSize
72+
// Monitor how much space is remaining by calling myGNSS.getCfgValsetSpaceRemaining. Call myGNSS.sendCfgValset(); before packetCfg becomes full.
73+
// Call myGNSS.autoSendCfgValsetAtSpaceRemaining(16); . This will cause the existing CFG_VALSET to be send automatically and a new one created when packetCfg has less than 16 bytes remaining.
74+
myGNSS.autoSendCfgValsetAtSpaceRemaining(16); // Trigger an auto-send when packetCfg has less than 16 bytes are remaining
75+
6976
//Begin with newCfgValset
7077
setValueSuccess &= myGNSS.newCfgValset(); // Defaults to configuring the setting in Flash, RAM and BBR
7178
//setValueSuccess &= myGNSS.newCfgValset(VAL_LAYER_RAM); //Set this and the following settings in RAM only instead of Flash/RAM/BBR

keywords.txt

+1
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,7 @@ sendCfgValset64 KEYWORD2
249249
sendCfgValset KEYWORD2
250250
getCfgValsetLen KEYWORD2
251251
getCfgValsetSpaceRemaining KEYWORD2
252+
autoSendCfgValsetAtSpaceRemaining KEYWORD2
252253

253254
getNAVPOSECEF KEYWORD2
254255
setAutoNAVPOSECEF KEYWORD2

library.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=SparkFun u-blox GNSS Arduino Library
2-
version=2.2.18
2+
version=2.2.19
33
author=SparkFun Electronics <[email protected]>
44
maintainer=SparkFun Electronics <sparkfun.com>
55
sentence=Library for I2C, Serial and SPI Communication with u-blox GNSS modules<br/><br/>

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

+112-2
Original file line numberDiff line numberDiff line change
@@ -9337,6 +9337,19 @@ uint8_t SFE_UBLOX_GNSS::newCfgValset(uint8_t layer)
93379337
// This function takes a full 32-bit key and 64-bit value
93389338
uint8_t SFE_UBLOX_GNSS::addCfgValset64(uint32_t key, uint64_t value)
93399339
{
9340+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9341+
{
9342+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9343+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9344+
_debugSerial->println(F("addCfgValset64: autosend"));
9345+
#endif
9346+
sendCommand(&packetCfg);
9347+
packetCfg.len = 4; // 4 byte header
9348+
packetCfg.startingSpot = 0;
9349+
_numCfgKeyIDs = 0;
9350+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9351+
}
9352+
93409353
if (packetCfg.len >= (packetCfgPayloadSize - 12))
93419354
{
93429355
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9384,6 +9397,19 @@ uint8_t SFE_UBLOX_GNSS::addCfgValset64(uint32_t key, uint64_t value)
93849397
// This function takes a full 32-bit key and 32-bit value
93859398
uint8_t SFE_UBLOX_GNSS::addCfgValset32(uint32_t key, uint32_t value)
93869399
{
9400+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9401+
{
9402+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9403+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9404+
_debugSerial->println(F("addCfgValset32: autosend"));
9405+
#endif
9406+
sendCommand(&packetCfg);
9407+
packetCfg.len = 4; // 4 byte header
9408+
packetCfg.startingSpot = 0;
9409+
_numCfgKeyIDs = 0;
9410+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9411+
}
9412+
93879413
if (packetCfg.len >= (packetCfgPayloadSize - 8))
93889414
{
93899415
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9427,6 +9453,19 @@ uint8_t SFE_UBLOX_GNSS::addCfgValset32(uint32_t key, uint32_t value)
94279453
// This function takes a full 32-bit key and 16-bit value
94289454
uint8_t SFE_UBLOX_GNSS::addCfgValset16(uint32_t key, uint16_t value)
94299455
{
9456+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9457+
{
9458+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9459+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9460+
_debugSerial->println(F("addCfgValset16: autosend"));
9461+
#endif
9462+
sendCommand(&packetCfg);
9463+
packetCfg.len = 4; // 4 byte header
9464+
packetCfg.startingSpot = 0;
9465+
_numCfgKeyIDs = 0;
9466+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9467+
}
9468+
94309469
if (packetCfg.len >= (packetCfgPayloadSize - 6))
94319470
{
94329471
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9468,6 +9507,19 @@ uint8_t SFE_UBLOX_GNSS::addCfgValset16(uint32_t key, uint16_t value)
94689507
// This function takes a full 32-bit key and 8-bit value
94699508
uint8_t SFE_UBLOX_GNSS::addCfgValset8(uint32_t key, uint8_t value)
94709509
{
9510+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9511+
{
9512+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9513+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9514+
_debugSerial->println(F("addCfgValset8: autosend"));
9515+
#endif
9516+
sendCommand(&packetCfg);
9517+
packetCfg.len = 4; // 4 byte header
9518+
packetCfg.startingSpot = 0;
9519+
_numCfgKeyIDs = 0;
9520+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9521+
}
9522+
94719523
if (packetCfg.len >= (packetCfgPayloadSize - 5))
94729524
{
94739525
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9508,6 +9560,19 @@ uint8_t SFE_UBLOX_GNSS::addCfgValset8(uint32_t key, uint8_t value)
95089560
// This function takes a full 32-bit key and 64-bit value
95099561
uint8_t SFE_UBLOX_GNSS::sendCfgValset64(uint32_t key, uint64_t value, uint16_t maxWait)
95109562
{
9563+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9564+
{
9565+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9566+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9567+
_debugSerial->println(F("sendCfgValset64: autosend"));
9568+
#endif
9569+
sendCommand(&packetCfg);
9570+
packetCfg.len = 4; // 4 byte header
9571+
packetCfg.startingSpot = 0;
9572+
_numCfgKeyIDs = 0;
9573+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9574+
}
9575+
95119576
if (packetCfg.len >= (packetCfgPayloadSize - 12))
95129577
{
95139578
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9536,6 +9601,19 @@ uint8_t SFE_UBLOX_GNSS::sendCfgValset64(uint32_t key, uint64_t value, uint16_t m
95369601
// This function takes a full 32-bit key and 32-bit value
95379602
uint8_t SFE_UBLOX_GNSS::sendCfgValset32(uint32_t key, uint32_t value, uint16_t maxWait)
95389603
{
9604+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9605+
{
9606+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9607+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9608+
_debugSerial->println(F("sendCfgValset32: autosend"));
9609+
#endif
9610+
sendCommand(&packetCfg);
9611+
packetCfg.len = 4; // 4 byte header
9612+
packetCfg.startingSpot = 0;
9613+
_numCfgKeyIDs = 0;
9614+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9615+
}
9616+
95399617
if (packetCfg.len >= (packetCfgPayloadSize - 8))
95409618
{
95419619
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9564,6 +9642,19 @@ uint8_t SFE_UBLOX_GNSS::sendCfgValset32(uint32_t key, uint32_t value, uint16_t m
95649642
// This function takes a full 32-bit key and 16-bit value
95659643
uint8_t SFE_UBLOX_GNSS::sendCfgValset16(uint32_t key, uint16_t value, uint16_t maxWait)
95669644
{
9645+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9646+
{
9647+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9648+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9649+
_debugSerial->println(F("sendCfgValset16: autosend"));
9650+
#endif
9651+
sendCommand(&packetCfg);
9652+
packetCfg.len = 4; // 4 byte header
9653+
packetCfg.startingSpot = 0;
9654+
_numCfgKeyIDs = 0;
9655+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9656+
}
9657+
95679658
if (packetCfg.len >= (packetCfgPayloadSize - 6))
95689659
{
95699660
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9592,6 +9683,19 @@ uint8_t SFE_UBLOX_GNSS::sendCfgValset16(uint32_t key, uint16_t value, uint16_t m
95929683
// This function takes a full 32-bit key and 8-bit value
95939684
uint8_t SFE_UBLOX_GNSS::sendCfgValset8(uint32_t key, uint8_t value, uint16_t maxWait)
95949685
{
9686+
if ((_autoSendAtSpaceRemaining > 0) && (packetCfg.len >= (packetCfgPayloadSize - _autoSendAtSpaceRemaining)))
9687+
{
9688+
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
9689+
if ((_printDebug == true) || (_printLimitedDebug == true)) // This is important. Print this if doing limited debugging
9690+
_debugSerial->println(F("sendCfgValset8: autosend"));
9691+
#endif
9692+
sendCommand(&packetCfg);
9693+
packetCfg.len = 4; // 4 byte header
9694+
packetCfg.startingSpot = 0;
9695+
_numCfgKeyIDs = 0;
9696+
memset(&payloadCfg[4], 0, packetCfgPayloadSize - 4);
9697+
}
9698+
95959699
if (packetCfg.len >= (packetCfgPayloadSize - 5))
95969700
{
95979701
#ifndef SFE_UBLOX_REDUCED_PROG_MEM
@@ -9619,10 +9723,16 @@ uint8_t SFE_UBLOX_GNSS::sendCfgValset8(uint32_t key, uint8_t value, uint16_t max
96199723
// Send the UBX-CFG-VALSET ubxPacket
96209724
uint8_t SFE_UBLOX_GNSS::sendCfgValset(uint16_t maxWait)
96219725
{
9622-
_numCfgKeyIDs = 0;
9726+
if (_numCfgKeyIDs == 0)
9727+
return true; // Nothing to send...
96239728

96249729
// Send VALSET command with this key and value
9625-
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
9730+
bool success = sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT; // We are only expecting an ACK
9731+
9732+
if (success)
9733+
_numCfgKeyIDs = 0;
9734+
9735+
return success;
96269736
}
96279737

96289738
// Return the number of keys in the CfgValset

src/SparkFun_u-blox_GNSS_Arduino_Library.h

+4
Original file line numberDiff line numberDiff line change
@@ -996,6 +996,7 @@ class SFE_UBLOX_GNSS
996996
uint8_t sendCfgValset(uint16_t maxWait = defaultMaxWait); // Send the CfgValset (UBX-CFG-VALSET) construct
997997
uint8_t getCfgValsetLen(); // Returns the length of the current CfgValset construct as number-of-keyIDs
998998
size_t getCfgValsetSpaceRemaining(); // Returns the number of free bytes remaining in packetCfg
999+
void autoSendCfgValsetAtSpaceRemaining(size_t spaceRemaining) { _autoSendAtSpaceRemaining = spaceRemaining; } // Cause CFG_VALSET packets to be sent automatically when packetCfg has less than this many bytes available
9991000

10001001
// get and set functions for all of the "automatic" message processing
10011002

@@ -1796,6 +1797,9 @@ class SFE_UBLOX_GNSS
17961797

17971798
// Keep track of how many keys have been added to CfgValset
17981799
uint8_t _numCfgKeyIDs = 0;
1800+
1801+
// Send the current CFG_VALSET message when packetCfg has less than this many bytes available
1802+
size_t _autoSendAtSpaceRemaining = 0;
17991803
};
18001804

18011805
#endif

0 commit comments

Comments
 (0)