OLD | NEW |
| (Empty) |
1 /* | |
2 * This file is Copyright (c) 2010 by the GPSD project | |
3 * BSD terms apply: see the file COPYING in the distribution root for details. | |
4 */ | |
5 #ifndef _GPSD_GPS_H_ | |
6 #define _GPSD_GPS_H_ | |
7 | |
8 /* gps.h -- interface of the libgps library */ | |
9 | |
10 #ifdef _WIN32 | |
11 #define strtok_r(s,d,p) strtok_s(s,d,p) | |
12 #endif | |
13 | |
14 #ifdef __cplusplus | |
15 extern "C" { | |
16 #endif | |
17 | |
18 /* Macro for declaring function arguments unused. */ | |
19 #if defined(__GNUC__) | |
20 # define UNUSED __attribute__((unused)) /* Flag variable as unused */ | |
21 #else /* not __GNUC__ */ | |
22 # define UNUSED | |
23 #endif | |
24 | |
25 | |
26 #include <sys/types.h> | |
27 #include <sys/time.h> | |
28 #include <stdbool.h> | |
29 #include <inttypes.h> /* stdint.h would be smaller but not all have it */ | |
30 #include <limits.h> | |
31 #include <time.h> | |
32 #include <signal.h> | |
33 #include <stdio.h> | |
34 #ifndef S_SPLINT_S | |
35 #include <pthread.h> /* pacifies OpenBSD's compiler */ | |
36 #endif | |
37 | |
38 #define GPSD_API_MAJOR_VERSION 4 /* bump on incompatible changes */ | |
39 #define GPSD_API_MINOR_VERSION 1 /* bump on compatible changes */ | |
40 | |
41 #define MAXTAGLEN 8 /* maximum length of sentence tag name */ | |
42 #define MAXCHANNELS 20 /* maximum GPS channels (*not* satellites!) */ | |
43 #define GPS_PRNMAX 32 /* above this number are SBAS satellites */ | |
44 #define GPS_PATH_MAX 64 /* dev files usually have short names */ | |
45 #define MAXUSERDEVS 4 /* max devices per user */ | |
46 | |
47 /* | |
48 * The structure describing an uncertainty volume in kinematic space. | |
49 * This is what GPSes are meant to produce; all the other info is | |
50 * technical impedimenta. | |
51 * | |
52 * All double values use NAN to indicate data not available. | |
53 * | |
54 * Usually all the information in this structure was considered valid | |
55 * by the GPS at the time of update. This will be so if you are using | |
56 * a GPS chipset that speaks SiRF binary, Garmin binary, or Zodiac binary. | |
57 * This covers over 80% of GPS products in early 2005. | |
58 * | |
59 * If you are using a chipset that speaks NMEA, this structure is updated | |
60 * in bits by GPRMC (lat/lon, track, speed), GPGGA (alt, climb), GPGLL | |
61 * (lat/lon), and GPGSA (eph, epv). Most NMEA GPSes take a single fix | |
62 * at the beginning of a 1-second cycle and report the same timestamp in | |
63 * GPRMC, GPGGA, and GPGLL; for these, all info is guaranteed correctly | |
64 * synced to the time member, but you'll get different stages of the same | |
65 * update depending on where in the cycle you poll. A very few GPSes, | |
66 * like the Garmin 48, take a new fix before more than one of of | |
67 * GPRMC/GPGGA/GPGLL during a single cycle; thus, they may have different | |
68 * timestamps and some data in this structure can be up to 1 cycle (usually | |
69 * 1 second) older than the fix time. | |
70 * | |
71 * Error estimates are at 95% confidence. | |
72 */ | |
73 struct gps_fix_t { | |
74 double time; /* Time of update, seconds since Unix epoch */ | |
75 int mode; /* Mode of fix */ | |
76 #define MODE_NOT_SEEN 0 /* mode update not seen yet */ | |
77 #define MODE_NO_FIX 1 /* none */ | |
78 #define MODE_2D 2 /* good for latitude/longitude */ | |
79 #define MODE_3D 3 /* good for altitude/climb too */ | |
80 double ept; /* Expected time uncertainty */ | |
81 double latitude; /* Latitude in degrees (valid if mode >= 2) */ | |
82 double epy; /* Latitude position uncertainty, meters */ | |
83 double longitude; /* Longitude in degrees (valid if mode >= 2) */ | |
84 double epx; /* Longitude position uncertainty, meters */ | |
85 double altitude; /* Altitude in meters (valid if mode == 3) */ | |
86 double epv; /* Vertical position uncertainty, meters */ | |
87 double track; /* Course made good (relative to true north) */ | |
88 double epd; /* Track uncertainty, degrees */ | |
89 double speed; /* Speed over ground, meters/sec */ | |
90 double eps; /* Speed uncertainty, meters/sec */ | |
91 double climb; /* Vertical speed, meters/sec */ | |
92 double epc; /* Vertical speed uncertainty */ | |
93 }; | |
94 | |
95 /* | |
96 * From the RCTM104 2.x standard: | |
97 * | |
98 * "The 30 bit words (as opposed to 32 bit words) coupled with a 50 Hz | |
99 * transmission rate provides a convenient timing capability where the | |
100 * times of word boundaries are a rational multiple of 0.6 seconds." | |
101 * | |
102 * "Each frame is N+2 words long, where N is the number of message data | |
103 * words. For example, a filler message (type 6 or 34) with no message | |
104 * data will have N=0, and will consist only of two header words. The | |
105 * maximum number of data words allowed by the format is 31, so that | |
106 * the longest possible message will have a total of 33 words." | |
107 */ | |
108 #define RTCM2_WORDS_MAX 33 | |
109 #define MAXCORRECTIONS 18 /* max correction count in type 1 or 9 */ | |
110 #define MAXSTATIONS 10 /* maximum stations in almanac, type 5 */ | |
111 /* RTCM104 doesn't specify this, so give it the largest reasonable value */ | |
112 #define MAXHEALTH (RTCM2_WORDS_MAX-2) | |
113 | |
114 #ifndef S_SPLINT_S | |
115 /* | |
116 * A nominally 30-bit word (24 bits of data, 6 bits of parity) | |
117 * used both in the GPS downlink protocol described in IS-GPS-200 | |
118 * and in the format for DGPS corrections used in RTCM-104v2. | |
119 */ | |
120 typedef /*@unsignedintegraltype@*/ uint32_t isgps30bits_t; | |
121 #endif /* S_SPLINT_S */ | |
122 | |
123 /* | |
124 * Values for "system" fields. Note, the encoding logic is senstive to the | |
125 * actual values of these; it's not sufficient that they're distinct. | |
126 */ | |
127 #define NAVSYSTEM_GPS 0 | |
128 #define NAVSYSTEM_GLONASS 1 | |
129 #define NAVSYSTEM_GALILEO 2 | |
130 #define NAVSYSTEM_UNKNOWN 3 | |
131 | |
132 struct rtcm2_t { | |
133 /* header contents */ | |
134 unsigned type; /* RTCM message type */ | |
135 unsigned length; /* length (words) */ | |
136 double zcount; /* time within hour: GPS time, no leap secs */ | |
137 unsigned refstaid; /* reference station ID */ | |
138 unsigned seqnum; /* message sequence number (modulo 8) */ | |
139 unsigned stathlth; /* station health */ | |
140 | |
141 /* message data in decoded form */ | |
142 union { | |
143 struct { | |
144 unsigned int nentries; | |
145 struct rangesat_t { /* data from messages 1 & 9 */ | |
146 unsigned ident; /* satellite ID */ | |
147 unsigned udre; /* user diff. range error */ | |
148 unsigned issuedata; /* issue of data */ | |
149 double rangerr; /* range error */ | |
150 double rangerate; /* range error rate */ | |
151 } sat[MAXCORRECTIONS]; | |
152 } ranges; | |
153 struct { /* data for type 3 messages */ | |
154 bool valid; /* is message well-formed? */ | |
155 double x, y, z; | |
156 } ecef; | |
157 struct { /* data from type 4 messages */ | |
158 bool valid; /* is message well-formed? */ | |
159 int system; | |
160 int sense; | |
161 #define SENSE_INVALID 0 | |
162 #define SENSE_GLOBAL 1 | |
163 #define SENSE_LOCAL 2 | |
164 char datum[6]; | |
165 double dx, dy, dz; | |
166 } reference; | |
167 struct { /* data from type 5 messages */ | |
168 unsigned int nentries; | |
169 struct consat_t { | |
170 unsigned ident; /* satellite ID */ | |
171 bool iodl; /* issue of data */ | |
172 unsigned int health; /* is satellite healthy? */ | |
173 #define HEALTH_NORMAL (0) /* Radiobeacon operation normal */ | |
174 #define HEALTH_UNMONITORED (1) /* No integrity monitor operating */ | |
175 #define HEALTH_NOINFO (2) /* No information available */ | |
176 #define HEALTH_DONOTUSE (3) /* Do not use this radiobeacon */ | |
177 int snr; /* signal-to-noise ratio, dB */ | |
178 #define SNR_BAD -1 /* not reported */ | |
179 bool health_en; /* health enabled */ | |
180 bool new_data; /* new data? */ | |
181 bool los_warning; /* line-of-sight warning */ | |
182 unsigned int tou; /* time to unhealth, seconds */ | |
183 } sat[MAXHEALTH]; | |
184 } conhealth; | |
185 struct { /* data from type 7 messages */ | |
186 unsigned int nentries; | |
187 struct station_t { | |
188 double latitude, longitude; /* location */ | |
189 unsigned int range; /* range in km */ | |
190 double frequency; /* broadcast freq */ | |
191 unsigned int health; /* station health */ | |
192 unsigned int station_id; /* of the transmitter */ | |
193 unsigned int bitrate; /* of station transmissions */ | |
194 } station[MAXSTATIONS]; | |
195 } almanac; | |
196 /* data from type 16 messages */ | |
197 char message[(RTCM2_WORDS_MAX-2) * sizeof(isgps30bits_t)]; | |
198 /* data from messages of unknown type */ | |
199 isgps30bits_t words[RTCM2_WORDS_MAX-2]; | |
200 }; | |
201 }; | |
202 | |
203 /* RTCM3 report structures begin here */ | |
204 | |
205 #define RTCM3_MAX_SATELLITES 64 | |
206 #define RTCM3_MAX_DESCRIPTOR 31 | |
207 #define RTCM3_MAX_ANNOUNCEMENTS 32 | |
208 | |
209 struct rtcm3_rtk_hdr { /* header data from 1001, 1002, 1003, 1004 */ | |
210 /* Used for both GPS and GLONASS, but their timebases differ */ | |
211 unsigned int station_id; /* Reference Station ID */ | |
212 time_t tow; /* GPS Epoch Time (TOW) in ms, | |
213 or GLONASS Epoch Time in ms */ | |
214 bool sync; /* Synchronous GNSS Message Flag */ | |
215 unsigned short satcount; /* # Satellite Signals Processed */ | |
216 bool smoothing; /* Divergence-free Smoothing Indicator */ | |
217 unsigned short interval; /* Smoothing Interval */ | |
218 }; | |
219 | |
220 struct rtcm3_basic_rtk { | |
221 unsigned char indicator; /* Indicator */ | |
222 unsigned char channel; /* Satellite Frequency Channel Number | |
223 (GLONASS only) */ | |
224 double pseudorange; /* Pseudorange */ | |
225 double rangediff; /* PhaseRange – Pseudorange in meters */ | |
226 unsigned char locktime; /* Lock time Indicator */ | |
227 }; | |
228 | |
229 struct rtcm3_extended_rtk { | |
230 unsigned char indicator; /* Indicator */ | |
231 unsigned char channel; /* Satellite Frequency Channel Number | |
232 (GLONASS only) */ | |
233 double pseudorange; /* Pseudorange */ | |
234 double rangediff; /* PhaseRange – L1 Pseudorange */ | |
235 unsigned char locktime; /* Lock time Indicator */ | |
236 unsigned char ambiguity; /* Integer Pseudorange | |
237 Modulus Ambiguity */ | |
238 double CNR; /* Carrier-to-Noise Ratio */ | |
239 }; | |
240 | |
241 struct rtcm3_network_rtk_header { | |
242 unsigned int network_id; /* Network ID */ | |
243 unsigned int subnetwork_id; /* Subnetwork ID */ | |
244 time_t time; /* GPS Epoch Time (TOW) in ms */ | |
245 bool multimesg; /* GPS Multiple Message Indicator */ | |
246 unsigned master_id; /* Master Reference Station ID */ | |
247 unsigned aux_id; /* Auxilary Reference Station ID */ | |
248 unsigned char satcount; /* count of GPS satellites */ | |
249 }; | |
250 | |
251 struct rtcm3_correction_diff { | |
252 unsigned char ident; /* satellite ID */ | |
253 enum {reserved, correct, widelane, uncertain} ambiguity; | |
254 unsigned char nonsync; | |
255 double geometric_diff; /* Geometric Carrier Phase | |
256 Correction Difference (1016, 1017) */ | |
257 unsigned char iode; /* GPS IODE (1016, 1017) */ | |
258 double ionospheric_diff; /* Ionospheric Carrier Phase | |
259 Correction Difference (1015, 1017) */ | |
260 }; | |
261 | |
262 struct rtcm3_t { | |
263 /* header contents */ | |
264 unsigned type; /* RTCM 3.x message type */ | |
265 unsigned length; /* payload length, inclusive of checksum */ | |
266 | |
267 union { | |
268 /* 1001-1013 were present in the 3.0 version */ | |
269 struct { | |
270 struct rtcm3_rtk_hdr header; | |
271 struct { | |
272 unsigned ident; /* Satellite ID */ | |
273 struct rtcm3_basic_rtk L1; | |
274 } rtk_data[RTCM3_MAX_SATELLITES]; | |
275 } rtcm3_1001; | |
276 struct { | |
277 struct rtcm3_rtk_hdr header; | |
278 struct { | |
279 unsigned ident; /* Satellite ID */ | |
280 struct rtcm3_extended_rtk L1; | |
281 } rtk_data[RTCM3_MAX_SATELLITES]; | |
282 } rtcm3_1002; | |
283 struct { | |
284 struct rtcm3_rtk_hdr header; | |
285 struct { | |
286 unsigned ident; /* Satellite ID */ | |
287 struct rtcm3_basic_rtk L1; | |
288 struct rtcm3_basic_rtk L2; | |
289 } rtk_data[RTCM3_MAX_SATELLITES]; | |
290 } rtcm3_1003; | |
291 struct { | |
292 struct rtcm3_rtk_hdr header; | |
293 struct { | |
294 unsigned ident; /* Satellite ID */ | |
295 struct rtcm3_extended_rtk L1; | |
296 struct rtcm3_extended_rtk L2; | |
297 } rtk_data[RTCM3_MAX_SATELLITES]; | |
298 } rtcm3_1004; | |
299 struct { | |
300 unsigned int station_id; /* Reference Station ID */ | |
301 int system; /* Which system is it? */ | |
302 bool reference_station; /* Reference-station indicator *
/ | |
303 bool single_receiver; /* Single Receiver Oscillator */ | |
304 double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ | |
305 } rtcm3_1005; | |
306 struct { | |
307 unsigned int station_id; /* Reference Station ID */ | |
308 int system; /* Which system is it? */ | |
309 bool reference_station; /* Reference-station indicator *
/ | |
310 bool single_receiver; /* Single Receiver Oscillator */ | |
311 double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ | |
312 double height; /* Antenna height */ | |
313 } rtcm3_1006; | |
314 struct { | |
315 unsigned int station_id; /* Reference Station ID
*/ | |
316 char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ | |
317 unsigned char setup_id; | |
318 } rtcm3_1007; | |
319 struct { | |
320 unsigned int station_id; /* Reference Station ID
*/ | |
321 char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ | |
322 unsigned char setup_id; | |
323 char serial[RTCM3_MAX_DESCRIPTOR+1]; /* Serial # string */ | |
324 } rtcm3_1008; | |
325 struct { | |
326 struct rtcm3_rtk_hdr header; | |
327 struct { | |
328 unsigned ident; /* Satellite ID */ | |
329 struct rtcm3_basic_rtk L1; | |
330 } rtk_data[RTCM3_MAX_SATELLITES]; | |
331 } rtcm3_1009; | |
332 struct { | |
333 struct rtcm3_rtk_hdr header; | |
334 struct { | |
335 unsigned ident; /* Satellite ID */ | |
336 struct rtcm3_extended_rtk L1; | |
337 } rtk_data[RTCM3_MAX_SATELLITES]; | |
338 } rtcm3_1010; | |
339 struct { | |
340 struct rtcm3_rtk_hdr header; | |
341 struct { | |
342 unsigned ident; /* Satellite ID */ | |
343 struct rtcm3_extended_rtk L1; | |
344 struct rtcm3_extended_rtk L2; | |
345 } rtk_data[RTCM3_MAX_SATELLITES]; | |
346 } rtcm3_1011; | |
347 struct { | |
348 struct rtcm3_rtk_hdr header; | |
349 struct { | |
350 unsigned ident; /* Satellite ID */ | |
351 struct rtcm3_extended_rtk L1; | |
352 struct rtcm3_extended_rtk L2; | |
353 } rtk_data[RTCM3_MAX_SATELLITES]; | |
354 } rtcm3_1012; | |
355 struct { | |
356 unsigned int station_id; /* Reference Station ID */ | |
357 unsigned short mjd; /* Modified Julian Day (MJD) Number */ | |
358 unsigned int sod; /* Seconds of Day (UTC) */ | |
359 unsigned char leapsecs; /* Leap Seconds, GPS-UTC */ | |
360 unsigned char ncount; /* Count of announcements to follow */ | |
361 struct { | |
362 unsigned short id; | |
363 bool sync; | |
364 unsigned short interval; | |
365 } announcements[RTCM3_MAX_ANNOUNCEMENTS]; | |
366 } rtcm3_1013; | |
367 /* 1014-1017 were added in the 3.1 version */ | |
368 struct { | |
369 unsigned int network_id; /* Network ID */ | |
370 unsigned int subnetwork_id; /* Subnetwork ID */ | |
371 unsigned char stationcount; /* # auxiliary stations transmitted */ | |
372 unsigned int master_id; /* Master Reference Station ID */ | |
373 unsigned int aux_id; /* Auxilary Reference Station ID */ | |
374 double d_lat, d_lon, d_alt; /* Aux-master location delta */ | |
375 } rtcm3_1014; | |
376 struct { | |
377 struct rtcm3_network_rtk_header header; | |
378 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
379 } rtcm3_1015; | |
380 struct { | |
381 struct rtcm3_network_rtk_header header; | |
382 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
383 } rtcm3_1016; | |
384 struct { | |
385 struct rtcm3_network_rtk_header header; | |
386 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
387 } rtcm3_1017; | |
388 /* 1018-1029 were in the 3.0 version */ | |
389 struct { | |
390 unsigned int ident; /* Satellite ID */ | |
391 unsigned int week; /* GPS Week Number */ | |
392 unsigned char sv_accuracy; /* GPS SV ACCURACY */ | |
393 enum {reserved_code, p, ca, l2c} code; | |
394 double idot; | |
395 unsigned char iode; | |
396 /* ephemeris fields, not scaled */ | |
397 unsigned int t_sub_oc; | |
398 signed int a_sub_f2; | |
399 signed int a_sub_f1; | |
400 signed int a_sub_f0; | |
401 unsigned int iodc; | |
402 signed int C_sub_rs; | |
403 signed int delta_sub_n; | |
404 signed int M_sub_0; | |
405 signed int C_sub_uc; | |
406 unsigned int e; | |
407 signed int C_sub_us; | |
408 unsigned int sqrt_sub_A; | |
409 unsigned int t_sub_oe; | |
410 signed int C_sub_ic; | |
411 signed int OMEGA_sub_0; | |
412 signed int C_sub_is; | |
413 signed int i_sub_0; | |
414 signed int C_sub_rc; | |
415 signed int argument_of_perigee; | |
416 signed int omegadot; | |
417 signed int t_sub_GD; | |
418 unsigned char sv_health; | |
419 bool p_data; | |
420 bool fit_interval; | |
421 } rtcm3_1019; | |
422 struct { | |
423 unsigned int ident; /* Satellite ID */ | |
424 unsigned short channel; /* Satellite Frequency Channel Number */ | |
425 /* ephemeris fields, not scaled */ | |
426 bool C_sub_n; | |
427 bool health_avAilability_indicator; | |
428 unsigned char P1; | |
429 unsigned short t_sub_k; | |
430 bool msb_of_B_sub_n; | |
431 bool P2; | |
432 bool t_sub_b; | |
433 signed int x_sub_n_t_of_t_sub_b_prime; | |
434 signed int x_sub_n_t_of_t_sub_b; | |
435 signed int x_sub_n_t_of_t_sub_b_prime_prime; | |
436 signed int y_sub_n_t_of_t_sub_b_prime; | |
437 signed int y_sub_n_t_of_t_sub_b; | |
438 signed int y_sub_n_t_of_t_sub_b_prime_prime; | |
439 signed int z_sub_n_t_of_t_sub_b_prime; | |
440 signed int z_sub_n_t_of_t_sub_b; | |
441 signed int z_sub_n_t_of_t_sub_b_prime_prime; | |
442 bool P3; | |
443 signed int gamma_sub_n_of_t_sub_b; | |
444 unsigned char MP; | |
445 bool Ml_n; | |
446 signed int tau_n_of_t_sub_b; | |
447 signed int M_delta_tau_sub_n; | |
448 unsigned int E_sub_n; | |
449 bool MP4; | |
450 unsigned char MF_sub_T; | |
451 unsigned char MN_sub_T; | |
452 unsigned char MM; | |
453 bool additioinal_data_availability; | |
454 unsigned int N_sup_A; | |
455 unsigned int tau_sub_c; | |
456 unsigned int M_N_sub_4; | |
457 signed int M_tau_sub_GPS; | |
458 bool M_l_sub_n; | |
459 } rtcm3_1020; | |
460 struct { | |
461 unsigned int station_id; /* Reference Station ID */ | |
462 unsigned short mjd; /* Modified Julian Day (MJD) Number */ | |
463 unsigned int sod; /* Seconds of Day (UTC) */ | |
464 unsigned char len; /* # Chars to follow */ | |
465 unsigned char unicode_units; | |
466 unsigned char text[128]; | |
467 } rtcm3_1029; | |
468 } rtcmtypes; | |
469 }; | |
470 | |
471 typedef /*@unsignedintegraltype@*/ unsigned int gps_mask_t; | |
472 | |
473 /* | |
474 * Is an MMSI number that of an auxiliary associated with a mother ship? | |
475 * We need to be able to test this for decoding AIS Type 24 messages. | |
476 * According to <http://www.navcen.uscg.gov/marcomms/gmdss/mmsi.htm#format>, | |
477 * auxiliary-craft MMSIs have the form 98MIDXXXX, where MID is a country | |
478 * code and XXXX the vessel ID. | |
479 */ | |
480 #define AIS_AUXILIARY_MMSI(n) ((n) / 10000000 == 98) | |
481 | |
482 struct ais_t | |
483 { | |
484 unsigned int type; /* message type */ | |
485 unsigned int repeat; /* Repeat indicator */ | |
486 unsigned int mmsi; /* MMSI */ | |
487 union { | |
488 /* Types 1-3 Common navigation info */ | |
489 struct { | |
490 unsigned int status; /* navigation status */ | |
491 signed turn; /* rate of turn */ | |
492 #define AIS_TURN_HARD_LEFT -127 | |
493 #define AIS_TURN_HARD_RIGHT 127 | |
494 #define AIS_TURN_NOT_AVAILABLE 128 | |
495 unsigned int speed; /* speed over ground in deciknot
s */ | |
496 #define AIS_SPEED_NOT_AVAILABLE 1023 | |
497 #define AIS_SPEED_FAST_MOVER 1022 /* >= 102.2 knots */ | |
498 bool accuracy; /* position accuracy */ | |
499 #define AIS_LATLON_SCALE 600000.0 | |
500 int lon; /* longitude */ | |
501 #define AIS_LON_NOT_AVAILABLE 0x6791AC0 | |
502 int lat; /* latitude */ | |
503 #define AIS_LAT_NOT_AVAILABLE 0x3412140 | |
504 unsigned int course; /* course over ground */ | |
505 #define AIS_COURSE_NOT_AVAILABLE 3600 | |
506 unsigned int heading; /* true heading */ | |
507 #define AIS_HEADING_NOT_AVAILABLE 511 | |
508 unsigned int second; /* seconds of UTC timestamp */ | |
509 #define AIS_SEC_NOT_AVAILABLE 60 | |
510 #define AIS_SEC_MANUAL 61 | |
511 #define AIS_SEC_ESTIMATED 62 | |
512 #define AIS_SEC_INOPERATIVE 63 | |
513 unsigned int maneuver; /* maneuver indicator */ | |
514 //unsigned int spare; spare bits */ | |
515 bool raim; /* RAIM flag */ | |
516 unsigned int radio; /* radio status bits */ | |
517 } type1; | |
518 /* Type 4 - Base Station Report & Type 11 - UTC and Date Response */ | |
519 struct { | |
520 unsigned int year; /* UTC year */ | |
521 #define AIS_YEAR_NOT_AVAILABLE 0 | |
522 unsigned int month; /* UTC month */ | |
523 #define AIS_MONTH_NOT_AVAILABLE 0 | |
524 unsigned int day; /* UTC day */ | |
525 #define AIS_DAY_NOT_AVAILABLE 0 | |
526 unsigned int hour; /* UTC hour */ | |
527 #define AIS_HOUR_NOT_AVAILABLE 24 | |
528 unsigned int minute; /* UTC minute */ | |
529 #define AIS_MINUTE_NOT_AVAILABLE 60 | |
530 unsigned int second; /* UTC second */ | |
531 #define AIS_SECOND_NOT_AVAILABLE 60 | |
532 bool accuracy; /* fix quality */ | |
533 int lon; /* longitude */ | |
534 int lat; /* latitude */ | |
535 unsigned int epfd; /* type of position fix device */ | |
536 //unsigned int spare; spare bits */ | |
537 bool raim; /* RAIM flag */ | |
538 unsigned int radio; /* radio status bits */ | |
539 } type4; | |
540 /* Type 5 - Ship static and voyage related data */ | |
541 struct { | |
542 unsigned int ais_version; /* AIS version level */ | |
543 unsigned int imo; /* IMO identification */ | |
544 char callsign[8]; /* callsign */ | |
545 #define AIS_SHIPNAME_MAXLEN 20 | |
546 char shipname[AIS_SHIPNAME_MAXLEN+1]; /* vessel name */ | |
547 unsigned int shiptype; /* ship type code */ | |
548 unsigned int to_bow; /* dimension to bow */ | |
549 unsigned int to_stern; /* dimension to stern */ | |
550 unsigned int to_port; /* dimension to port */ | |
551 unsigned int to_starboard; /* dimension to starboard */ | |
552 unsigned int epfd; /* type of position fix deviuce */ | |
553 unsigned int month; /* UTC month */ | |
554 unsigned int day; /* UTC day */ | |
555 unsigned int hour; /* UTC hour */ | |
556 unsigned int minute; /* UTC minute */ | |
557 unsigned int draught; /* draft in meters */ | |
558 char destination[21]; /* ship destination */ | |
559 unsigned int dte; /* data terminal enable */ | |
560 //unsigned int spare; spare bits */ | |
561 } type5; | |
562 /* Type 6 - Addressed Binary Message */ | |
563 struct { | |
564 unsigned int seqno; /* sequence number */ | |
565 unsigned int dest_mmsi; /* destination MMSI */ | |
566 bool retransmit; /* retransmit flag */ | |
567 //unsigned int spare; spare bit(s) */ | |
568 unsigned int app_id; /* Application ID */ | |
569 #define AIS_TYPE6_BINARY_MAX 920 /* 920 bits */ | |
570 size_t bitcount; /* bit count of the data */ | |
571 char bitdata[(AIS_TYPE6_BINARY_MAX + 7) / 8]; | |
572 } type6; | |
573 /* Type 7 - Binary Acknowledge */ | |
574 struct { | |
575 unsigned int mmsi1; | |
576 unsigned int mmsi2; | |
577 unsigned int mmsi3; | |
578 unsigned int mmsi4; | |
579 /* spares ignored, they're only padding here */ | |
580 } type7; | |
581 /* Type 8 - Broadcast Binary Message */ | |
582 struct { | |
583 //unsigned int spare; spare bit(s) */ | |
584 unsigned int app_id; /* Application ID */ | |
585 #define AIS_TYPE8_BINARY_MAX 952 /* 952 bits */ | |
586 size_t bitcount; /* bit count of the data */ | |
587 char bitdata[(AIS_TYPE8_BINARY_MAX + 7) / 8]; | |
588 } type8; | |
589 /* Type 9 - Standard SAR Aircraft Position Report */ | |
590 struct { | |
591 unsigned int alt; /* altitude in meters */ | |
592 #define AIS_ALT_NOT_AVAILABLE 4095 | |
593 #define AIS_ALT_HIGH 4094 /* 4094 meters or higher */ | |
594 unsigned int speed; /* speed over ground in deciknots */ | |
595 #define AIS_SAR_SPEED_NOT_AVAILABLE 1023 | |
596 #define AIS_SAR_FAST_MOVER 1022 | |
597 bool accuracy; /* position accuracy */ | |
598 int lon; /* longitude */ | |
599 int lat; /* latitude */ | |
600 unsigned int course; /* course over ground */ | |
601 unsigned int second; /* seconds of UTC timestamp */ | |
602 unsigned int regional; /* regional reserved */ | |
603 unsigned int dte; /* data terminal enable */ | |
604 //unsigned int spare; spare bits */ | |
605 bool assigned; /* assigned-mode flag */ | |
606 bool raim; /* RAIM flag */ | |
607 unsigned int radio; /* radio status bits */ | |
608 } type9; | |
609 /* Type 10 - UTC/Date Inquiry */ | |
610 struct { | |
611 //unsigned int spare; | |
612 unsigned int dest_mmsi; /* destination MMSI */ | |
613 //unsigned int spare2; | |
614 } type10; | |
615 /* Type 12 - Safety-Related Message */ | |
616 struct { | |
617 unsigned int seqno; /* sequence number */ | |
618 unsigned int dest_mmsi; /* destination MMSI */ | |
619 bool retransmit; /* retransmit flag */ | |
620 //unsigned int spare; spare bit(s) */ | |
621 #define AIS_TYPE12_TEXT_MAX 157 /* 936 bits of six-bit, plus NUL */ | |
622 char text[AIS_TYPE12_TEXT_MAX]; | |
623 } type12; | |
624 /* Type 14 - Safety-Related Broadcast Message */ | |
625 struct { | |
626 //unsigned int spare; spare bit(s) */ | |
627 #define AIS_TYPE14_TEXT_MAX 161 /* 952 bits of six-bit, plus NUL */ | |
628 char text[AIS_TYPE14_TEXT_MAX]; | |
629 } type14; | |
630 /* Type 15 - Interrogation */ | |
631 struct { | |
632 //unsigned int spare; spare bit(s) */ | |
633 unsigned int mmsi1; | |
634 unsigned int type1_1; | |
635 unsigned int offset1_1; | |
636 //unsigned int spare2; spare bit(s) */ | |
637 unsigned int type1_2; | |
638 unsigned int offset1_2; | |
639 //unsigned int spare3; spare bit(s) */ | |
640 unsigned int mmsi2; | |
641 unsigned int type2_1; | |
642 unsigned int offset2_1; | |
643 //unsigned int spare4; spare bit(s) */ | |
644 } type15; | |
645 /* Type 16 - Assigned Mode Command */ | |
646 struct { | |
647 //unsigned int spare; spare bit(s) */ | |
648 unsigned int mmsi1; | |
649 unsigned int offset1; | |
650 unsigned int increment1; | |
651 unsigned int mmsi2; | |
652 unsigned int offset2; | |
653 unsigned int increment2; | |
654 } type16; | |
655 /* Type 17 - GNSS Broadcast Binary Message */ | |
656 struct { | |
657 //unsigned int spare; spare bit(s) */ | |
658 #define AIS_GNSS_LATLON_SCALE 600.0 | |
659 int lon; /* longitude */ | |
660 int lat; /* latitude */ | |
661 //unsigned int spare2; spare bit(s) */ | |
662 #define AIS_TYPE17_BINARY_MAX 736 /* 920 bits */ | |
663 size_t bitcount; /* bit count of the data */ | |
664 char bitdata[(AIS_TYPE17_BINARY_MAX + 7) / 8]; | |
665 } type17; | |
666 /* Type 18 - Standard Class B CS Position Report */ | |
667 struct { | |
668 unsigned int reserved; /* altitude in meters */ | |
669 unsigned int speed; /* speed over ground in deciknots */ | |
670 bool accuracy; /* position accuracy */ | |
671 int lon; /* longitude */ | |
672 #define AIS_GNS_LON_NOT_AVAILABLE 0x1a838 | |
673 int lat; /* latitude */ | |
674 #define AIS_GNS_LAT_NOT_AVAILABLE 0xd548 | |
675 unsigned int course; /* course over ground */ | |
676 unsigned int heading; /* true heading */ | |
677 unsigned int second; /* seconds of UTC timestamp */ | |
678 unsigned int regional; /* regional reserved */ | |
679 bool cs; /* carrier sense unit flag */ | |
680 bool display; /* unit has attached display? */ | |
681 bool dsc; /* unit attached to radio with DSC? */ | |
682 bool band; /* unit can switch frequency bands? */ | |
683 bool msg22; /* can accept Message 22 management? */ | |
684 bool assigned; /* assigned-mode flag */ | |
685 bool raim; /* RAIM flag */ | |
686 unsigned int radio; /* radio status bits */ | |
687 } type18; | |
688 /* Type 19 - Extended Class B CS Position Report */ | |
689 struct { | |
690 unsigned int reserved; /* altitude in meters */ | |
691 unsigned int speed; /* speed over ground in deciknots */ | |
692 bool accuracy; /* position accuracy */ | |
693 int lon; /* longitude */ | |
694 int lat; /* latitude */ | |
695 unsigned int course; /* course over ground */ | |
696 unsigned int heading; /* true heading */ | |
697 unsigned int second; /* seconds of UTC timestamp */ | |
698 unsigned int regional; /* regional reserved */ | |
699 char shipname[AIS_SHIPNAME_MAXLEN+1]; /* ship name */ | |
700 unsigned int shiptype; /* ship type code */ | |
701 unsigned int to_bow; /* dimension to bow */ | |
702 unsigned int to_stern; /* dimension to stern */ | |
703 unsigned int to_port; /* dimension to port */ | |
704 unsigned int to_starboard; /* dimension to starboard */ | |
705 unsigned int epfd; /* type of position fix deviuce */ | |
706 bool raim; /* RAIM flag */ | |
707 unsigned int dte; /* date terminal enable */ | |
708 bool assigned; /* assigned-mode flag */ | |
709 //unsigned int spare; spare bits */ | |
710 } type19; | |
711 /* Type 20 - Data Link Management Message */ | |
712 struct { | |
713 //unsigned int spare; spare bit(s) */ | |
714 unsigned int offset1; /* TDMA slot offset */ | |
715 unsigned int number1; /* number of xlots to allocate */ | |
716 unsigned int timeout1; /* allocation timeout */ | |
717 unsigned int increment1; /* repeat increment */ | |
718 unsigned int offset2; /* TDMA slot offset */ | |
719 unsigned int number2; /* number of xlots to allocate */ | |
720 unsigned int timeout2; /* allocation timeout */ | |
721 unsigned int increment2; /* repeat increment */ | |
722 unsigned int offset3; /* TDMA slot offset */ | |
723 unsigned int number3; /* number of xlots to allocate */ | |
724 unsigned int timeout3; /* allocation timeout */ | |
725 unsigned int increment3; /* repeat increment */ | |
726 unsigned int offset4; /* TDMA slot offset */ | |
727 unsigned int number4; /* number of xlots to allocate */ | |
728 unsigned int timeout4; /* allocation timeout */ | |
729 unsigned int increment4; /* repeat increment */ | |
730 } type20; | |
731 /* Type 21 - Aids to Navigation Report */ | |
732 struct { | |
733 unsigned int aid_type; /* aid type */ | |
734 char name[35]; /* name of aid to navigation */ | |
735 bool accuracy; /* position accuracy */ | |
736 int lon; /* longitude */ | |
737 int lat; /* latitude */ | |
738 unsigned int to_bow; /* dimension to bow */ | |
739 unsigned int to_stern; /* dimension to stern */ | |
740 unsigned int to_port; /* dimension to port */ | |
741 unsigned int to_starboard; /* dimension to starboard */ | |
742 unsigned int epfd; /* type of EPFD */ | |
743 unsigned int second; /* second of UTC timestamp */ | |
744 bool off_position; /* off-position indicator */ | |
745 unsigned int regional; /* regional reserved field */ | |
746 bool raim; /* RAIM flag */ | |
747 bool virtual_aid; /* is virtual station? */ | |
748 bool assigned; /* assigned-mode flag */ | |
749 //unsigned int spare; unused */ | |
750 } type21; | |
751 /* Type 22 - Channel Management */ | |
752 struct { | |
753 //unsigned int spare; spare bit(s) */ | |
754 unsigned int channel_a; /* Channel A number */ | |
755 unsigned int channel_b; /* Channel B number */ | |
756 unsigned int txrx; /* transmit/receive mode */ | |
757 bool power; /* high-power flag */ | |
758 #define AIS_CHANNEL_LATLON_SCALE 600.0 | |
759 union { | |
760 struct { | |
761 int ne_lon; /* NE corner longitude */ | |
762 int ne_lat; /* NE corner latitude */ | |
763 int sw_lon; /* SW corner longitude */ | |
764 int sw_lat; /* SW corner latitude */ | |
765 } area; | |
766 struct { | |
767 unsigned int dest1; /* addressed station MMSI 1 */ | |
768 unsigned int dest2; /* addressed station MMSI 2 */ | |
769 } mmsi; | |
770 }; | |
771 bool addressed; /* addressed vs. broadast flag */ | |
772 bool band_a; /* fix 1.5kHz band for channel A */ | |
773 bool band_b; /* fix 1.5kHz band for channel B */ | |
774 unsigned int zonesize; /* size of transitional zone */ | |
775 } type22; | |
776 /* Type 23 - Group Assignment Command */ | |
777 struct { | |
778 int ne_lon; /* NE corner longitude */ | |
779 int ne_lat; /* NE corner latitude */ | |
780 int sw_lon; /* SW corner longitude */ | |
781 int sw_lat; /* SW corner latitude */ | |
782 //unsigned int spare; spare bit(s) */ | |
783 unsigned int stationtype; /* station type code */ | |
784 unsigned int shiptype; /* ship type code */ | |
785 //unsigned int spare2; spare bit(s) */ | |
786 unsigned int txrx; /* transmit-enable code */ | |
787 unsigned int interval; /* report interval */ | |
788 unsigned int quiet; /* quiet time */ | |
789 //unsigned int spare3; spare bit(s) */ | |
790 } type23; | |
791 /* Type 24 - Class B CS Static Data Report */ | |
792 struct { | |
793 char shipname[AIS_SHIPNAME_MAXLEN+1]; /* vessel name */ | |
794 unsigned int shiptype; /* ship type code */ | |
795 char vendorid[8]; /* vendor ID */ | |
796 char callsign[8]; /* callsign */ | |
797 union { | |
798 unsigned int mothership_mmsi; /* MMSI of main vessel */ | |
799 struct { | |
800 unsigned int to_bow; /* dimension to bow */ | |
801 unsigned int to_stern; /* dimension to stern */ | |
802 unsigned int to_port; /* dimension to port */ | |
803 unsigned int to_starboard; /* dimension to starboard */ | |
804 } dim; | |
805 }; | |
806 } type24; | |
807 /* Type 25 - Addressed Binary Message */ | |
808 struct { | |
809 bool addressed; /* addressed-vs.broadcast flag */ | |
810 bool structured; /* structured-binary flag */ | |
811 unsigned int dest_mmsi; /* destination MMSI */ | |
812 unsigned int app_id; /* Application ID */ | |
813 #define AIS_TYPE25_BINARY_MAX 128 /* Up to 128 bits */ | |
814 size_t bitcount; /* bit count of the data */ | |
815 char bitdata[(AIS_TYPE25_BINARY_MAX + 7) / 8]; | |
816 } type25; | |
817 /* Type 26 - Addressed Binary Message */ | |
818 struct { | |
819 bool addressed; /* addressed-vs.broadcast flag */ | |
820 bool structured; /* structured-binary flag */ | |
821 unsigned int dest_mmsi; /* destination MMSI */ | |
822 unsigned int app_id; /* Application ID */ | |
823 #define AIS_TYPE26_BINARY_MAX 1004 /* Up to 128 bits */ | |
824 size_t bitcount; /* bit count of the data */ | |
825 char bitdata[(AIS_TYPE26_BINARY_MAX + 7) / 8]; | |
826 unsigned int radio; /* radio status bits */ | |
827 } type26; | |
828 }; | |
829 }; | |
830 | |
831 struct attitude_t { | |
832 double heading; | |
833 double pitch; | |
834 double roll; | |
835 double yaw; | |
836 double dip; | |
837 double mag_len; /* unitvector sqrt(x^2 + y^2 +z^2) */ | |
838 double mag_x; | |
839 double mag_y; | |
840 double mag_z; | |
841 double acc_len; /* unitvector sqrt(x^2 + y^2 +z^2) */ | |
842 double acc_x; | |
843 double acc_y; | |
844 double acc_z; | |
845 double gyro_x; | |
846 double gyro_y; | |
847 double temp; | |
848 double depth; | |
849 /* compass status -- TrueNorth (and any similar) devices only */ | |
850 char mag_st; | |
851 char pitch_st; | |
852 char roll_st; | |
853 char yaw_st; | |
854 }; | |
855 | |
856 struct dop_t { | |
857 /* Dilution of precision factors */ | |
858 double xdop, ydop, pdop, hdop, vdop, tdop, gdop; | |
859 }; | |
860 | |
861 struct rawdata_t { | |
862 /* raw measurement data */ | |
863 double codephase[MAXCHANNELS]; /* meters */ | |
864 double carrierphase[MAXCHANNELS]; /* meters */ | |
865 double pseudorange[MAXCHANNELS]; /* meters */ | |
866 double deltarange[MAXCHANNELS]; /* meters/sec */ | |
867 double doppler[MAXCHANNELS]; /* Hz */ | |
868 double mtime[MAXCHANNELS]; /* sec */ | |
869 unsigned satstat[MAXCHANNELS]; /* tracking status */ | |
870 #define SAT_ACQUIRED 0x01 /* satellite acquired */ | |
871 #define SAT_CODE_TRACK 0x02 /* code-tracking loop acquired */ | |
872 #define SAT_CARR_TRACK 0x04 /* carrier-tracking loop acquired */ | |
873 #define SAT_DATA_SYNC 0x08 /* data-bit synchronization done */ | |
874 #define SAT_FRAME_SYNC 0x10 /* frame synchronization done */ | |
875 #define SAT_EPHEMERIS 0x20 /* ephemeris collected */ | |
876 #define SAT_FIX_USED 0x40 /* used for position fix */ | |
877 }; | |
878 | |
879 struct version_t { | |
880 char release[64]; /* external version */ | |
881 char rev[64]; /* internal revision ID */ | |
882 int proto_major, proto_minor; /* API major and minor versions */ | |
883 }; | |
884 | |
885 struct devconfig_t { | |
886 char path[GPS_PATH_MAX]; | |
887 int flags; | |
888 #define SEEN_GPS 0x01 | |
889 #define SEEN_RTCM2 0x02 | |
890 #define SEEN_RTCM3 0x04 | |
891 #define SEEN_AIS 0x08 | |
892 char driver[64]; | |
893 char subtype[64]; | |
894 double activated; | |
895 unsigned int baudrate, stopbits; /* RS232 link parameters */ | |
896 char parity; /* 'N', 'O', or 'E' */ | |
897 double cycle, mincycle; /* refresh cycle time in seconds */ | |
898 int driver_mode; /* is driver in native mode or not? */ | |
899 }; | |
900 | |
901 struct policy_t { | |
902 bool watcher; /* is watcher mode on? */ | |
903 bool json; /* requesting JSON? */ | |
904 bool nmea; /* requesting dumping as NMEA? */ | |
905 int raw; /* requesting raw data? */ | |
906 bool scaled; /* requesting report scaling? */ | |
907 bool timing; /* requesting timing info */ | |
908 char devpath[GPS_PATH_MAX]; /* specific device to watch */ | |
909 }; | |
910 | |
911 /* | |
912 * Someday we may support Windows, under which socket_t is a separate type. | |
913 * In the meantime, having a typedef for this semantic kind is no bad thing, | |
914 * as it makes clearer what some declarations are doing without breaking | |
915 * binary compatibility. | |
916 */ | |
917 typedef int socket_t; | |
918 | |
919 /* mode flags for setting streaming policy */ | |
920 #define WATCH_ENABLE 0x0001u /* enable streaming */ | |
921 #define WATCH_JSON 0x0002u /* enable JSON output */ | |
922 #define WATCH_NMEA 0x0004u /* enable output in NMEA */ | |
923 #define WATCH_RARE 0x0008u /* enable output of packets in hex */ | |
924 #define WATCH_RAW 0x0010u /* enable output of raw packets */ | |
925 #define WATCH_SCALED 0x0020u /* scale output to floats, when applicable */ | |
926 #define WATCH_NEWSTYLE 0x0040u /* force JSON streaming */ | |
927 #define WATCH_OLDSTYLE 0x0080u /* force old-style streaming */ | |
928 #define WATCH_DEVICE 0x0100u /* watch specific device */ | |
929 #define WATCH_DISABLE 0x0200u /* disable watching */ | |
930 #define POLL_NONBLOCK 0x1000u /* set non-blocking poll (experimental!) */ | |
931 | |
932 /* | |
933 * Main structure that includes all previous substructures | |
934 */ | |
935 | |
936 struct gps_data_t { | |
937 gps_mask_t set; /* has field been set since this was last cleared? */ | |
938 #define ONLINE_SET 0x00000001u | |
939 #define TIME_SET 0x00000002u | |
940 #define TIMERR_SET 0x00000004u | |
941 #define LATLON_SET 0x00000008u | |
942 #define ALTITUDE_SET 0x00000010u | |
943 #define SPEED_SET 0x00000020u | |
944 #define TRACK_SET 0x00000040u | |
945 #define CLIMB_SET 0x00000080u | |
946 #define STATUS_SET 0x00000100u | |
947 #define MODE_SET 0x00000200u | |
948 #define DOP_SET 0x00000400u | |
949 #define VERSION_SET 0x00000800u | |
950 #define HERR_SET 0x00001000u | |
951 #define VERR_SET 0x00002000u | |
952 #define ATTITUDE_SET 0x00004000u | |
953 #define POLICY_SET 0x00008000u | |
954 #define SATELLITE_SET 0x00010000u | |
955 #define RAW_SET 0x00020000u | |
956 #define USED_SET 0x00040000u | |
957 #define SPEEDERR_SET 0x00080000u | |
958 #define TRACKERR_SET 0x00100000u | |
959 #define CLIMBERR_SET 0x00200000u | |
960 #define DEVICE_SET 0x00400000u | |
961 #define DEVICELIST_SET 0x00800000u | |
962 #define DEVICEID_SET 0x01000000u | |
963 #define ERROR_SET 0x02000000u | |
964 #define RTCM2_SET 0x04000000u | |
965 #define RTCM3_SET 0x08000000u | |
966 #define AIS_SET 0x10000000u | |
967 #define PACKET_SET 0x20000000u | |
968 #define AUXDATA_SET 0x80000000u /* reserved */ | |
969 double online; /* NZ if GPS is on line, 0 if not. | |
970 * | |
971 * Note: gpsd clears this time when sentences | |
972 * fail to show up within the GPS's normal | |
973 * send cycle time. If the host-to-GPS | |
974 * link is lossy enough to drop entire | |
975 * sentences, this field will be | |
976 * prone to false zero values. | |
977 */ | |
978 | |
979 #ifndef USE_QT | |
980 socket_t gps_fd; /* socket or file descriptor to GPS */ | |
981 #else | |
982 void* gps_fd; | |
983 #endif | |
984 struct gps_fix_t fix; /* accumulated PVT data */ | |
985 | |
986 double separation; /* Geoidal separation, MSL - WGS84 (Meters) */ | |
987 | |
988 /* GPS status -- always valid */ | |
989 int status; /* Do we have a fix? */ | |
990 #define STATUS_NO_FIX 0 /* no */ | |
991 #define STATUS_FIX 1 /* yes, without DGPS */ | |
992 #define STATUS_DGPS_FIX 2 /* yes, with DGPS */ | |
993 | |
994 /* precision of fix -- valid if satellites_used > 0 */ | |
995 int satellites_used; /* Number of satellites used in solution */ | |
996 int used[MAXCHANNELS]; /* PRNs of satellites used in solution */ | |
997 struct dop_t dop; | |
998 | |
999 /* redundant with the estimate elements in the fix structure */ | |
1000 double epe; /* spherical position error, 95% confidence (meters) */ | |
1001 | |
1002 /* satellite status -- valid when satellites_visible > 0 */ | |
1003 double skyview_time; /* skyview timestamp */ | |
1004 int satellites_visible; /* # of satellites in view */ | |
1005 int PRN[MAXCHANNELS]; /* PRNs of satellite */ | |
1006 int elevation[MAXCHANNELS]; /* elevation of satellite */ | |
1007 int azimuth[MAXCHANNELS]; /* azimuth */ | |
1008 double ss[MAXCHANNELS]; /* signal-to-noise ratio (dB) */ | |
1009 | |
1010 struct devconfig_t dev; /* device that shipped last update */ | |
1011 | |
1012 struct policy_t policy; /* our listening policy */ | |
1013 | |
1014 char tag[MAXTAGLEN+1]; /* tag of last sentence processed */ | |
1015 | |
1016 void (*raw_hook)(struct gps_data_t *, char *, size_t len); /* Raw-mode hook
for GPS data. */ | |
1017 | |
1018 /* pack things never reported together to reduce structure size */ | |
1019 #define UNION_SET (RTCM2_SET|RTCM3_SET|AIS_SET|VERSION_SET|DEVICELIST_SET|
ERROR_SET) | |
1020 union { | |
1021 /* unusual forms of sensor data that might come up the pipe */ | |
1022 struct rtcm2_t rtcm2; | |
1023 struct rtcm3_t rtcm3; | |
1024 struct ais_t ais; | |
1025 struct attitude_t attitude; | |
1026 struct rawdata_t raw; | |
1027 /* "artificial" structures for various protocol responses */ | |
1028 struct version_t version; | |
1029 struct { | |
1030 double time; | |
1031 int ndevices; | |
1032 struct devconfig_t list[MAXUSERDEVS]; | |
1033 } devices; | |
1034 char error[80]; | |
1035 }; | |
1036 | |
1037 /* Private data - client code must not set this */ | |
1038 void *privdata; | |
1039 }; | |
1040 | |
1041 extern int gps_open_r(const char *host, const char *, | |
1042 /*@out@*/struct gps_data_t *); | |
1043 extern /*@null@*/struct gps_data_t *gps_open(const char *, const char *); | |
1044 extern int gps_close(struct gps_data_t *); | |
1045 extern int gps_send(struct gps_data_t *, const char *, ... ); | |
1046 extern int gps_poll(struct gps_data_t *); | |
1047 extern bool gps_waiting(struct gps_data_t *); | |
1048 extern int gps_stream(struct gps_data_t *, unsigned int, /*@null@*/void *); | |
1049 extern void gps_set_raw_hook(struct gps_data_t *, | |
1050 void (*)(struct gps_data_t *, char *, size_t)); | |
1051 extern char /*@observer@*/ *gps_errstr(const int); | |
1052 | |
1053 /* this only needs to be visible for the unit tests */ | |
1054 extern int gps_unpack(char *, struct gps_data_t *); | |
1055 | |
1056 /* dependencies on struct gpsdata_t end hrere */ | |
1057 | |
1058 extern void gps_clear_fix(/*@ out @*/struct gps_fix_t *); | |
1059 extern void gps_merge_fix(/*@ out @*/struct gps_fix_t *, | |
1060 gps_mask_t, | |
1061 /*@ in @*/struct gps_fix_t *); | |
1062 extern void gps_enable_debug(int, FILE *); | |
1063 extern /*@observer@*/const char *gps_maskdump(gps_mask_t); | |
1064 | |
1065 extern time_t mkgmtime(register struct tm *); | |
1066 extern double timestamp(void); | |
1067 extern double iso8601_to_unix(char *); | |
1068 extern /*@observer@*/char *unix_to_iso8601(double t, /*@ out @*/char[], size_t l
en); | |
1069 extern double gpstime_to_unix(int, double); | |
1070 extern void unix_to_gpstime(double, /*@out@*/int *, /*@out@*/double *); | |
1071 extern double earth_distance(double, double, double, double); | |
1072 extern double wgs84_separation(double, double); | |
1073 | |
1074 /* some multipliers for interpreting GPS output */ | |
1075 #define METERS_TO_FEET 3.2808399 /* Meters to U.S./British feet */ | |
1076 #define METERS_TO_MILES 0.00062137119 /* Meters to miles */ | |
1077 #define KNOTS_TO_MPH 1.1507794 /* Knots to miles per hour */ | |
1078 #define KNOTS_TO_KPH 1.852 /* Knots to kilometers per hour */ | |
1079 #define KNOTS_TO_MPS 0.51444444 /* Knots to meters per second */ | |
1080 #define MPS_TO_KPH 3.6 /* Meters per second to klicks/hr */ | |
1081 #define MPS_TO_MPH 2.2369363 /* Meters/second to miles per hour */ | |
1082 #define MPS_TO_KNOTS 1.9438445 /* Meters per second to knots */ | |
1083 /* miles and knots are both the international standard versions of the units */ | |
1084 | |
1085 /* angle conversion multipliers */ | |
1086 #define GPS_PI 3.1415926535897932384626433832795029 | |
1087 #define RAD_2_DEG 57.2957795130823208767981548141051703 | |
1088 #define DEG_2_RAD 0.0174532925199432957692369076848861271 | |
1089 | |
1090 /* geodetic constants */ | |
1091 #define WGS84A 6378137 /* equatorial radius */ | |
1092 #define WGS84F 298.257223563 /* flattening */ | |
1093 #define WGS84B 6356752.3142 /* polar radius */ | |
1094 | |
1095 /* gps_open() errno return values */ | |
1096 #define NL_NOSERVICE -1 /* can't get service entry */ | |
1097 #define NL_NOHOST -2 /* can't get host entry */ | |
1098 #define NL_NOPROTO -3 /* can't get protocol entry */ | |
1099 #define NL_NOSOCK -4 /* can't create socket */ | |
1100 #define NL_NOSOCKOPT -5 /* error SETSOCKOPT SO_REUSEADDR */ | |
1101 #define NL_NOCONNECT -6 /* can't connect to host/socket pair */ | |
1102 | |
1103 #define DEFAULT_GPSD_PORT "2947" /* IANA assignment */ | |
1104 #define DEFAULT_RTCM_PORT "2101" /* IANA assignment */ | |
1105 | |
1106 #ifdef __cplusplus | |
1107 } /* End of the 'extern "C"' block */ | |
1108 #endif | |
1109 | |
1110 /* gps.h ends here */ | |
1111 #endif /* _GPSD_GPS_H_ */ | |
OLD | NEW |