Skip to content

Commit 4b03031

Browse files
committed
Create Adding_New_Messages.md
1 parent 57f1332 commit 4b03031

File tree

1 file changed

+167
-0
lines changed

1 file changed

+167
-0
lines changed

Adding_New_Messages.md

Lines changed: 167 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,167 @@
1+
## How to add new messages to the SparkFun u-blox GNSS Arduino Library
2+
3+
Based on [this issue](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/issues/97), here is a summary of how to add new messages to the SparkFun u-blox GNSS Arduino Library
4+
- with full "auto" support (for callbacks, logging, etc.).
5+
6+
Looking at the issue, we see that the library is not supporting the UBX-NAV-PVAT (Navigation Position Velocity Attitude Time solution).
7+
PVAT is a new message added in version 1.21 of the HPS (High Precision Fusion) firmware and version 33.21 of the F9 Interface Description.
8+
This makes us wonder if more new messages have been added which should also be included?
9+
10+
### Step 1: Check the Interface Description for new keys
11+
12+
* Download the latest [interface description](https://www.u-blox.com/sites/default/files/ZED-F9R_ProductSummary_UBX-19048775.pdf) from the [u-blox website](https://www.u-blox.com/en/product/zed-f9r-module#tab-documentation-resources)
13+
* Open the interface description in Adobe Acrobat Reader DC (the free version)
14+
* Do a ```File \ Save as Text...```
15+
* Save the file in ```Text (Accessible) (*.txt)``` format
16+
* Go make a cup of tea - this takes a while
17+
* Open the txt file in Notepad++ or another editor which supports Regular Expressions
18+
* The keys will have been saved as individual lines in the format: 0xnnnnnnnn space CR LF
19+
* So all we need to do is use a regex to delete everything else
20+
* Open Search \ Replace
21+
* Click the Search Mode - Regular Expression button
22+
* In the "Find what :" box enter: ```^(?!.*0x[\dabcdefABCDEF]{8}\s\r\n).*```
23+
* Clear the "Replace with :" box
24+
* Click "Replace All"
25+
* You are left with just the keys - and a bunch of empty lines, some of which contain form feeds (\f)
26+
* Delete the empty lines (\r\n) by replacing \r\n with nothing - don't panic, this takes a few seconds
27+
* Delete the form feeds by replacing \f with nothing
28+
* Finally replace the remaining spaces (\s) with \r\n
29+
* Delete any spurious lines left at the start of the file. E.g. ROM and BASE and 0x118B2060. These came from the General information section
30+
* The following line (0x10340014) is the first key from the "Configuration Reference" section
31+
* Search for that key number and you will find it again half way through the file. This second copy came from "Configuration Defaults"
32+
* Delete the duplicate keys from that line onwards
33+
* Save the file
34+
* Open it in a spreadsheet, e.g. LibreOffice Calc
35+
* Select the "A" column and click "Sort Ascending A-Z"
36+
* Save the file (as Text CSV)
37+
* Use KDiff3 or another diff package to see the new additions
38+
39+
You can find the keys in the [keys folder](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/tree/main/keys), saved as sorted text files.
40+
There are separate files for the P, R and T interfaces, plus a combined list (also sorted in ascending order).
41+
42+
Comparing HPS 1.21 to HPS 1.20, we can see that the following keys have been added:
43+
44+
* 0x10340014 CFG-BDS-USE_GEO_PRN
45+
* 0x10710005 CFG-I2CINPROT-SPARTN
46+
* 0x10730005 CFG-UART1INPROT-SPARTN
47+
* 0x10750005 CFG-UART2INPROT-SPARTN
48+
* 0x10770005 CFG-USBINPROT-SPARTN
49+
* 0x10790005 CFG-SPIINPROT-SPARTN
50+
* 0x20050035 CFG-TP-DRSTR_TP1
51+
* 0x20910605 CFG-MSGOUT-UBX_RXM_SPARTN_I2C
52+
* 0x20910606 CFG-MSGOUT-UBX_RXM_SPARTN_UART1
53+
* 0x20910607 CFG-MSGOUT-UBX_RXM_SPARTN_UART2
54+
* 0x20910608 CFG-MSGOUT-UBX_RXM_SPARTN_USB
55+
* 0x20910609 CFG-MSGOUT-UBX_RXM_SPARTN_SPI
56+
* 0x2091062a CFG-MSGOUT-UBX_NAV_PVAT_I2C
57+
* 0x2091062b CFG-MSGOUT-UBX_NAV_PVAT_UART1
58+
* 0x2091062c CFG-MSGOUT-UBX_NAV_PVAT_UART2
59+
* 0x2091062d CFG-MSGOUT-UBX_NAV_PVAT_USB
60+
* 0x2091062e CFG-MSGOUT-UBX_NAV_PVAT_SPI
61+
* 0x20910634 CFG-MSGOUT-UBX_SEC_SIG_I2C
62+
* 0x20910635 CFG-MSGOUT-UBX_SEC_SIG_UART1
63+
* 0x20910636 CFG-MSGOUT-UBX_SEC_SIG_UART2
64+
* 0x20910637 CFG-MSGOUT-UBX_SEC_SIG_USB
65+
* 0x20910638 CFG-MSGOUT-UBX_SEC_SIG_SPI
66+
67+
Interestingly, we can also see that one key has been deleted:
68+
69+
* 0x10530006 CFG-UART2-REMAP
70+
71+
From this we can confirm - as documented by u-blox in the [Release Notes](https://www.u-blox.com/sites/default/files/ZED-F9R-02B_FW1.00HPS1.21_RN_UBX-21035491_1.3.pdf) -
72+
that HPS 1.21:
73+
74+
* adds support for SPARTN (Safe Position Augmentation for Real-Time Navigation) correction messages
75+
* enables the use of BeiDou geostationary satellites (previously, this configuration item had a different name)
76+
* enables UBX-SEC-SIG message (signal security measures) as output across the different interfaces
77+
* enables UBX_NAV_PVAT message (navigation and altitude position) as output across the different interfaces
78+
79+
There are also two new dynamic models, robotic lawn mower (11) and e-scooter model (12), which we need to add to the library.
80+
81+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/805aab18b6656513bfee473487a437754cd3965d) for the changes.
82+
83+
### Step 2: Update the combined keys file
84+
85+
Update [u-blox_config_keys_sorted.txt](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/blob/main/keys/u-blox_config_keys_sorted.txt)
86+
to include the new keys.
87+
88+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/8895764f237ae494dcd0fa1ae942d487d2e1557f) for the changes.
89+
90+
### Step 3: Update u-blox_config_keys.h
91+
92+
Update [u-blox_config_keys.h](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/blob/main/src/u-blox_config_keys.h) to include the new keys.
93+
Include the descriptions as defined in the Interface Description.
94+
95+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/3609da15f90a7a66b41524e77c6dc3dd76cd362c) for the changes.
96+
97+
### Step 4: Add the new message struct to u-blox_struct.h
98+
99+
The next step is to add the new struct for UBX-NAV-PVAT to u-blox_struct.h.
100+
101+
The messages are in ascending class and ID order. So we add UBX-NAV-PVAT (0x01 0x17) after UBX-NAV-HPPOSLLH (0x01 0x14).
102+
103+
The names and widths of the fields are taken directly from the interface definition.
104+
105+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/a4ba440c6240e0974c27f40b976a5ddf0fbdb9b6) for the changes.
106+
107+
### Step 5: Update SparkFun_u-blox_GNSS_Arduino_Library.h
108+
109+
Add the new message ID: ```const uint8_t UBX_NAV_PVAT = 0x17;```
110+
111+
Add the new functions to provide "auto" support for UBX-NAV-PVAT: ```getNAVPVAT```, ```setAutoNAVPVAT```, ..., ```logNAVPVAT```
112+
113+
Add new helper functions to access the most important fields: ```getVehicleRoll```, ..., ```getMotionHeading```
114+
115+
Add the pointer to the struct storage: ```UBX_NAV_PVAT_t *packetUBXNAVPVAT = NULL;```
116+
117+
Add the private init function: ```bool initPacketUBXNAVPVAT();```
118+
119+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/423a1e2ccd418dd679257edc6edeec0bd3029052) for the changes.
120+
121+
### Step 6: Update SparkFun_u-blox_GNSS_Arduino_Library.cpp
122+
123+
Now we need to update SparkFun_u-blox_GNSS_Arduino_Library.cpp:
124+
125+
#### Step 6.1: Update end()
126+
127+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/35d225e3f1abb316eda3becb7f8e2eb04ff1d17c) for the changes.
128+
129+
#### Step 6.2: Update checkAutomatic()
130+
131+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/b746d8e2742961ede95e2d06d5db3a3a557e571d) for the changes.
132+
133+
#### Step 6.3: Update processUBXpacket()
134+
135+
Take time to double-check that you have used the correct data width, signed/unsigned and position for each field.
136+
137+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/8eecdd5044f810b0e2b567150ff63a17c219fe8e) for the changes.
138+
139+
#### Step 6.4: Update checkCallbacks()
140+
141+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/b53bffaa3ae12482cfb268f23796963d0b8519c9) for the changes.
142+
143+
#### Step 6.5: Add the "auto" functions
144+
145+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/e394ae003ad38117d150598774d0552059416473) for the changes.
146+
147+
#### Step 6.6: Add the helper functions (if any)
148+
149+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/318e76383e96d6676bbb57294c25e665c0d4a31f) for the changes.
150+
151+
### Step 7: Add an example
152+
153+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/06014dc95f1b9ffae4876fbacfb9390541d7c31d) for the changes.
154+
155+
### Step 8: Update keywords.txt
156+
157+
Add the new "auto" and helper functions to keywords.txt.
158+
159+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/4f0a0ca3c5e6420be9064b91702947c23104bd1b) for the changes.
160+
161+
### Step 9: Update Theory.md
162+
163+
Add the new message to the list of "auto" messages.
164+
165+
See [this commit](https://github.com/sparkfun/SparkFun_u-blox_GNSS_Arduino_Library/commit/57f133259245d8071c73797e4be2ff630c2720ab) for the changes.
166+
167+
That's all folks!

0 commit comments

Comments
 (0)