dRonin  adbada4
dRonin firmware
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
UBX.h
Go to the documentation of this file.
1 
15 /*
16  * This program is free software; you can redistribute it and/or modify
17  * it under the terms of the GNU General Public License as published by
18  * the Free Software Foundation; either version 3 of the License, or
19  * (at your option) any later version.
20  *
21  * This program is distributed in the hope that it will be useful, but
22  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
23  * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
24  * for more details.
25  *
26  * You should have received a copy of the GNU General Public License along
27  * with this program; if not, see <http://www.gnu.org/licenses/>
28  */
29 
30 #ifndef UBX_H
31 #define UBX_H
32 #include "openpilot.h"
33 #include "gpsposition.h"
34 #include "GPS.h"
35 
36 
37 #define UBX_SYNC1 0xb5 // UBX protocol synchronization characters
38 #define UBX_SYNC2 0x62
39 
40 // From u-blox6 receiver protocol specification
41 
42 // Messages classes
43 #define UBX_CLASS_NAV 0x01
44 
45 // Message IDs (all in NAV class)
46 #define UBX_ID_POSLLH 0x02
47 #define UBX_ID_STATUS 0x03
48 #define UBX_ID_DOP 0x04
49 #define UBX_ID_SOL 0x06
50 #define UBX_ID_VELNED 0x12
51 #define UBX_ID_TIMEUTC 0x21
52 #define UBX_ID_SVINFO 0x30
53 
54 #define UBX_CLASS_MON 0x0A
55 
56 #define UBX_ID_MONVER 0x04
57 // private structures
58 
59 // Geodetic Position Solution
61  uint32_t iTOW; // GPS Millisecond Time of Week (ms)
62  int32_t lon; // Longitude (deg*1e-7)
63  int32_t lat; // Latitude (deg*1e-7)
64  int32_t height; // Height above Ellipsoid (mm)
65  int32_t hMSL; // Height above mean sea level (mm)
66  uint32_t hAcc; // Horizontal Accuracy Estimate (mm)
67  uint32_t vAcc; // Vertical Accuracy Estimate (mm)
68 };
69 
70 // Receiver Navigation Status
71 
72 #define STATUS_GPSFIX_NOFIX 0x00
73 #define STATUS_GPSFIX_DRONLY 0x01
74 #define STATUS_GPSFIX_2DFIX 0x02
75 #define STATUS_GPSFIX_3DFIX 0x03
76 #define STATUS_GPSFIX_GPSDR 0x04
77 #define STATUS_GPSFIX_TIMEONLY 0x05
78 
79 #define STATUS_FLAGS_GPSFIX_OK (1 << 0)
80 #define STATUS_FLAGS_DIFFSOLN (1 << 1)
81 #define STATUS_FLAGS_WKNSET (1 << 2)
82 #define STATUS_FLAGS_TOWSET (1 << 3)
83 
85  uint32_t iTOW; // GPS Millisecond Time of Week (ms)
86  uint8_t gpsFix; // GPS fix type
87  uint8_t flags; // Navigation Status Flags
88  uint8_t fixStat; // Fix Status Information
89  uint8_t flags2; // Additional navigation output information
90  uint32_t ttff; // Time to first fix (ms)
91  uint32_t msss; // Milliseconds since startup/reset (ms)
92 };
93 
94 // Dilution of precision
95 struct UBX_NAV_DOP {
96  uint32_t iTOW; // GPS Millisecond Time of Week (ms)
97  uint16_t gDOP; // Geometric DOP
98  uint16_t pDOP; // Position DOP
99  uint16_t tDOP; // Time DOP
100  uint16_t vDOP; // Vertical DOP
101  uint16_t hDOP; // Horizontal DOP
102  uint16_t nDOP; // Northing DOP
103  uint16_t eDOP; // Easting DOP
104 };
105 
106 // Navigation solution
107 
108 struct UBX_NAV_SOL {
109  uint32_t iTOW; // GPS Millisecond Time of Week (ms)
110  int32_t fTOW; // fractional nanoseconds (ns)
111  int16_t week; // GPS week
112  uint8_t gpsFix; // GPS fix type
113  uint8_t flags; // Fix status flags
114  int32_t ecefX; // ECEF X coordinate (cm)
115  int32_t ecefY; // ECEF Y coordinate (cm)
116  int32_t ecefZ; // ECEF Z coordinate (cm)
117  uint32_t pAcc; // 3D Position Accuracy Estimate (cm)
118  int32_t ecefVX; // ECEF X coordinate (cm/s)
119  int32_t ecefVY; // ECEF Y coordinate (cm/s)
120  int32_t ecefVZ; // ECEF Z coordinate (cm/s)
121  uint32_t sAcc; // Speed Accuracy Estimate
122  uint16_t pDOP; // Position DOP
123  uint8_t reserved1; // Reserved
124  uint8_t numSV; // Number of SVs used in Nav Solution
125  uint32_t reserved2; // Reserved
126 };
127 
128 // North/East/Down velocity
129 
131  uint32_t iTOW; // ms GPS Millisecond Time of Week
132  int32_t velN; // cm/s NED north velocity
133  int32_t velE; // cm/s NED east velocity
134  int32_t velD; // cm/s NED down velocity
135  uint32_t speed; // cm/s Speed (3-D)
136  uint32_t gSpeed; // cm/s Ground Speed (2-D)
137  int32_t heading; // 1e-5 *deg Heading of motion 2-D
138  uint32_t sAcc; // cm/s Speed Accuracy Estimate
139  uint32_t cAcc; // 1e-5 *deg Course / Heading Accuracy Estimate
140 };
141 
142 // UTC Time Solution
143 
144 #define TIMEUTC_VALIDTOW (1 << 0)
145 #define TIMEUTC_VALIDWKN (1 << 1)
146 #define TIMEUTC_VALIDUTC (1 << 2)
147 
149  uint32_t iTOW; // GPS Millisecond Time of Week (ms)
150  uint32_t tAcc; // Time Accuracy Estimate (ns)
151  int32_t nano; // Nanoseconds of second
152  uint16_t year;
153  uint8_t month;
154  uint8_t day;
155  uint8_t hour;
156  uint8_t min;
157  uint8_t sec;
158  uint8_t valid; // Validity Flags
159 };
160 
161 // Space Vehicle (SV) Information
162 
163 // Single SV information block
164 
165 #define SVUSED (1 << 0) // This SV is used for navigation
166 #define DIFFCORR (1 << 1) // Differential correction available
167 #define ORBITAVAIL (1 << 2) // Orbit information available
168 #define ORBITEPH (1 << 3) // Orbit information is Ephemeris
169 #define UNHEALTHY (1 << 4) // SV is unhealthy
170 #define ORBITALM (1 << 5) // Orbit information is Almanac Plus
171 #define ORBITAOP (1 << 6) // Orbit information is AssistNow Autonomous
172 #define SMOOTHED (1 << 7) // Carrier smoothed pseudoranges used
173 
175  uint8_t chn; // Channel number
176  uint8_t svid; // Satellite ID
177  uint8_t flags; // Misc SV information
178  uint8_t quality; // Misc quality indicators
179  uint8_t cno; // Carrier to Noise Ratio (dbHz)
180  int8_t elev; // Elevation (integer degrees)
181  int16_t azim; // Azimuth (integer degrees)
182  int32_t prRes; // Pseudo range residual (cm)
183 };
184 
185 // SV information message
186 #define MAX_SVS 32
187 
189  uint32_t iTOW; // GPS Millisecond Time of Week (ms)
190  uint8_t numCh; // Number of channels
191  uint8_t globalFlags; //
192  uint16_t reserved2; // Reserved
193  struct UBX_NAV_SVINFO_SV sv[MAX_SVS]; // Repeated 'numCh' times
194 };
195 
196 struct UBX_MON_VER {
197  uint8_t swVersion[30];
198  uint8_t hwVersion[10];
199  uint8_t extra[30];
200 };
201 
202 typedef union {
203  uint8_t payload[0];
204  struct UBX_NAV_POSLLH nav_posllh;
205  struct UBX_NAV_STATUS nav_status;
206  struct UBX_NAV_DOP nav_dop;
207  struct UBX_NAV_SOL nav_sol;
208  struct UBX_NAV_VELNED nav_velned;
209  struct UBX_NAV_TIMEUTC nav_timeutc;
210  struct UBX_NAV_SVINFO nav_svinfo;
211  struct UBX_MON_VER mon_ver;
212 } UBXPayload;
213 
214 struct UBXHeader {
215  uint8_t class;
216  uint8_t id;
217  uint16_t len;
218  uint8_t ck_a;
219  uint8_t ck_b;
220 };
221 
222 struct UBXPacket {
225 };
226 
227 int parse_ubx_stream(uint8_t, char *, GPSPositionData *, struct GPS_RX_STATS *);
228 
229 #endif /* UBX_H */
230 
uint16_t hDOP
Definition: UBX.h:101
uint16_t vDOP
Definition: UBX.h:100
struct UBXHeader header
Definition: UBX.h:223
uint32_t cAcc
Definition: UBX.h:139
uint8_t globalFlags
Definition: UBX.h:191
int32_t lon
Definition: UBX.h:62
uint8_t svid
Definition: UBX.h:176
uint8_t ck_b
Definition: UBX.h:219
int32_t ecefVY
Definition: UBX.h:119
uint16_t pDOP
Definition: UBX.h:98
uint8_t extra[30]
Definition: UBX.h:199
uint32_t iTOW
Definition: UBX.h:189
uint8_t month
Definition: UBX.h:153
uint8_t sec
Definition: UBX.h:157
uint8_t numCh
Definition: UBX.h:190
uint16_t pDOP
Definition: UBX.h:122
uint32_t pAcc
Definition: UBX.h:117
uint8_t cno
Definition: UBX.h:179
Definition: UBX.h:214
uint8_t hwVersion[10]
Definition: UBX.h:198
int32_t heading
Definition: UBX.h:137
uint32_t iTOW
Definition: UBX.h:109
int32_t ecefX
Definition: UBX.h:114
int32_t hMSL
Definition: UBX.h:65
uint8_t payload[CRSF_MAX_PAYLOAD+CRSF_CRC_LEN]
int16_t week
Definition: UBX.h:111
uint8_t chn
Definition: UBX.h:175
uint8_t day
Definition: UBX.h:154
uint32_t vAcc
Definition: UBX.h:67
uint32_t tAcc
Definition: UBX.h:150
uint8_t gpsFix
Definition: UBX.h:112
#define MAX_SVS
Definition: UBX.h:186
uint32_t iTOW
Definition: UBX.h:96
int8_t elev
Definition: UBX.h:180
int16_t azim
Definition: UBX.h:181
uint8_t reserved1
Definition: UBX.h:123
uint16_t reserved2
Definition: UBX.h:192
int32_t velE
Definition: UBX.h:133
uint8_t flags
Definition: UBX.h:113
uint16_t year
Definition: UBX.h:152
int32_t velD
Definition: UBX.h:134
uint8_t fixStat
Definition: UBX.h:88
uint32_t sAcc
Definition: UBX.h:121
Include file of the GPS module.
uint16_t len
Definition: UBX.h:217
int32_t velN
Definition: UBX.h:132
int parse_ubx_stream(uint8_t, char *, GPSPositionData *, struct GPS_RX_STATS *)
uint8_t ck_a
Definition: UBX.h:218
uint16_t tDOP
Definition: UBX.h:99
uint32_t msss
Definition: UBX.h:91
uint32_t iTOW
Definition: UBX.h:149
uint8_t flags
Definition: UBX.h:177
uint8_t flags2
Definition: UBX.h:89
uint32_t ttff
Definition: UBX.h:90
int32_t ecefZ
Definition: UBX.h:116
uint32_t hAcc
Definition: UBX.h:66
uint8_t min
Definition: UBX.h:156
int32_t ecefY
Definition: UBX.h:115
int32_t ecefVZ
Definition: UBX.h:120
uint32_t iTOW
Definition: UBX.h:131
int32_t height
Definition: UBX.h:64
uint8_t quality
Definition: UBX.h:178
int32_t lat
Definition: UBX.h:63
Includes PiOS and core architecture components.
uint8_t id
Definition: UBX.h:216
uint32_t reserved2
Definition: UBX.h:125
int32_t ecefVX
Definition: UBX.h:118
uint8_t numSV
Definition: UBX.h:124
uint16_t eDOP
Definition: UBX.h:103
uint16_t gDOP
Definition: UBX.h:97
uint32_t iTOW
Definition: UBX.h:85
uint32_t sAcc
Definition: UBX.h:138
uint8_t gpsFix
Definition: UBX.h:86
uint32_t gSpeed
Definition: UBX.h:136
int32_t prRes
Definition: UBX.h:182
uint8_t swVersion[30]
Definition: UBX.h:197
uint8_t flags
Definition: UBX.h:87
int32_t nano
Definition: UBX.h:151
uint32_t iTOW
Definition: UBX.h:61
struct UBX_NAV_SVINFO_SV sv[MAX_SVS]
Definition: UBX.h:193
int32_t fTOW
Definition: UBX.h:110
uint8_t hour
Definition: UBX.h:155
uint16_t nDOP
Definition: UBX.h:102
Definition: UBX.h:222
UBXPayload payload
Definition: UBX.h:224
uint8_t valid
Definition: UBX.h:158
uint32_t speed
Definition: UBX.h:135