Skip to content

Commit 8589b63

Browse files
committed
Update README.md
1 parent c8cbdc6 commit 8589b63

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ This library is the new and improved version of the very popular SparkFun u-blox
3737
* The hardware interface has been abstracted:
3838
* All hardware communication is performed through ```class GNSSDeviceBus```
3939
* This makes it _much_ easier to re-use this library on other hardware platforms. Only ```sfe_bus.h``` and ```sfe_bus.cpp``` need to be updated
40+
* Template methods simplify multiple-VALGET and multiple-VALSET configuration
4041

4142
## Migrating to v3
4243

@@ -133,6 +134,87 @@ key &= ~UBX_CFG_SIZE_MASK; // Mask off the size identifer bits
133134

134135
The get and set template methods are based on an idea by Michael Ammann. Thank you @mazgch
135136

137+
#### Multiple-VALGET
138+
139+
Start by creating a custom ```ubxPacket``` :
140+
141+
```
142+
const uint16_t maxPayloadSize = 100; // Make this large enough to hold all keys and values
143+
uint8_t customPayload[maxPayloadSize]; // This array holds the payload data bytes
144+
ubxPacket customCfg = {0, 0, 0, 0, 0, customPayload, 0, 0, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED, SFE_UBLOX_PACKET_VALIDITY_NOT_DEFINED}; // Create and initialise the custom packet
145+
myGNSS.newCfgValget(&customCfg, maxPayloadSize, VAL_LAYER_RAM); // Create a new VALGET construct inside the custom packet
146+
```
147+
148+
Add the Keys you want to get using ```addCfgValget``` :
149+
150+
```
151+
myGNSS.addCfgValget(&customCfg, UBLOX_CFG_I2C_ADDRESS); // Get the I2C address (see u-blox_config_keys.h for details)
152+
myGNSS.addCfgValget(&customCfg, UBLOX_CFG_I2COUTPROT_NMEA); // Get the flag indicating is NMEA should be output on I2C
153+
myGNSS.addCfgValget(&customCfg, UBLOX_CFG_UART1_BAUDRATE); // Get the UART1 baud rate
154+
```
155+
156+
Perform the VALGET by calling ```sendCfgValget(&customCfg)```. The method returns true if the VALGET was successful.
157+
158+
Extract the Key Values using the template method ```extractConfigValueByKey```.
159+
160+
**Note:** you do still need to know the data type to extract the data correctly.
161+
162+
Consult the u-blox Interface Description or [u-blox_config_keys.h](./src/u-blox_config_keys.h) to see the data type (size) for each Key ID.
163+
* L : bool
164+
* U1/E1/X1 : uint8_t
165+
* I1 : int8_t
166+
* U2/E2/X2 : uint16_t
167+
* I2 : int16_t
168+
* U4/E4/X4 : uint32_t
169+
* I4 : int32_t
170+
* U8/X8 : uint64_t
171+
* I8 : int64_t
172+
* R4 : float (32-bit)
173+
* R8 : double (64-bit)
174+
175+
Pass a pointer to, or the address of, your variable plus its size (in bytes) to ```extractConfigValueByKey``` to extract the value.
176+
The method returns true if the extraction was successful.
177+
178+
```
179+
uint32_t baud; // U4
180+
myGNSS.extractConfigValueByKey(&customCfg, UBLOX_CFG_UART1_BAUDRATE, &baud, sizeof(baud)); // Get the baud rate - using the key and the address of and sizeof baud
181+
```
182+
183+
Please see [VALGET_and_VALSET/Example6](./examples/VALGET_and_VALSET/Example6_multiSetVal_and_GetVal_Templates/) for more details.
184+
185+
#### Multiple-VALSET
186+
187+
In v2 of the library, you had to specify the key value size when calling ```addCfgValset```. v3 uses a template method to deduce the size automatically
188+
using the size encoded into the key itself.
189+
190+
Start by creating a new VALSET:
191+
192+
```
193+
myGNSS.newCfgValset(VAL_LAYER_RAM); // Create a new VALSET construct (internally in packetCfg)
194+
```
195+
196+
Add each key and value that you wish to set. The type / size is deduced automatically if required. The method returns true if the add is successful.
197+
198+
```
199+
myGNSS.addCfgValset(UBLOX_CFG_UART1_BAUDRATE, 38400); // U4 - deduced automatically
200+
myGNSS.addCfgValset(UBLOX_CFG_TP_DUTY_LOCK_TP1, 50.0); // R8 - deduced automatically
201+
uint32_t freq = 1000; // U4
202+
myGNSS.addCfgValset(UBLOX_CFG_TP_FREQ_LOCK_TP1, freq);
203+
```
204+
205+
Finally, send the VALSET by calling ```sendCfgValset();```. The method returns true if the VALSET was successful.
206+
207+
Please see [VALGET_and_VALSET/Example6](./examples/VALGET_and_VALSET/Example6_multiSetVal_and_GetVal_Templates/) for more details.
208+
209+
If you are setting many configuration items, such that the number of keys and values could overflow ```packetCfg```, you can use the
210+
method ```autoSendCfgValsetAtSpaceRemaining``` to send a VALSET automatically when packetCfg is almost full. E.g.:
211+
212+
```
213+
myGNSS.autoSendCfgValsetAtSpaceRemaining(16); // Trigger an auto-send when packetCfg has less than 16 bytes are remaining
214+
```
215+
216+
Please see [VALGET_and_VALSET/Example4](./examples/VALGET_and_VALSET/Example4_multiSetVal/) for more details.
217+
136218
## Compatibility
137219

138220
v3 of the library provides support for generation F9 and M10 u-blox GNSS modules.

0 commit comments

Comments
 (0)