forked from MamMark/mm
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsirf_msg.h
385 lines (324 loc) · 9.24 KB
/
sirf_msg.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
/*
* Copyright (c) 2017, 2019 Eric B. Decker
* All rights reserved.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
* See COPYING in the top level directory of this source tree.
*
* Contact: Eric B. Decker <[email protected]>
*/
#ifndef __SIRF_MSG_H__
#define __SIRF_MSG_H__
/*
* Various external SirfBin/Sirf structures and definitions that are protocol
* dependent (external to the chip).
*/
#ifndef PACKED
#define PACKED __attribute__((__packed__))
#endif
#define NMEA_START '$'
#define NMEA_END '*'
#define SIRFBIN_A0 0xa0
#define SIRFBIN_A2 0xa2
#define SIRFBIN_B0 0xb0
#define SIRFBIN_B3 0xb3
/* overhead: start (2), len (2), checksum (2), end (2) */
#define SIRFBIN_OVERHEAD 8
#define MID_NAVDATA 2
#define NAVDATA_LEN 41
#define MID_NAVTRACK 4
#define MID_SWVER 6
#define MID_CLOCKSTATUS 7
#define CLOCKSTATUS_LEN 20
#define MID_ACK 11
#define MID_NACK 12
#define MID_OTS 18
#define MID_GEODETIC 41
#define GEODETIC_LEN 91
#define MID_GPIO 65
#define SID_GPIO 192
#define MID_HW_CONFIG_REQ 71
#define MID_SESSION_RSP 74
#define MID_PWR_MODE_RSP 90
#define PWR_MODE_RSP_LEN 6
/*
* max size (sirfbin length) message we will receive
*
* If we are eavesdropping then we want to see everything
* and the largest we have seen is MID 4 (len 0xbc, 188 + 8)
* 196, we round up to 200.
*/
#define SIRFBIN_MIN_MSG 1
#define SIRFBIN_MAX_MSG 200
#define SIRFBIN_MAX_SW_VER 88
/* actual size of expected PEEK response */
#define SIRFBIN_PEEK_RSP_LEN 32
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t data[0];
} PACKED sb_header_t;
/* MID 2, Nav Data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
int32_t xpos; /* meters */
int32_t ypos; /* meters */
int32_t zpos; /* meters */
int16_t xvel; /* m/s * 8 */
int16_t yvel; /* m/s * 8 */
int16_t zvel; /* m/s * 8 */
uint8_t mode1; /* see below */
uint8_t hdop5; /* * 5 */
uint8_t mode2; /* see below */
uint16_t week10; /* gps week, 10 lsb, don't use */
uint32_t tow100; /* *100, time of week */
uint8_t nsats; /* SVs in fix */
uint8_t data[0];
/* ch1 PRN - ch12 PRN - pseudo-random noise values, sat ids */
} PACKED sb_nav_data_t;
/* MODE1, bit map */
#define SB_NAV_M1_PMODE_MASK 0x07
#define SB_NAV_M1_TPMODE_MASK 0x08
#define SB_NAV_M1_ALTMODE_MASK 0x30
#define SB_NAV_M1_DOPMASK_MASK 0x40
#define SB_NAV_M1_DGPS_MASK 0x80
/* Position Mode */
#define SB_NAV_M1_PMODE_NONE 0
#define SB_NAV_M1_PMODE_SV1KF 1
#define SB_NAV_M1_PMODE_SV2KF 2
#define SB_NAV_M1_PMODE_SV3KF 3
#define SB_NAV_M1_PMODE_SVODKF 4
#define SB_NAV_M1_PMODE_2D 5
#define SB_NAV_M1_PMODE_3D 6
#define SB_NAV_M1_PMODE_DR 7
/* TricklePower Mode */
#define SB_NAV_M1_TPMODE_FULL 0x00
#define SB_NAV_M1_TPMODE_TRICKLE 0x08
/* Altitude Mode */
#define SB_NAV_M1_ALTMODE_NONE 0x00
#define SB_NAV_M1_ALTMODE_KFHOLD 0x10
#define SB_NAV_M1_ALTMODE_USERHOLD 0x20
#define SB_NAV_M1_ALTMODE_ALWAYS 0x30
/* Dilution of Precision */
#define SB_NAV_M1_DOPMASK_OK 0x00
#define SB_NAV_M1_DOPMASK_EXCEEDED 0x40
/* Differential GPS */
#define SB_NAV_M1_DGPS_NONE 0x00
#define SB_NAV_M1_DGPS_APPLIED 0x80
/* MODE2, bit map */
/* for the time being, we don't care about M2 */
#define SB_NAV_M2_SOL_VALIDATED 0x02
#define SB_NAV_M2_VEL_INVALID 0x10
#define SB_NAV_M2_ALTHOLD_DISABLED 0x20
typedef struct {
uint8_t svid;
uint8_t az23;
uint8_t el2;
uint8_t state[2];
uint8_t cno[10];
} PACKED sb_tracker_element_t;
/* MID 4, Tracker Data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint16_t week10; /* modulo 1024 */
uint32_t tow100; /* time * 100 (ms) */
uint8_t chans;
/* for each chan:
* SVid, Az, El, State, C/NO 1:10
*/
sb_tracker_element_t sats[12];
} PACKED sb_tracker_data_t;
/* MID 6, s/w version */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t data[0];
} PACKED sb_soft_version_data_t;
/* MID 7, clock status */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint16_t week_x; /* extended week */
uint32_t tow100; /* tow * 100 */
uint8_t nsats;
uint32_t drift;
uint32_t bias;
uint32_t esttime_ms; /* ms, @ start of measurement */
} PACKED sb_clock_status_data_t;
/* MID 10, error data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint16_t submsg;
uint16_t count;
uint8_t data[0];
} PACKED sb_error_data_t;
/* MIDS 11/12 ack/nack */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t a_mid;
uint8_t a_sid;
} PACKED sb_acknack_t;
/* MID 14, almanac data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t satid;
uint16_t weekstatus;
uint8_t data[0];
} PACKED sb_almanac_status_data_t;
/* MID 28, nav lib data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t chan;
uint32_t time_tag;
uint8_t sat_id;
uint64_t soft_time;
uint64_t pseudo_range;
uint32_t car_freq;
uint64_t car_phase;
uint16_t time_in_track;
uint8_t sync_flags;
uint8_t c_no_1;
uint8_t c_no_2;
uint8_t c_no_3;
uint8_t c_no_4;
uint8_t c_no_5;
uint8_t c_no_6;
uint8_t c_no_7;
uint8_t c_no_8;
uint8_t c_no_9;
uint8_t c_no_10;
uint16_t delta_range_intv;
uint16_t mean_delta_time_range;
uint16_t extrap_time;
uint8_t phase_err_cnt;
uint8_t low_pow_cnt;
} PACKED sb_nav_lib_data_t;
/* MID 41, geodetic data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint16_t nav_valid; /* bit mask */
uint16_t nav_type;
uint16_t week_x; /* extended */
uint32_t tow1000; /* seconds x 1e3 */
uint16_t utc_year;
uint8_t utc_month;
uint8_t utc_day;
uint8_t utc_hour;
uint8_t utc_min;
uint16_t utc_ms; /* x 1e3 (millisecs) */
uint32_t sat_mask;
int32_t lat;
int32_t lon;
int32_t alt_elipsoid; /* m * 100 */
int32_t alt_msl; /* m * 100 */
uint8_t map_datum;
uint16_t sog; /* m/s * 100 */
uint16_t cog; /* deg cw from N_t * 100 */
uint16_t mag_var;
int16_t climb;
int16_t heading_rate;
uint32_t ehpe;
uint32_t evpe;
uint32_t ete;
uint16_t ehve;
int32_t clock_bias;
int32_t clock_bias_err;
int32_t clock_drift;
int32_t clock_drift_err;
uint32_t distance;
uint16_t distance_err;
uint16_t head_err;
uint8_t nsats; /* num_svs, num sat vehicles */
uint8_t hdop;
uint8_t additional_mode;
} PACKED sb_geodetic_t;
#define SB_GEO_TYPE_MASK 0x7
#define SB_GEO_TYPE_NONE 0
/* MID 52, 1PPS data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t hr;
uint8_t min;
uint8_t sec;
uint8_t day;
uint8_t mo;
uint16_t year;
int16_t utcintoff; /* secs */
uint32_t utcfracoff; /* nanosecs, * 10^9 */
uint8_t status;
uint32_t reserved;
} PACKED sb_pps_data_t;
#define SB_PPS_STATUS_VALID 1
#define SB_PPS_STATUS_UTC 2
#define SB_PPS_STATUS_UTCGPS 4
#define SB_PPS_STATUS_UTCGPS 4
/*
* MID 74, Open/Close Session Status
*
* open is sid 1, close sid 2
* status: 0 open/close success
* 1 open/close failed
* 0x80 suspend/resume success
* 0x81 suspend/resume failed
*/
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t sid;
uint8_t status;
} PACKED sb_session_rsp_t;
/* MID 90, pwr_mode_rsp data */
typedef struct {
uint8_t start1;
uint8_t start2;
uint16_t len;
uint8_t mid;
uint8_t sid;
uint16_t error;
uint16_t reserved;
} PACKED sb_pwr_rsp_t;
#define PWR_RSP_MPM_GOOD 0x0010
#endif /* __SIRF_MSG_H__ */