Skip to content

Commit 058f904

Browse files
committed
Add downloadDeviceConfig
Helper function to pipe u-center friendly formatted file for entire device config.
1 parent 46340ea commit 058f904

File tree

2 files changed

+41
-5
lines changed

2 files changed

+41
-5
lines changed

src/SparkFun_u-blox_GNSS_Arduino_Library.cpp

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4818,7 +4818,7 @@ uint32_t SFE_UBLOX_GNSS::createKey(uint16_t group, uint16_t id, uint8_t size)
48184818
//This function takes a full 32-bit key
48194819
//Default layer is RAM
48204820
//Configuration of modern u-blox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
4821-
sfe_ublox_status_e SFE_UBLOX_GNSS::getVal(uint32_t key, uint8_t layer, uint16_t maxWait)
4821+
sfe_ublox_status_e SFE_UBLOX_GNSS::getVal(uint32_t key, uint8_t layer, uint16_t skipAmt, uint16_t maxWait)
48224822
{
48234823
packetCfg.cls = UBX_CLASS_CFG;
48244824
packetCfg.id = UBX_CFG_VALGET;
@@ -4842,6 +4842,9 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::getVal(uint32_t key, uint8_t layer, uint16_t
48424842
payloadCfg[0] = 0; //Message Version - set to 0
48434843
payloadCfg[1] = getLayer; //Layer
48444844

4845+
payloadCfg[2] = skipAmt >> 8 * 0; //Position - skip this many key values
4846+
payloadCfg[3] = skipAmt >> 8 * 1;
4847+
48454848
//Load key into outgoing payload
48464849
payloadCfg[4] = key >> 8 * 0; //Key LSB
48474850
payloadCfg[5] = key >> 8 * 1;
@@ -4878,21 +4881,21 @@ sfe_ublox_status_e SFE_UBLOX_GNSS::getVal(uint32_t key, uint8_t layer, uint16_t
48784881
//Configuration of modern u-blox modules is now done via getVal/setVal/delVal, ie protocol v27 and above found on ZED-F9P
48794882
uint8_t SFE_UBLOX_GNSS::getVal8(uint32_t key, uint8_t layer, uint16_t maxWait)
48804883
{
4881-
if (getVal(key, layer, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
4884+
if (getVal(key, layer, 0, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
48824885
return (0);
48834886

48844887
return (extractByte(&packetCfg, 8));
48854888
}
48864889
uint16_t SFE_UBLOX_GNSS::getVal16(uint32_t key, uint8_t layer, uint16_t maxWait)
48874890
{
4888-
if (getVal(key, layer, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
4891+
if (getVal(key, layer, 0, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
48894892
return (0);
48904893

48914894
return (extractInt(&packetCfg, 8));
48924895
}
48934896
uint32_t SFE_UBLOX_GNSS::getVal32(uint32_t key, uint8_t layer, uint16_t maxWait)
48944897
{
4895-
if (getVal(key, layer, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
4898+
if (getVal(key, layer, 0, maxWait) != SFE_UBLOX_STATUS_DATA_RECEIVED)
48964899
return (0);
48974900

48984901
return (extractLong(&packetCfg, 8));
@@ -5211,6 +5214,38 @@ uint8_t SFE_UBLOX_GNSS::sendCfgValset8(uint32_t key, uint8_t value, uint16_t max
52115214
return (sendCommand(&packetCfg, maxWait) == SFE_UBLOX_STATUS_DATA_SENT); // We are only expecting an ACK
52125215
}
52135216

5217+
//Read 18 sets of key values, for a total of 1088 keys
5218+
//Format the output to match the config files that u-center can understand
5219+
//Layer number can be 0 (RAM) or layer 7 (Default)
5220+
void SFE_UBLOX_GNSS::downloadDeviceConfig(Stream &downloadPort, uint8_t layerNumber, uint16_t maxWait)
5221+
{
5222+
for (int x = 0 ; x < 18 ; x++)
5223+
{
5224+
getVal(0x0FFF0000, layerNumber, x * 64, maxWait); //Advance by 64 keys each time
5225+
5226+
//All lines start with a VALGET
5227+
downloadPort.print(F("CFG-VALGET - 06 8B "));
5228+
5229+
//Pretty print the response length
5230+
uint16_t responseLength = packetCfg.len;
5231+
if ((responseLength & 0xFF) < 0x10) downloadPort.print(F("0"));
5232+
downloadPort.print(responseLength & 0xFF, HEX);
5233+
downloadPort.print(F(" "));
5234+
if ((responseLength >> 8) < 0x10) downloadPort.print(F("0"));
5235+
downloadPort.print(responseLength >> 8, HEX);
5236+
5237+
//Pretty print the payload
5238+
for (int x = 0 ; x < 32 ; x++)
5239+
{
5240+
downloadPort.print(F(" "));
5241+
if (payloadCfg[x] < 0x10) downloadPort.print(F("0"));
5242+
downloadPort.print(payloadCfg[x], HEX);
5243+
}
5244+
downloadPort.println();
5245+
}
5246+
}
5247+
5248+
52145249
//=-=-=-=-=-=-=-= "Automatic" Messages =-=-=-=-=-=-=-==-=-=-=-=-=-=-=
52155250
//=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-==-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
52165251

src/SparkFun_u-blox_GNSS_Arduino_Library.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -747,7 +747,7 @@ class SFE_UBLOX_GNSS
747747
//It is probably safe to assume that users of the ZED-F9P will be using I2C / Qwiic.
748748
//If they are using Serial then the higher baud rate will also help. So let's leave maxWait set to 250ms.
749749
uint32_t createKey(uint16_t group, uint16_t id, uint8_t size); //Form 32-bit key from group/id/size
750-
sfe_ublox_status_e getVal(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Load payload with response
750+
sfe_ublox_status_e getVal(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t skipAmt = 0, uint16_t maxWait = 250); //Load payload with response
751751
uint8_t getVal8(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given key location
752752
uint16_t getVal16(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given key location
753753
uint32_t getVal32(uint32_t keyID, uint8_t layer = VAL_LAYER_RAM, uint16_t maxWait = 250); //Returns the value at a given key location
@@ -767,6 +767,7 @@ class SFE_UBLOX_GNSS
767767
uint8_t sendCfgValset8(uint32_t keyID, uint8_t value, uint16_t maxWait = 250); //Add the final KeyID and 8-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
768768
uint8_t sendCfgValset16(uint32_t keyID, uint16_t value, uint16_t maxWait = 250); //Add the final KeyID and 16-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
769769
uint8_t sendCfgValset32(uint32_t keyID, uint32_t value, uint16_t maxWait = 250); //Add the final KeyID and 32-bit value to an existing UBX-CFG-VALSET ubxPacket and send it
770+
void downloadDeviceConfig(Stream &port = Serial, uint8_t layerNumber = VAL_LAYER_RAM, uint16_t maxWait = 1000); //Pipe entire device's config data to a user chosen stream
770771

771772
// getPVT will only return data once in each navigation cycle. By default, that is once per second.
772773
// Therefore we should set defaultMaxWait to slightly longer than that.

0 commit comments

Comments
 (0)