| OLD | NEW |
| (Empty) |
| 1 /* gps.h -- interface of the libgps library */ | |
| 2 /* | |
| 3 * This file is Copyright (c) 2010 by the GPSD project | |
| 4 * BSD terms apply: see the file COPYING in the distribution root for details. | |
| 5 */ | |
| 6 #ifndef _GPSD_GPS_H_ | |
| 7 #define _GPSD_GPS_H_ | |
| 8 | |
| 9 #ifdef __cplusplus | |
| 10 extern "C" { | |
| 11 #endif | |
| 12 | |
| 13 /* Macro for declaring function arguments unused. */ | |
| 14 #if defined(__GNUC__) | |
| 15 # define UNUSED __attribute__((unused)) /* Flag variable as unused */ | |
| 16 #else /* not __GNUC__ */ | |
| 17 # define UNUSED | |
| 18 #endif | |
| 19 | |
| 20 | |
| 21 #include <sys/types.h> | |
| 22 #include <sys/time.h> | |
| 23 #include <stdbool.h> | |
| 24 #include <inttypes.h> /* stdint.h would be smaller but not all have it */ | |
| 25 #include <limits.h> | |
| 26 #include <time.h> | |
| 27 #include <signal.h> | |
| 28 #include <stdio.h> | |
| 29 #ifndef S_SPLINT_S | |
| 30 #include <pthread.h> /* pacifies OpenBSD's compiler */ | |
| 31 #endif | |
| 32 | |
| 33 /* | |
| 34 * 4.1 - Base version for initial JSON protocol (Dec 2009, release 2.90) | |
| 35 * 4.2 - AIS application IDs split into DAC and FID (July 2010, release 2.95) | |
| 36 * 5.0 - MAXCHANNELS bumped from 20 to 32 for GLONASS (Mar 2011, release 2.96) | |
| 37 * gps_open() becomes reentrant, what gps_open_r() used to be. | |
| 38 * gps_poll() removed in favor of gps_read(). The raw hook is gone. | |
| 39 */ | |
| 40 #define GPSD_API_MAJOR_VERSION 5 /* bump on incompatible changes */ | |
| 41 #define GPSD_API_MINOR_VERSION 0 /* bump on compatible changes */ | |
| 42 | |
| 43 #define MAXTAGLEN 8 /* maximum length of sentence tag name */ | |
| 44 #define MAXCHANNELS 72 /* must be > 12 GPS + 12 GLONASS + 2 WAAS */ | |
| 45 #define GPS_PRNMAX 32 /* above this number are SBAS satellites */ | |
| 46 #define GPS_PATH_MAX 64 /* dev files usually have short names */ | |
| 47 #define MAXUSERDEVS 4 /* max devices per user */ | |
| 48 | |
| 49 /* | |
| 50 * The structure describing an uncertainty volume in kinematic space. | |
| 51 * This is what GPSes are meant to produce; all the other info is | |
| 52 * technical impedimenta. | |
| 53 * | |
| 54 * All double values use NAN to indicate data not available. | |
| 55 * | |
| 56 * Usually all the information in this structure was considered valid | |
| 57 * by the GPS at the time of update. This will be so if you are using | |
| 58 * a GPS chipset that speaks SiRF binary, Garmin binary, or Zodiac binary. | |
| 59 * This covers over 80% of GPS products in early 2005. | |
| 60 * | |
| 61 * If you are using a chipset that speaks NMEA, this structure is updated | |
| 62 * in bits by GPRMC (lat/lon, track, speed), GPGGA (alt, climb), GPGLL | |
| 63 * (lat/lon), and GPGSA (eph, epv). Most NMEA GPSes take a single fix | |
| 64 * at the beginning of a 1-second cycle and report the same timestamp in | |
| 65 * GPRMC, GPGGA, and GPGLL; for these, all info is guaranteed correctly | |
| 66 * synced to the time member, but you'll get different stages of the same | |
| 67 * update depending on where in the cycle you poll. A very few GPSes, | |
| 68 * like the Garmin 48, take a new fix before more than one of of | |
| 69 * GPRMC/GPGGA/GPGLL during a single cycle; thus, they may have different | |
| 70 * timestamps and some data in this structure can be up to 1 cycle (usually | |
| 71 * 1 second) older than the fix time. | |
| 72 * | |
| 73 * Error estimates are at 95% confidence. | |
| 74 */ | |
| 75 typedef double timestamp_t; /* Unix time in seconds with fractional part */ | |
| 76 | |
| 77 struct gps_fix_t { | |
| 78 timestamp_t time; /* Time of update */ | |
| 79 int mode; /* Mode of fix */ | |
| 80 #define MODE_NOT_SEEN 0 /* mode update not seen yet */ | |
| 81 #define MODE_NO_FIX 1 /* none */ | |
| 82 #define MODE_2D 2 /* good for latitude/longitude */ | |
| 83 #define MODE_3D 3 /* good for altitude/climb too */ | |
| 84 double ept; /* Expected time uncertainty */ | |
| 85 double latitude; /* Latitude in degrees (valid if mode >= 2) */ | |
| 86 double epy; /* Latitude position uncertainty, meters */ | |
| 87 double longitude; /* Longitude in degrees (valid if mode >= 2) */ | |
| 88 double epx; /* Longitude position uncertainty, meters */ | |
| 89 double altitude; /* Altitude in meters (valid if mode == 3) */ | |
| 90 double epv; /* Vertical position uncertainty, meters */ | |
| 91 double track; /* Course made good (relative to true north) */ | |
| 92 double epd; /* Track uncertainty, degrees */ | |
| 93 double speed; /* Speed over ground, meters/sec */ | |
| 94 double eps; /* Speed uncertainty, meters/sec */ | |
| 95 double climb; /* Vertical speed, meters/sec */ | |
| 96 double epc; /* Vertical speed uncertainty */ | |
| 97 }; | |
| 98 | |
| 99 /* | |
| 100 * The structure describing the pseudorange errors (GPGST) | |
| 101 */ | |
| 102 struct gst_t { | |
| 103 double utctime; | |
| 104 double rms_deviation; | |
| 105 double smajor_deviation; | |
| 106 double sminor_deviation; | |
| 107 double smajor_orientation; | |
| 108 double lat_err_deviation; | |
| 109 double lon_err_deviation; | |
| 110 double alt_err_deviation; | |
| 111 }; | |
| 112 | |
| 113 /* | |
| 114 * From the RCTM104 2.x standard: | |
| 115 * | |
| 116 * "The 30 bit words (as opposed to 32 bit words) coupled with a 50 Hz | |
| 117 * transmission rate provides a convenient timing capability where the | |
| 118 * times of word boundaries are a rational multiple of 0.6 seconds." | |
| 119 * | |
| 120 * "Each frame is N+2 words long, where N is the number of message data | |
| 121 * words. For example, a filler message (type 6 or 34) with no message | |
| 122 * data will have N=0, and will consist only of two header words. The | |
| 123 * maximum number of data words allowed by the format is 31, so that | |
| 124 * the longest possible message will have a total of 33 words." | |
| 125 */ | |
| 126 #define RTCM2_WORDS_MAX 33 | |
| 127 #define MAXCORRECTIONS 18 /* max correction count in type 1 or 9 */ | |
| 128 #define MAXSTATIONS 10 /* maximum stations in almanac, type 5 */ | |
| 129 /* RTCM104 doesn't specify this, so give it the largest reasonable value */ | |
| 130 #define MAXHEALTH (RTCM2_WORDS_MAX-2) | |
| 131 | |
| 132 #ifndef S_SPLINT_S | |
| 133 /* | |
| 134 * A nominally 30-bit word (24 bits of data, 6 bits of parity) | |
| 135 * used both in the GPS downlink protocol described in IS-GPS-200 | |
| 136 * and in the format for DGPS corrections used in RTCM-104v2. | |
| 137 */ | |
| 138 typedef /*@unsignedintegraltype@*/ uint32_t isgps30bits_t; | |
| 139 #endif /* S_SPLINT_S */ | |
| 140 | |
| 141 /* | |
| 142 * Values for "system" fields. Note, the encoding logic is senstive to the | |
| 143 * actual values of these; it's not sufficient that they're distinct. | |
| 144 */ | |
| 145 #define NAVSYSTEM_GPS 0 | |
| 146 #define NAVSYSTEM_GLONASS 1 | |
| 147 #define NAVSYSTEM_GALILEO 2 | |
| 148 #define NAVSYSTEM_UNKNOWN 3 | |
| 149 | |
| 150 struct rtcm2_t { | |
| 151 /* header contents */ | |
| 152 unsigned type; /* RTCM message type */ | |
| 153 unsigned length; /* length (words) */ | |
| 154 double zcount; /* time within hour: GPS time, no leap secs */ | |
| 155 unsigned refstaid; /* reference station ID */ | |
| 156 unsigned seqnum; /* message sequence number (modulo 8) */ | |
| 157 unsigned stathlth; /* station health */ | |
| 158 | |
| 159 /* message data in decoded form */ | |
| 160 union { | |
| 161 struct { | |
| 162 unsigned int nentries; | |
| 163 struct gps_rangesat_t { /* data from messages 1 & 9 */ | |
| 164 unsigned ident; /* satellite ID */ | |
| 165 unsigned udre; /* user diff. range error */ | |
| 166 unsigned iod; /* issue of data */ | |
| 167 double prc; /* range error */ | |
| 168 double rrc; /* range error rate */ | |
| 169 } sat[MAXCORRECTIONS]; | |
| 170 } gps_ranges; | |
| 171 struct { /* data for type 3 messages */ | |
| 172 bool valid; /* is message well-formed? */ | |
| 173 double x, y, z; | |
| 174 } ecef; | |
| 175 struct { /* data from type 4 messages */ | |
| 176 bool valid; /* is message well-formed? */ | |
| 177 int system; | |
| 178 int sense; | |
| 179 #define SENSE_INVALID 0 | |
| 180 #define SENSE_GLOBAL 1 | |
| 181 #define SENSE_LOCAL 2 | |
| 182 char datum[6]; | |
| 183 double dx, dy, dz; | |
| 184 } reference; | |
| 185 struct { /* data from type 5 messages */ | |
| 186 unsigned int nentries; | |
| 187 struct consat_t { | |
| 188 unsigned ident; /* satellite ID */ | |
| 189 bool iodl; /* issue of data */ | |
| 190 unsigned int health; /* is satellite healthy? */ | |
| 191 #define HEALTH_NORMAL (0) /* Radiobeacon operation normal */ | |
| 192 #define HEALTH_UNMONITORED (1) /* No integrity monitor operating */ | |
| 193 #define HEALTH_NOINFO (2) /* No information available */ | |
| 194 #define HEALTH_DONOTUSE (3) /* Do not use this radiobeacon */ | |
| 195 int snr; /* signal-to-noise ratio, dB */ | |
| 196 #define SNR_BAD -1 /* not reported */ | |
| 197 bool health_en; /* health enabled */ | |
| 198 bool new_data; /* new data? */ | |
| 199 bool los_warning; /* line-of-sight warning */ | |
| 200 unsigned int tou; /* time to unhealth, seconds */ | |
| 201 } sat[MAXHEALTH]; | |
| 202 } conhealth; | |
| 203 struct { /* data from type 7 messages */ | |
| 204 unsigned int nentries; | |
| 205 struct station_t { | |
| 206 double latitude, longitude; /* location */ | |
| 207 unsigned int range; /* range in km */ | |
| 208 double frequency; /* broadcast freq */ | |
| 209 unsigned int health; /* station health */ | |
| 210 unsigned int station_id; /* of the transmitter */ | |
| 211 unsigned int bitrate; /* of station transmissions */ | |
| 212 } station[MAXSTATIONS]; | |
| 213 } almanac; | |
| 214 struct { /* data for type 13 messages */ | |
| 215 bool status; /* expect a text message */ | |
| 216 bool rangeflag; /* station range altered? */ | |
| 217 double lat, lon; /* station longitude/latitude */ | |
| 218 unsigned int range; /* transmission range in km */ | |
| 219 } xmitter; | |
| 220 struct { /* data from type 14 messages */ | |
| 221 unsigned int week; /* GPS week (0-1023) */ | |
| 222 unsigned int hour; /* Hour in week (0-167) */ | |
| 223 unsigned int leapsecs; /* Leap seconds (0-63) */ | |
| 224 } gpstime; | |
| 225 struct { | |
| 226 unsigned int nentries; | |
| 227 struct glonass_rangesat_t { /* data from message type 31 */ | |
| 228 unsigned ident; /* satellite ID */ | |
| 229 unsigned udre; /* user diff. range error */ | |
| 230 unsigned tod; /* issue of data */ | |
| 231 bool change; /* ephemeris change bit */ | |
| 232 double prc; /* range error */ | |
| 233 double rrc; /* range error rate */ | |
| 234 } sat[MAXCORRECTIONS]; | |
| 235 } glonass_ranges; | |
| 236 /* data from type 16 messages */ | |
| 237 char message[(RTCM2_WORDS_MAX-2) * sizeof(isgps30bits_t)]; | |
| 238 /* data from messages of unknown type */ | |
| 239 isgps30bits_t words[RTCM2_WORDS_MAX-2]; | |
| 240 }; | |
| 241 }; | |
| 242 | |
| 243 /* RTCM3 report structures begin here */ | |
| 244 | |
| 245 #define RTCM3_MAX_SATELLITES 64 | |
| 246 #define RTCM3_MAX_DESCRIPTOR 31 | |
| 247 #define RTCM3_MAX_ANNOUNCEMENTS 32 | |
| 248 | |
| 249 struct rtcm3_rtk_hdr { /* header data from 1001, 1002, 1003, 1004 */ | |
| 250 /* Used for both GPS and GLONASS, but their timebases differ */ | |
| 251 unsigned int station_id; /* Reference Station ID */ | |
| 252 time_t tow; /* GPS Epoch Time (TOW) in ms, | |
| 253 or GLONASS Epoch Time in ms */ | |
| 254 bool sync; /* Synchronous GNSS Message Flag */ | |
| 255 unsigned short satcount; /* # Satellite Signals Processed */ | |
| 256 bool smoothing; /* Divergence-free Smoothing Indicator */ | |
| 257 unsigned short interval; /* Smoothing Interval */ | |
| 258 }; | |
| 259 | |
| 260 struct rtcm3_basic_rtk { | |
| 261 unsigned char indicator; /* Indicator */ | |
| 262 short channel; /* Satellite Frequency Channel Number | |
| 263 (GLONASS only) */ | |
| 264 double pseudorange; /* Pseudorange */ | |
| 265 double rangediff; /* PhaseRange – Pseudorange in meters */ | |
| 266 unsigned char locktime; /* Lock time Indicator */ | |
| 267 }; | |
| 268 | |
| 269 struct rtcm3_extended_rtk { | |
| 270 unsigned char indicator; /* Indicator */ | |
| 271 short channel; /* Satellite Frequency Channel Number | |
| 272 (GLONASS only) */ | |
| 273 double pseudorange; /* Pseudorange */ | |
| 274 double rangediff; /* PhaseRange – L1 Pseudorange */ | |
| 275 unsigned char locktime; /* Lock time Indicator */ | |
| 276 unsigned char ambiguity; /* Integer Pseudorange | |
| 277 Modulus Ambiguity */ | |
| 278 double CNR; /* Carrier-to-Noise Ratio */ | |
| 279 }; | |
| 280 | |
| 281 struct rtcm3_network_rtk_header { | |
| 282 unsigned int network_id; /* Network ID */ | |
| 283 unsigned int subnetwork_id; /* Subnetwork ID */ | |
| 284 time_t time; /* GPS Epoch Time (TOW) in ms */ | |
| 285 bool multimesg; /* GPS Multiple Message Indicator */ | |
| 286 unsigned master_id; /* Master Reference Station ID */ | |
| 287 unsigned aux_id; /* Auxilary Reference Station ID */ | |
| 288 unsigned char satcount; /* count of GPS satellites */ | |
| 289 }; | |
| 290 | |
| 291 struct rtcm3_correction_diff { | |
| 292 unsigned char ident; /* satellite ID */ | |
| 293 enum {reserved, correct, widelane, uncertain} ambiguity; | |
| 294 unsigned char nonsync; | |
| 295 double geometric_diff; /* Geometric Carrier Phase | |
| 296 Correction Difference (1016, 1017) */ | |
| 297 unsigned char iode; /* GPS IODE (1016, 1017) */ | |
| 298 double ionospheric_diff; /* Ionospheric Carrier Phase | |
| 299 Correction Difference (1015, 1017) */ | |
| 300 }; | |
| 301 | |
| 302 struct rtcm3_t { | |
| 303 /* header contents */ | |
| 304 unsigned type; /* RTCM 3.x message type */ | |
| 305 unsigned length; /* payload length, inclusive of checksum */ | |
| 306 | |
| 307 union { | |
| 308 /* 1001-1013 were present in the 3.0 version */ | |
| 309 struct { | |
| 310 struct rtcm3_rtk_hdr header; | |
| 311 struct rtcm3_1001_t { | |
| 312 unsigned ident; /* Satellite ID */ | |
| 313 struct rtcm3_basic_rtk L1; | |
| 314 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 315 } rtcm3_1001; | |
| 316 struct rtcm3_1002_t { | |
| 317 struct rtcm3_rtk_hdr header; | |
| 318 struct { | |
| 319 unsigned ident; /* Satellite ID */ | |
| 320 struct rtcm3_extended_rtk L1; | |
| 321 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 322 } rtcm3_1002; | |
| 323 struct rtcm3_1003_t { | |
| 324 struct rtcm3_rtk_hdr header; | |
| 325 struct { | |
| 326 unsigned ident; /* Satellite ID */ | |
| 327 struct rtcm3_basic_rtk L1; | |
| 328 struct rtcm3_basic_rtk L2; | |
| 329 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 330 } rtcm3_1003; | |
| 331 struct rtcm3_1004_t { | |
| 332 struct rtcm3_rtk_hdr header; | |
| 333 struct { | |
| 334 unsigned ident; /* Satellite ID */ | |
| 335 struct rtcm3_extended_rtk L1; | |
| 336 struct rtcm3_extended_rtk L2; | |
| 337 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 338 } rtcm3_1004; | |
| 339 struct rtcm3_1005_t { | |
| 340 unsigned int station_id; /* Reference Station ID */ | |
| 341 int system; /* Which system is it? */ | |
| 342 bool reference_station; /* Reference-station indicator *
/ | |
| 343 bool single_receiver; /* Single Receiver Oscillator */ | |
| 344 double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ | |
| 345 } rtcm3_1005; | |
| 346 struct rtcm3_1006_t { | |
| 347 unsigned int station_id; /* Reference Station ID */ | |
| 348 int system; /* Which system is it? */ | |
| 349 bool reference_station; /* Reference-station indicator *
/ | |
| 350 bool single_receiver; /* Single Receiver Oscillator */ | |
| 351 double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ | |
| 352 double height; /* Antenna height */ | |
| 353 } rtcm3_1006; | |
| 354 struct rtcm3_1007_t { | |
| 355 unsigned int station_id; /* Reference Station ID
*/ | |
| 356 char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ | |
| 357 unsigned char setup_id; | |
| 358 } rtcm3_1007; | |
| 359 struct rtcm3_1008_t { | |
| 360 unsigned int station_id; /* Reference Station ID
*/ | |
| 361 char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ | |
| 362 unsigned char setup_id; | |
| 363 char serial[RTCM3_MAX_DESCRIPTOR+1]; /* Serial # string */ | |
| 364 } rtcm3_1008; | |
| 365 struct rtcm3_1009_t { | |
| 366 struct rtcm3_rtk_hdr header; | |
| 367 struct { | |
| 368 unsigned ident; /* Satellite ID */ | |
| 369 struct rtcm3_basic_rtk L1; | |
| 370 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 371 } rtcm3_1009; | |
| 372 struct rtcm3_1010_t { | |
| 373 struct rtcm3_rtk_hdr header; | |
| 374 struct { | |
| 375 unsigned ident; /* Satellite ID */ | |
| 376 struct rtcm3_extended_rtk L1; | |
| 377 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 378 } rtcm3_1010; | |
| 379 struct rtcm3_1011_t { | |
| 380 struct rtcm3_rtk_hdr header; | |
| 381 struct { | |
| 382 unsigned ident; /* Satellite ID */ | |
| 383 struct rtcm3_extended_rtk L1; | |
| 384 struct rtcm3_extended_rtk L2; | |
| 385 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 386 } rtcm3_1011; | |
| 387 struct rtcm3_1012_t { | |
| 388 struct rtcm3_rtk_hdr header; | |
| 389 struct { | |
| 390 unsigned ident; /* Satellite ID */ | |
| 391 struct rtcm3_extended_rtk L1; | |
| 392 struct rtcm3_extended_rtk L2; | |
| 393 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 394 } rtcm3_1012; | |
| 395 struct rtcm3_1013_t { | |
| 396 unsigned int station_id; /* Reference Station ID */ | |
| 397 unsigned short mjd; /* Modified Julian Day (MJD) Number */ | |
| 398 unsigned int sod; /* Seconds of Day (UTC) */ | |
| 399 unsigned char leapsecs; /* Leap Seconds, GPS-UTC */ | |
| 400 unsigned char ncount; /* Count of announcements to follow */ | |
| 401 struct { | |
| 402 unsigned short id; /* message type ID */ | |
| 403 bool sync; | |
| 404 unsigned short interval; /* interval in 0.1sec units */ | |
| 405 } announcements[RTCM3_MAX_ANNOUNCEMENTS]; | |
| 406 } rtcm3_1013; | |
| 407 /* 1014-1017 were added in the 3.1 version */ | |
| 408 struct rtcm3_1014_t { | |
| 409 unsigned int network_id; /* Network ID */ | |
| 410 unsigned int subnetwork_id; /* Subnetwork ID */ | |
| 411 unsigned char stationcount; /* # auxiliary stations transmitted */ | |
| 412 unsigned int master_id; /* Master Reference Station ID */ | |
| 413 unsigned int aux_id; /* Auxilary Reference Station ID */ | |
| 414 double d_lat, d_lon, d_alt; /* Aux-master location delta */ | |
| 415 } rtcm3_1014; | |
| 416 struct rtcm3_1015_t { | |
| 417 struct rtcm3_network_rtk_header header; | |
| 418 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
| 419 } rtcm3_1015; | |
| 420 struct rtcm3_1016_t { | |
| 421 struct rtcm3_network_rtk_header header; | |
| 422 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
| 423 } rtcm3_1016; | |
| 424 struct rtcm3_1017_t { | |
| 425 struct rtcm3_network_rtk_header header; | |
| 426 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
| 427 } rtcm3_1017; | |
| 428 /* 1018-1029 were in the 3.0 version */ | |
| 429 struct rtcm3_1019_t { | |
| 430 unsigned int ident; /* Satellite ID */ | |
| 431 unsigned int week; /* GPS Week Number */ | |
| 432 unsigned char sv_accuracy; /* GPS SV ACCURACY */ | |
| 433 enum {reserved_code, p, ca, l2c} code; | |
| 434 double idot; | |
| 435 unsigned char iode; | |
| 436 /* ephemeris fields, not scaled */ | |
| 437 unsigned int t_sub_oc; | |
| 438 signed int a_sub_f2; | |
| 439 signed int a_sub_f1; | |
| 440 signed int a_sub_f0; | |
| 441 unsigned int iodc; | |
| 442 signed int C_sub_rs; | |
| 443 signed int delta_sub_n; | |
| 444 signed int M_sub_0; | |
| 445 signed int C_sub_uc; | |
| 446 unsigned int e; | |
| 447 signed int C_sub_us; | |
| 448 unsigned int sqrt_sub_A; | |
| 449 unsigned int t_sub_oe; | |
| 450 signed int C_sub_ic; | |
| 451 signed int OMEGA_sub_0; | |
| 452 signed int C_sub_is; | |
| 453 signed int i_sub_0; | |
| 454 signed int C_sub_rc; | |
| 455 signed int argument_of_perigee; | |
| 456 signed int omegadot; | |
| 457 signed int t_sub_GD; | |
| 458 unsigned char sv_health; | |
| 459 bool p_data; | |
| 460 bool fit_interval; | |
| 461 } rtcm3_1019; | |
| 462 struct rtcm3_1020_t { | |
| 463 unsigned int ident; /* Satellite ID */ | |
| 464 unsigned short channel; /* Satellite Frequency Channel Number */ | |
| 465 /* ephemeris fields, not scaled */ | |
| 466 bool C_sub_n; | |
| 467 bool health_avAilability_indicator; | |
| 468 unsigned char P1; | |
| 469 unsigned short t_sub_k; | |
| 470 bool msb_of_B_sub_n; | |
| 471 bool P2; | |
| 472 bool t_sub_b; | |
| 473 signed int x_sub_n_t_of_t_sub_b_prime; | |
| 474 signed int x_sub_n_t_of_t_sub_b; | |
| 475 signed int x_sub_n_t_of_t_sub_b_prime_prime; | |
| 476 signed int y_sub_n_t_of_t_sub_b_prime; | |
| 477 signed int y_sub_n_t_of_t_sub_b; | |
| 478 signed int y_sub_n_t_of_t_sub_b_prime_prime; | |
| 479 signed int z_sub_n_t_of_t_sub_b_prime; | |
| 480 signed int z_sub_n_t_of_t_sub_b; | |
| 481 signed int z_sub_n_t_of_t_sub_b_prime_prime; | |
| 482 bool P3; | |
| 483 signed int gamma_sub_n_of_t_sub_b; | |
| 484 unsigned char MP; | |
| 485 bool Ml_n; | |
| 486 signed int tau_n_of_t_sub_b; | |
| 487 signed int M_delta_tau_sub_n; | |
| 488 unsigned int E_sub_n; | |
| 489 bool MP4; | |
| 490 unsigned char MF_sub_T; | |
| 491 unsigned char MN_sub_T; | |
| 492 unsigned char MM; | |
| 493 bool additioinal_data_availability; | |
| 494 unsigned int N_sup_A; | |
| 495 unsigned int tau_sub_c; | |
| 496 unsigned int M_N_sub_4; | |
| 497 signed int M_tau_sub_GPS; | |
| 498 bool M_l_sub_n; | |
| 499 } rtcm3_1020; | |
| 500 struct rtcm3_1029_t { | |
| 501 unsigned int station_id; /* Reference Station ID */ | |
| 502 unsigned short mjd; /* Modified Julian Day (MJD) Number */ | |
| 503 unsigned int sod; /* Seconds of Day (UTC) */ | |
| 504 size_t len; /* # chars to follow */ | |
| 505 size_t unicode_units; /* # Unicode units in text */ | |
| 506 unsigned char text[128]; | |
| 507 } rtcm3_1029; | |
| 508 struct rtcm3_1033_t { | |
| 509 unsigned int station_id; /* Reference Station ID
*/ | |
| 510 char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ | |
| 511 unsigned char setup_id; | |
| 512 char serial[RTCM3_MAX_DESCRIPTOR+1]; /* Serial # string */ | |
| 513 char receiver[RTCM3_MAX_DESCRIPTOR+1]; /* Receiver string */ | |
| 514 char firmware[RTCM3_MAX_DESCRIPTOR+1]; /* Firmware string */ | |
| 515 } rtcm3_1033; | |
| 516 char data[1024]; /* Max RTCM3 msg length is 1023 bytes */ | |
| 517 } rtcmtypes; | |
| 518 }; | |
| 519 | |
| 520 /* RTCM3 scaling constants */ | |
| 521 #define GPS_AMBIGUITY_MODULUS 299792.458 /* 1004, DF014*/ | |
| 522 #define GLONASS_AMBIGUITY_MODULUS 599584.916 /* 1012, DF044 */ | |
| 523 #define MESSAGE_INTERVAL_UNITS 0.1 /* 1013, DF047 */ | |
| 524 | |
| 525 /* | |
| 526 * Raw IS_GPS subframe data | |
| 527 */ | |
| 528 | |
| 529 /* The almanac is a subset of the clock and ephemeris data, with reduced | |
| 530 * precision. See IS-GPS-200E, Table 20-VI */ | |
| 531 struct almanac_t | |
| 532 { | |
| 533 uint8_t sv; /* The satellite this refers to */ | |
| 534 /* toa, almanac reference time, 8 bits unsigned, seconds */ | |
| 535 uint8_t toa; | |
| 536 long l_toa; | |
| 537 /* SV health data, 8 bit unsigned bit map */ | |
| 538 uint8_t svh; | |
| 539 /* deltai, correction to inclination, 16 bits signed, semi-circles */ | |
| 540 int16_t deltai; | |
| 541 double d_deltai; | |
| 542 /* M0, Mean Anomaly at Reference Time, 24 bits signed, semi-circles */ | |
| 543 int32_t M0; | |
| 544 double d_M0; | |
| 545 /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly Epoch, | |
| 546 * 24 bits signed, semi-circles */ | |
| 547 int32_t Omega0; | |
| 548 double d_Omega0; | |
| 549 /* omega, Argument of Perigee, 24 bits signed, semi-circles */ | |
| 550 int32_t omega; | |
| 551 double d_omega; | |
| 552 /* af0, SV clock correction constant term | |
| 553 * 11 bits signed, seconds */ | |
| 554 int16_t af0; | |
| 555 double d_af0; | |
| 556 /* af1, SV clock correction first order term | |
| 557 * 11 bits signed, seconds/second */ | |
| 558 int16_t af1; | |
| 559 double d_af1; | |
| 560 /* eccentricity, 16 bits, unsigned, dimensionless */ | |
| 561 uint16_t e; | |
| 562 double d_eccentricity; | |
| 563 /* sqrt A, Square Root of the Semi-Major Axis | |
| 564 * 24 bits unsigned, square_root(meters) */ | |
| 565 uint32_t sqrtA; | |
| 566 double d_sqrtA; | |
| 567 /* Omega dot, Rate of Right Ascension, 16 bits signed, semi-circles/sec */ | |
| 568 int16_t Omegad; | |
| 569 double d_Omegad; | |
| 570 }; | |
| 571 | |
| 572 struct subframe_t { | |
| 573 /* subframe number, 3 bits, unsigned, 1 to 5 */ | |
| 574 uint8_t subframe_num; | |
| 575 /* data_id, denotes the NAV data structure of D(t), 2 bits, in | |
| 576 * IS-GPS-200E always == 0x1 */ | |
| 577 uint8_t data_id; | |
| 578 /* SV/page id used for subframes 4 & 5, 6 bits */ | |
| 579 uint8_t pageid; | |
| 580 /* tSVID, SV ID of the sat that transmitted this frame, 6 bits unsigned */ | |
| 581 uint8_t tSVID; | |
| 582 /* TOW, Time of Week of NEXT message, 17 bits unsigned, scale 6, seconds */ | |
| 583 uint32_t TOW17; | |
| 584 long l_TOW17; | |
| 585 /* integrity, URA bounds flag, 1 bit */ | |
| 586 bool integrity; | |
| 587 /* alert, alert flag, SV URA and/or the SV User Differential Range | |
| 588 * Accuracy (UDRA) may be worse than indicated, 1 bit */ | |
| 589 bool alert; | |
| 590 /* antispoof, A-S mode is ON in that SV, 1 bit */ | |
| 591 bool antispoof; | |
| 592 int is_almanac; | |
| 593 union { | |
| 594 /* subframe 1, part of ephemeris, see IS-GPS-200E, Table 20-II | |
| 595 * and Table 20-I */ | |
| 596 struct { | |
| 597 /* WN, Week Number, 10 bits unsigned, scale 1, weeks */ | |
| 598 uint16_t WN; | |
| 599 /* IODC, Issue of Data, Clock, 10 bits, unsigned, | |
| 600 * issued in 8 data ranges at the same time */ | |
| 601 uint16_t IODC; | |
| 602 /* toc, clock data reference time, 16 bits, unsigned, seconds | |
| 603 * scale 2**4, issued in 8 data ranges at the same time */ | |
| 604 uint16_t toc; | |
| 605 long l_toc; | |
| 606 /* l2, code on L2, 2 bits, bit map */ | |
| 607 uint8_t l2; | |
| 608 /* l2p, L2 P data flag, 1 bit */ | |
| 609 uint8_t l2p; | |
| 610 /* ura, SV accuracy, 4 bits unsigned index */ | |
| 611 unsigned int ura; | |
| 612 /* hlth, SV health, 6 bits unsigned bitmap */ | |
| 613 unsigned int hlth; | |
| 614 /* af0, SV clock correction constant term | |
| 615 * 22 bits signed, scale 2**-31, seconds */ | |
| 616 int32_t af0; | |
| 617 double d_af0; | |
| 618 /* af1, SV clock correction first order term | |
| 619 * 22 bits signed, scale 2**-43, seconds/second */ | |
| 620 int16_t af1; | |
| 621 double d_af1; | |
| 622 /* af2, SV clock correction second order term | |
| 623 * 8 bits signed, scale 2**-55, seconds/second**2 */ | |
| 624 int8_t af2; | |
| 625 double d_af2; | |
| 626 /* Tgd, L1-L2 correction term, 8 bits signed, scale 2**-31, | |
| 627 * seconds */ | |
| 628 int8_t Tgd; | |
| 629 double d_Tgd; | |
| 630 } sub1; | |
| 631 /* subframe 2, part of ephemeris, see IS-GPS-200E, Table 20-II | |
| 632 * and Table 20-III */ | |
| 633 struct { | |
| 634 /* Issue of Data (Ephemeris), | |
| 635 * equal to the 8 LSBs of the 10 bit IODC of the same data set */ | |
| 636 uint8_t IODE; | |
| 637 /* Age of Data Offset for the NMCT, 6 bits, scale 900, | |
| 638 * ignore if all ones, seconds */ | |
| 639 uint8_t AODO; | |
| 640 uint16_t u_AODO; | |
| 641 /* fit, FIT interval flag, indicates a fit interval greater than | |
| 642 * 4 hour, 1 bit */ | |
| 643 uint8_t fit; | |
| 644 /* toe, Reference Time Ephemeris, 16 bits unsigned, scale 2**4, | |
| 645 * seconds */ | |
| 646 uint16_t toe; | |
| 647 long l_toe; | |
| 648 /* Crs, Amplitude of the Sine Harmonic Correction Term to the | |
| 649 * Orbit Radius, 16 bits, scale 2**-5, signed, meters */ | |
| 650 int16_t Crs; | |
| 651 double d_Crs; | |
| 652 /* Cus, Amplitude of the Sine Harmonic Correction Term to the | |
| 653 * Argument of Latitude, 16 bits, signed, scale 2**-29, radians */ | |
| 654 int16_t Cus; | |
| 655 double d_Cus; | |
| 656 /* Cuc, Amplitude of the Cosine Harmonic Correction Term to the | |
| 657 * Argument of Latitude, 16 bits, signed, scale 2**-29, radians */ | |
| 658 int16_t Cuc; | |
| 659 double d_Cuc; | |
| 660 /* deltan, Mean Motion Difference From Computed Value | |
| 661 * Mean Motion Difference From Computed Value | |
| 662 * 16 bits, signed, scale 2**-43, semi-circles/sec */ | |
| 663 int16_t deltan; | |
| 664 double d_deltan; | |
| 665 /* M0, Mean Anomaly at Reference Time, 32 bits signed, | |
| 666 * scale 2**-31, semi-circles */ | |
| 667 int32_t M0; | |
| 668 double d_M0; | |
| 669 /* eccentricity, 32 bits, unsigned, scale 2**-33, dimensionless */ | |
| 670 uint32_t e; | |
| 671 double d_eccentricity; | |
| 672 /* sqrt A, Square Root of the Semi-Major Axis | |
| 673 * 32 bits unsigned, scale 2**-19, square_root(meters) */ | |
| 674 uint32_t sqrtA; | |
| 675 double d_sqrtA; | |
| 676 } sub2; | |
| 677 /* subframe 3, part of ephemeris, see IS-GPS-200E, Table 20-II, | |
| 678 * Table 20-III */ | |
| 679 struct { | |
| 680 /* Issue of Data (Ephemeris), 8 bits, unsigned | |
| 681 * equal to the 8 LSBs of the 10 bit IODC of the same data set */ | |
| 682 uint8_t IODE; | |
| 683 /* Rate of Inclination Angle, 14 bits signed, scale2**-43, | |
| 684 * semi-circles/sec */ | |
| 685 uint16_t IDOT; | |
| 686 double d_IDOT; | |
| 687 /* Cic, Amplitude of the Cosine Harmonic Correction Term to the | |
| 688 * Angle of Inclination, 16 bits signed, scale 2**-29, radians*/ | |
| 689 uint16_t Cic; | |
| 690 double d_Cic; | |
| 691 /* Cis, Amplitude of the Sine Harmonic Correction Term to the | |
| 692 * Angle of Inclination, 16 bits, unsigned, scale 2**-29, radians */ | |
| 693 int16_t Cis; | |
| 694 double d_Cis; | |
| 695 /* Crc, Amplitude of the Cosine Harmonic Correction Term to the | |
| 696 * Orbit Radius, 16 bits signed, scale 2**-5, meters */ | |
| 697 int16_t Crc; | |
| 698 double d_Crc; | |
| 699 /* i0, Inclination Angle at Reference Time, 32 bits, signed, | |
| 700 * scale 2**-31, semi-circles */ | |
| 701 int32_t i0; | |
| 702 double d_i0; | |
| 703 /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly | |
| 704 * Epoch, 32 bits signed, semi-circles */ | |
| 705 int32_t Omega0; | |
| 706 double d_Omega0; | |
| 707 /* omega, Argument of Perigee, 32 bits signed, scale 2**-31, | |
| 708 * semi-circles */ | |
| 709 int32_t omega; | |
| 710 double d_omega; | |
| 711 /* Omega dot, Rate of Right Ascension, 24 bits signed, | |
| 712 * scale 2**-43, semi-circles/sec */ | |
| 713 int32_t Omegad; | |
| 714 double d_Omegad; | |
| 715 } sub3; | |
| 716 struct { | |
| 717 struct almanac_t almanac; | |
| 718 } sub4; | |
| 719 /* subframe 4, page 13 */ | |
| 720 struct { | |
| 721 /* mapping ord ERD# to SV # is non trivial | |
| 722 * leave it alone. See IS-GPS-200E Section 20.3.3.5.1.9 */ | |
| 723 /* Estimated Range Deviation, 6 bits signed, meters */ | |
| 724 char ERD[33]; | |
| 725 /* ai, Availability Indicator, 2bits, bit map */ | |
| 726 unsigned char ai; | |
| 727 } sub4_13; | |
| 728 /* subframe 4, page 17, system message, 23 chars, plus nul */ | |
| 729 struct { | |
| 730 char str[24]; | |
| 731 } sub4_17; | |
| 732 /* subframe 4, page 18 */ | |
| 733 struct { | |
| 734 /* ionospheric and UTC data */ | |
| 735 /* A0, Bias coefficient of GPS time scale relative to UTC time | |
| 736 * scale, 32 bits signed, scale 2**-30, seconds */ | |
| 737 int32_t A0; | |
| 738 double d_A0; | |
| 739 /* A1, Drift coefficient of GPS time scale relative to UTC time | |
| 740 * scale, 24 bits signed, scale 2**-50, seconds/second */ | |
| 741 int32_t A1; | |
| 742 double d_A1; | |
| 743 | |
| 744 /* alphaX, the four coefficients of a cubic equation representing | |
| 745 * the amplitude of the vertical delay */ | |
| 746 | |
| 747 /* alpha0, 8 bits signed, scale w**-30, seconds */ | |
| 748 int8_t alpha0; | |
| 749 double d_alpha0; | |
| 750 /* alpha1, 8 bits signed, scale w**-27, seconds/semi-circle */ | |
| 751 int8_t alpha1; | |
| 752 double d_alpha1; | |
| 753 /* alpha2, 8 bits signed, scale w**-24, seconds/semi-circle**2 */ | |
| 754 int8_t alpha2; | |
| 755 double d_alpha2; | |
| 756 /* alpha3, 8 bits signed, scale w**-24, seconds/semi-circle**3 */ | |
| 757 int8_t alpha3; | |
| 758 double d_alpha3; | |
| 759 | |
| 760 /* betaX, the four coefficients of a cubic equation representing | |
| 761 * the period of the model */ | |
| 762 | |
| 763 /* beta0, 8 bits signed, scale w**11, seconds */ | |
| 764 int8_t beta0; | |
| 765 double d_beta0; | |
| 766 /* beta1, 8 bits signed, scale w**14, seconds/semi-circle */ | |
| 767 int8_t beta1; | |
| 768 double d_beta1; | |
| 769 /* beta2, 8 bits signed, scale w**16, seconds/semi-circle**2 */ | |
| 770 int8_t beta2; | |
| 771 double d_beta2; | |
| 772 /* beta3, 8 bits signed, scale w**16, seconds/semi-circle**3 */ | |
| 773 int8_t beta3; | |
| 774 double d_beta3; | |
| 775 | |
| 776 /* leap (delta t ls), current leap second, 8 bits signed, | |
| 777 * scale 1, seconds */ | |
| 778 int8_t leap; | |
| 779 /* lsf (delta t lsf), future leap second, 8 bits signed, | |
| 780 * scale 1, seconds */ | |
| 781 int8_t lsf; | |
| 782 | |
| 783 /* tot, reference time for UTC data, | |
| 784 * 8 bits unsigned, scale 2**12, seconds */ | |
| 785 uint8_t tot; | |
| 786 double d_tot; | |
| 787 | |
| 788 /* WNt, UTC reference week number, 8 bits unsigned, scale 1, | |
| 789 * weeks */ | |
| 790 uint8_t WNt; | |
| 791 /* WNlsf, Leap second reference Week Number, | |
| 792 * 8 bits unsigned, scale 1, weeks */ | |
| 793 uint8_t WNlsf; | |
| 794 /* DN, Leap second reference Day Number , 8 bits unsigned, | |
| 795 * scale 1, days */ | |
| 796 uint8_t DN; | |
| 797 } sub4_18; | |
| 798 /* subframe 4, page 25 */ | |
| 799 struct { | |
| 800 /* svf, A-S status and the configuration code of each SV | |
| 801 * 4 bits unsigned, bitmap */ | |
| 802 unsigned char svf[33]; | |
| 803 /* svh, SV health data for SV 25 through 32 | |
| 804 * 6 bits unsigned bitmap */ | |
| 805 uint8_t svhx[8]; | |
| 806 } sub4_25; | |
| 807 struct { | |
| 808 struct almanac_t almanac; | |
| 809 } sub5; | |
| 810 struct { | |
| 811 /* toa, Almanac reference Time, 8 bits unsigned, scale 2**12, | |
| 812 * seconds */ | |
| 813 uint8_t toa; | |
| 814 long l_toa; | |
| 815 /* WNa, Week Number almanac, 8 bits, scale 2, GPS Week | |
| 816 * Number % 256 */ | |
| 817 uint8_t WNa; | |
| 818 /* sv, SV health status, 6 bits, bitmap */ | |
| 819 uint8_t sv[25]; | |
| 820 } sub5_25; | |
| 821 }; | |
| 822 }; | |
| 823 | |
| 824 #ifndef S_SPLINT_S | |
| 825 typedef uint64_t gps_mask_t; | |
| 826 #else | |
| 827 typedef /*@unsignedintegraltype@*/ unsigned long long gps_mask_t; | |
| 828 #endif /* S_SPLINT_S */ | |
| 829 | |
| 830 /* | |
| 831 * Is an MMSI number that of an auxiliary associated with a mother ship? | |
| 832 * We need to be able to test this for decoding AIS Type 24 messages. | |
| 833 * According to <http://www.navcen.uscg.gov/marcomms/gmdss/mmsi.htm#format>, | |
| 834 * auxiliary-craft MMSIs have the form 98MIDXXXX, where MID is a country | |
| 835 * code and XXXX the vessel ID. | |
| 836 */ | |
| 837 #define AIS_AUXILIARY_MMSI(n) ((n) / 10000000 == 98) | |
| 838 | |
| 839 /* N/A values and scaling constant for 25/24 bit lon/lat pairs */ | |
| 840 #define AIS_LON3_NOT_AVAILABLE 181000 | |
| 841 #define AIS_LAT3_NOT_AVAILABLE 91000 | |
| 842 #define AIS_LATLON3_SCALE 60000.0 | |
| 843 | |
| 844 /* N/A values and scaling constant for 28/27 bit lon/lat pairs */ | |
| 845 #define AIS_LON4_NOT_AVAILABLE 1810000 | |
| 846 #define AIS_LAT4_NOT_AVAILABLE 910000 | |
| 847 #define AIS_LATLON4_SCALE 600000.0 | |
| 848 | |
| 849 struct route_info { | |
| 850 unsigned int linkage; /* Message Linkage ID */ | |
| 851 unsigned int sender; /* Sender Class */ | |
| 852 unsigned int rtype; /* Route Type */ | |
| 853 unsigned int month; /* Start month */ | |
| 854 unsigned int day; /* Start day */ | |
| 855 unsigned int hour; /* Start hour */ | |
| 856 unsigned int minute; /* Start minute */ | |
| 857 unsigned int duration; /* Duration */ | |
| 858 int waycount; /* Waypoint count */ | |
| 859 struct waypoint_t { | |
| 860 signed int lon; /* Longitude */ | |
| 861 signed int lat; /* Latitude */ | |
| 862 } waypoints[16]; | |
| 863 }; | |
| 864 | |
| 865 struct ais_t | |
| 866 { | |
| 867 unsigned int type; /* message type */ | |
| 868 unsigned int repeat; /* Repeat indicator */ | |
| 869 unsigned int mmsi; /* MMSI */ | |
| 870 union { | |
| 871 /* Types 1-3 Common navigation info */ | |
| 872 struct { | |
| 873 unsigned int status; /* navigation status */ | |
| 874 signed turn; /* rate of turn */ | |
| 875 #define AIS_TURN_HARD_LEFT -127 | |
| 876 #define AIS_TURN_HARD_RIGHT 127 | |
| 877 #define AIS_TURN_NOT_AVAILABLE 128 | |
| 878 unsigned int speed; /* speed over ground in deciknot
s */ | |
| 879 #define AIS_SPEED_NOT_AVAILABLE 1023 | |
| 880 #define AIS_SPEED_FAST_MOVER 1022 /* >= 102.2 knots */ | |
| 881 bool accuracy; /* position accuracy */ | |
| 882 #define AIS_LATLON_SCALE 600000.0 | |
| 883 int lon; /* longitude */ | |
| 884 #define AIS_LON_NOT_AVAILABLE 0x6791AC0 | |
| 885 int lat; /* latitude */ | |
| 886 #define AIS_LAT_NOT_AVAILABLE 0x3412140 | |
| 887 unsigned int course; /* course over ground */ | |
| 888 #define AIS_COURSE_NOT_AVAILABLE 3600 | |
| 889 unsigned int heading; /* true heading */ | |
| 890 #define AIS_HEADING_NOT_AVAILABLE 511 | |
| 891 unsigned int second; /* seconds of UTC timestamp */ | |
| 892 #define AIS_SEC_NOT_AVAILABLE 60 | |
| 893 #define AIS_SEC_MANUAL 61 | |
| 894 #define AIS_SEC_ESTIMATED 62 | |
| 895 #define AIS_SEC_INOPERATIVE 63 | |
| 896 unsigned int maneuver; /* maneuver indicator */ | |
| 897 //unsigned int spare; spare bits */ | |
| 898 bool raim; /* RAIM flag */ | |
| 899 unsigned int radio; /* radio status bits */ | |
| 900 } type1; | |
| 901 /* Type 4 - Base Station Report & Type 11 - UTC and Date Response */ | |
| 902 struct { | |
| 903 unsigned int year; /* UTC year */ | |
| 904 #define AIS_YEAR_NOT_AVAILABLE 0 | |
| 905 unsigned int month; /* UTC month */ | |
| 906 #define AIS_MONTH_NOT_AVAILABLE 0 | |
| 907 unsigned int day; /* UTC day */ | |
| 908 #define AIS_DAY_NOT_AVAILABLE 0 | |
| 909 unsigned int hour; /* UTC hour */ | |
| 910 #define AIS_HOUR_NOT_AVAILABLE 24 | |
| 911 unsigned int minute; /* UTC minute */ | |
| 912 #define AIS_MINUTE_NOT_AVAILABLE 60 | |
| 913 unsigned int second; /* UTC second */ | |
| 914 #define AIS_SECOND_NOT_AVAILABLE 60 | |
| 915 bool accuracy; /* fix quality */ | |
| 916 int lon; /* longitude */ | |
| 917 int lat; /* latitude */ | |
| 918 unsigned int epfd; /* type of position fix device */ | |
| 919 //unsigned int spare; spare bits */ | |
| 920 bool raim; /* RAIM flag */ | |
| 921 unsigned int radio; /* radio status bits */ | |
| 922 } type4; | |
| 923 /* Type 5 - Ship static and voyage related data */ | |
| 924 struct { | |
| 925 unsigned int ais_version; /* AIS version level */ | |
| 926 unsigned int imo; /* IMO identification */ | |
| 927 char callsign[7+1]; /* callsign */ | |
| 928 #define AIS_SHIPNAME_MAXLEN 20 | |
| 929 char shipname[AIS_SHIPNAME_MAXLEN+1]; /* vessel name */ | |
| 930 unsigned int shiptype; /* ship type code */ | |
| 931 unsigned int to_bow; /* dimension to bow */ | |
| 932 unsigned int to_stern; /* dimension to stern */ | |
| 933 unsigned int to_port; /* dimension to port */ | |
| 934 unsigned int to_starboard; /* dimension to starboard */ | |
| 935 unsigned int epfd; /* type of position fix deviuce */ | |
| 936 unsigned int month; /* UTC month */ | |
| 937 unsigned int day; /* UTC day */ | |
| 938 unsigned int hour; /* UTC hour */ | |
| 939 unsigned int minute; /* UTC minute */ | |
| 940 unsigned int draught; /* draft in meters */ | |
| 941 char destination[20+1]; /* ship destination */ | |
| 942 unsigned int dte; /* data terminal enable */ | |
| 943 //unsigned int spare; spare bits */ | |
| 944 } type5; | |
| 945 /* Type 6 - Addressed Binary Message */ | |
| 946 struct { | |
| 947 unsigned int seqno; /* sequence number */ | |
| 948 unsigned int dest_mmsi; /* destination MMSI */ | |
| 949 bool retransmit; /* retransmit flag */ | |
| 950 //unsigned int spare; spare bit(s) */ | |
| 951 unsigned int dac; /* Application ID */ | |
| 952 unsigned int fid; /* Functional ID */ | |
| 953 #define AIS_TYPE6_BINARY_MAX 920 /* 920 bits */ | |
| 954 size_t bitcount; /* bit count of the data */ | |
| 955 union { | |
| 956 char bitdata[(AIS_TYPE6_BINARY_MAX + 7) / 8]; | |
| 957 /* IMO236 - Dangerous Cargo Indication */ | |
| 958 struct { | |
| 959 char lastport[5+1]; /* Last Port Of Call */ | |
| 960 unsigned int lmonth; /* ETA month */ | |
| 961 unsigned int lday; /* ETA day */ | |
| 962 unsigned int lhour; /* ETA hour */ | |
| 963 unsigned int lminute; /* ETA minute */ | |
| 964 char nextport[5+1]; /* Next Port Of Call */ | |
| 965 unsigned int nmonth; /* ETA month */ | |
| 966 unsigned int nday; /* ETA day */ | |
| 967 unsigned int nhour; /* ETA hour */ | |
| 968 unsigned int nminute; /* ETA minute */ | |
| 969 char dangerous[20+1]; /* Main Dangerous Good */ | |
| 970 char imdcat[4+1]; /* IMD Category */ | |
| 971 unsigned int unid; /* UN Number */ | |
| 972 unsigned int amount; /* Amount of Cargo */ | |
| 973 unsigned int unit; /* Unit of Quantity */ | |
| 974 } dac1fid12; | |
| 975 /* IMO236 - Extended Ship Static and Voyage Related Data */ | |
| 976 struct { | |
| 977 unsigned int airdraught; /* Air Draught */ | |
| 978 } dac1fid15; | |
| 979 /* IMO236 - Number of Persons on board */ | |
| 980 struct { | |
| 981 unsigned persons; /* number of persons */ | |
| 982 } dac1fid16; | |
| 983 /* IMO289 - Clearance Time To Enter Port */ | |
| 984 struct { | |
| 985 unsigned int linkage; /* Message Linkage ID */ | |
| 986 unsigned int month; /* Month (UTC) */ | |
| 987 unsigned int day; /* Day (UTC) */ | |
| 988 unsigned int hour; /* Hour (UTC) */ | |
| 989 unsigned int minute; /* Minute (UTC) */ | |
| 990 char portname[20+1]; /* Name of Port & Berth */ | |
| 991 char destination[5+1]; /* Destination */ | |
| 992 signed int lon; /* Longitude */ | |
| 993 signed int lat; /* Latitude */ | |
| 994 } dac1fid18; | |
| 995 /* IMO289 - Berthing Data (addressed) */ | |
| 996 struct { | |
| 997 unsigned int linkage; /* Message Linkage ID */ | |
| 998 unsigned int berth_length; /* Berth length */ | |
| 999 unsigned int berth_depth; /* Berth Water Depth */ | |
| 1000 unsigned int position; /* Mooring Position */ | |
| 1001 unsigned int month; /* Month (UTC) */ | |
| 1002 unsigned int day; /* Day (UTC) */ | |
| 1003 unsigned int hour; /* Hour (UTC) */ | |
| 1004 unsigned int minute; /* Minute (UTC) */ | |
| 1005 unsigned int availability; /* Services Availability */ | |
| 1006 unsigned int agent; /* Agent */ | |
| 1007 unsigned int fuel; /* Bunker/fuel */ | |
| 1008 unsigned int chandler; /* Chandler */ | |
| 1009 unsigned int stevedore; /* Stevedore */ | |
| 1010 unsigned int electrical; /* Electrical */ | |
| 1011 unsigned int water; /* Potable water */ | |
| 1012 unsigned int customs; /* Customs house */ | |
| 1013 unsigned int cartage; /* Cartage */ | |
| 1014 unsigned int crane; /* Crane(s) */ | |
| 1015 unsigned int lift; /* Lift(s) */ | |
| 1016 unsigned int medical; /* Medical facilities */ | |
| 1017 unsigned int navrepair; /* Navigation repair */ | |
| 1018 unsigned int provisions; /* Provisions */ | |
| 1019 unsigned int shiprepair; /* Ship repair */ | |
| 1020 unsigned int surveyor; /* Surveyor */ | |
| 1021 unsigned int steam; /* Steam */ | |
| 1022 unsigned int tugs; /* Tugs */ | |
| 1023 unsigned int solidwaste; /* Waste disposal (solid) */ | |
| 1024 unsigned int liquidwaste; /* Waste disposal (liquid) */ | |
| 1025 unsigned int hazardouswaste; /* Waste disposal (hazar
dous) */ | |
| 1026 unsigned int ballast; /* Reserved ballast exchange */ | |
| 1027 unsigned int additional; /* Additional services */ | |
| 1028 unsigned int regional1; /* Regional reserved 1 */ | |
| 1029 unsigned int regional2; /* Regional reserved 2 */ | |
| 1030 unsigned int future1; /* Reserved for future */ | |
| 1031 unsigned int future2; /* Reserved for future */ | |
| 1032 char berth_name[20+1]; /* Name of Berth */ | |
| 1033 signed int berth_lon; /* Longitude */ | |
| 1034 signed int berth_lat; /* Latitude */ | |
| 1035 } dac1fid20; | |
| 1036 /* IMO289 - Dangerous Cargo Indication */ | |
| 1037 struct { | |
| 1038 unsigned int unit; /* Unit of Quantity */ | |
| 1039 unsigned int amount; /* Amount of Cargo */ | |
| 1040 int ncargos; | |
| 1041 struct cargo_t { | |
| 1042 unsigned int code; /* Cargo code */ | |
| 1043 unsigned int subtype; /* Cargo subtype */ | |
| 1044 } cargos[28]; | |
| 1045 } dac1fid25; | |
| 1046 /* IMO289 - Route info (addressed) */ | |
| 1047 struct route_info dac1fid28; | |
| 1048 /* IMO289 - Text message (addressed) */ | |
| 1049 struct { | |
| 1050 unsigned int linkage; | |
| 1051 #define AIS_DAC1FID30_TEXT_MAX 154 /* 920 bits of six-bit, plus NUL */ | |
| 1052 char text[AIS_DAC1FID30_TEXT_MAX]; | |
| 1053 } dac1fid30; | |
| 1054 /* IMO289 & IMO236 - Tidal Window */ | |
| 1055 struct { | |
| 1056 unsigned int type; /* Message Type */ | |
| 1057 unsigned int repeat; /* Repeat Indicator */ | |
| 1058 unsigned int mmsi; /* Source MMSI */ | |
| 1059 unsigned int seqno; /* Sequence Number */ | |
| 1060 unsigned int dest_mmsi; /* Destination MMSI */ | |
| 1061 signed int retransmit; /* Retransmit flag */ | |
| 1062 unsigned int dac; /* DAC */ | |
| 1063 unsigned int fid; /* FID */ | |
| 1064 unsigned int month; /* Month */ | |
| 1065 unsigned int day; /* Day */ | |
| 1066 signed int ntidals; | |
| 1067 struct tidal_t { | |
| 1068 signed int lon; /* Longitude */ | |
| 1069 signed int lat; /* Latitude */ | |
| 1070 unsigned int from_hour; /* From UTC Hour */ | |
| 1071 unsigned int from_min; /* From UTC Minute */ | |
| 1072 unsigned int to_hour; /* To UTC Hour */ | |
| 1073 unsigned int to_min; /* To UTC Minute */ | |
| 1074 #define DAC1FID32_CDIR_NOT_AVAILABLE 360 | |
| 1075 unsigned int cdir; /* Current Dir. Predicted */ | |
| 1076 #define DAC1FID32_CSPEED_NOT_AVAILABLE 127 | |
| 1077 unsigned int cspeed; /* Current Speed Predicted */ | |
| 1078 } tidals[3]; | |
| 1079 } dac1fid32; | |
| 1080 }; | |
| 1081 } type6; | |
| 1082 /* Type 7 - Binary Acknowledge */ | |
| 1083 struct { | |
| 1084 unsigned int mmsi1; | |
| 1085 unsigned int mmsi2; | |
| 1086 unsigned int mmsi3; | |
| 1087 unsigned int mmsi4; | |
| 1088 /* spares ignored, they're only padding here */ | |
| 1089 } type7; | |
| 1090 /* Type 8 - Broadcast Binary Message */ | |
| 1091 struct { | |
| 1092 //unsigned int spare; spare bit(s) */ | |
| 1093 unsigned int dac; /* Designated Area Code */ | |
| 1094 unsigned int fid; /* Functional ID */ | |
| 1095 #define AIS_TYPE8_BINARY_MAX 952 /* 952 bits */ | |
| 1096 size_t bitcount; /* bit count of the data */ | |
| 1097 union { | |
| 1098 char bitdata[(AIS_TYPE8_BINARY_MAX + 7) / 8]; | |
| 1099 /* IMO236 - Fairway Closed */ | |
| 1100 struct { | |
| 1101 char reason[20+1]; /* Reason For Closing */ | |
| 1102 char closefrom[20+1]; /* Location Of Closing From */ | |
| 1103 char closeto[20+1]; /* Location of Closing To */ | |
| 1104 unsigned int radius; /* Radius extension */ | |
| 1105 #define AIS_DAC1FID13_RADIUS_NOT_AVAILABLE 10001 | |
| 1106 unsigned int extunit; /* Unit of extension */ | |
| 1107 #define AIS_DAC1FID13_EXTUNIT_NOT_AVAILABLE 0 | |
| 1108 unsigned int fday; /* From day (UTC) */ | |
| 1109 unsigned int fmonth; /* From month (UTC) */ | |
| 1110 unsigned int fhour; /* From hour (UTC) */ | |
| 1111 unsigned int fminute; /* From minute (UTC) */ | |
| 1112 unsigned int tday; /* To day (UTC) */ | |
| 1113 unsigned int tmonth; /* To month (UTC) */ | |
| 1114 unsigned int thour; /* To hour (UTC) */ | |
| 1115 unsigned int tminute; /* To minute (UTC) */ | |
| 1116 } dac1fid13; | |
| 1117 /* IMO236 - Extended ship and voyage data */ | |
| 1118 struct { | |
| 1119 unsigned int airdraught; /* Air Draught */ | |
| 1120 } dac1fid15; | |
| 1121 /* IMO289 - VTS-generated/Synthetic Targets */ | |
| 1122 struct { | |
| 1123 signed int ntargets; | |
| 1124 struct target_t { | |
| 1125 #define DAC1FID17_IDTYPE_MMSI 0 | |
| 1126 #define DAC1FID17_IDTYPE_IMO 1 | |
| 1127 #define DAC1FID17_IDTYPE_CALLSIGN 2 | |
| 1128 #define DAC1FID17_IDTYPE_OTHER 3 | |
| 1129 unsigned int idtype; /* Identifier type */ | |
| 1130 union target_id { /* Target identifier */ | |
| 1131 unsigned int mmsi; | |
| 1132 unsigned int imo; | |
| 1133 #define DAC1FID17_ID_LENGTH 7 | |
| 1134 char callsign[DAC1FID17_ID_LENGTH+1]; | |
| 1135 char other[DAC1FID17_ID_LENGTH+1]; | |
| 1136 } id; | |
| 1137 signed int lat; /* Latitude */ | |
| 1138 signed int lon; /* Longitude */ | |
| 1139 #define DAC1FID17_COURSE_NOT_AVAILABLE 360 | |
| 1140 unsigned int course; /* Course Over Ground */ | |
| 1141 unsigned int second; /* Time Stamp */ | |
| 1142 #define DAC1FID17_SPEED_NOT_AVAILABLE 255 | |
| 1143 unsigned int speed; /* Speed Over Ground */ | |
| 1144 } targets[4]; | |
| 1145 } dac1fid17; | |
| 1146 /* IMO 289 - Marine Traffic Signal */ | |
| 1147 struct { | |
| 1148 unsigned int linkage; /* Message Linkage ID */ | |
| 1149 char station[20+1]; /* Name of Signal Station */ | |
| 1150 signed int lon; /* Longitude */ | |
| 1151 signed int lat; /* Latitude */ | |
| 1152 unsigned int status; /* Status of Signal */ | |
| 1153 unsigned int signal; /* Signal In Service */ | |
| 1154 unsigned int hour; /* UTC hour */ | |
| 1155 unsigned int minute; /* UTC minute */ | |
| 1156 unsigned int nextsignal; /* Expected Next Signal */ | |
| 1157 } dac1fid19; | |
| 1158 /* IMO289 - Route info (broadcast) */ | |
| 1159 struct route_info dac1fid27; | |
| 1160 /* IMO289 - Text message (broadcast) */ | |
| 1161 struct { | |
| 1162 unsigned int linkage; | |
| 1163 #define AIS_DAC1FID29_TEXT_MAX 162 /* 920 bits of six-bit, plus NUL */ | |
| 1164 char text[AIS_DAC1FID29_TEXT_MAX]; | |
| 1165 } dac1fid29; | |
| 1166 /* IMO236 & IMO289 - Meteorological-Hydrological data */ | |
| 1167 struct { | |
| 1168 bool accuracy; /* position accuracy, <10m if true */ | |
| 1169 #define DAC1FID31_LATLON_SCALE 1000 | |
| 1170 int lon; /* longitude in minutes * .001 */ | |
| 1171 #define DAC1FID31_LON_NOT_AVAILABLE (181*60*DAC1FID31_LATLON_SCALE) | |
| 1172 int lat; /* longitude in minutes * .001 */ | |
| 1173 #define DAC1FID31_LAT_NOT_AVAILABLE (91*60*DAC1FID31_LATLON_SCALE) | |
| 1174 unsigned int day; /* UTC day */ | |
| 1175 unsigned int hour; /* UTC hour */ | |
| 1176 unsigned int minute; /* UTC minute */ | |
| 1177 unsigned int wspeed; /* average wind speed */ | |
| 1178 unsigned int wgust; /* wind gust */ | |
| 1179 #define DAC1FID31_WIND_HIGH 126 | |
| 1180 #define DAC1FID31_WIND_NOT_AVAILABLE 127 | |
| 1181 unsigned int wdir; /* wind direction */ | |
| 1182 unsigned int wgustdir; /* wind gust direction */ | |
| 1183 #define DAC1FID31_DIR_NOT_AVAILABLE 360 | |
| 1184 int airtemp; /* temperature, units 0.1C */ | |
| 1185 #define DAC1FID31_AIRTEMP_NOT_AVAILABLE -1084 | |
| 1186 unsigned int humidity; /* relative humidity, % */ | |
| 1187 #define DAC1FID31_HUMIDITY_NOT_AVAILABLE 101 | |
| 1188 int dewpoint; /* dew point, units 0.1C */ | |
| 1189 #define DAC1FID31_DEWPOINT_NOT_AVAILABLE 501 | |
| 1190 unsigned int pressure; /* air pressure, hpa */ | |
| 1191 #define DAC1FID31_PRESSURE_NOT_AVAILABLE 511 | |
| 1192 #define DAC1FID31_PRESSURE_HIGH 402 | |
| 1193 unsigned int pressuretend; /* tendency */ | |
| 1194 #define DAC1FID31_PRESSURETREND_NOT_AVAILABLE 3 | |
| 1195 bool visgreater; /* visibility greater than */ | |
| 1196 unsigned int visibility; /* units 0.1 nautical miles */ | |
| 1197 #define DAC1FID31_VISIBILITY_NOT_AVAILABLE 127 | |
| 1198 int waterlevel; /* decimeters or cm */ | |
| 1199 #define DAC1FID11_WATERLEVEL_NOT_AVAILABLE 4001 | |
| 1200 #define DAC1FID31_WATERLEVEL_NOT_AVAILABLE 40001 | |
| 1201 unsigned int leveltrend; /* water level trend code */ | |
| 1202 #define DAC1FID31_LEVELTREND_NOT_AVAILABLE 3 | |
| 1203 unsigned int cspeed; /* current speed in deciknots */ | |
| 1204 #define DAC1FID31_CSPEED_NOT_AVAILABLE 255 | |
| 1205 unsigned int cdir; /* current dir., degrees */ | |
| 1206 unsigned int cspeed2; /* current speed in deciknots */ | |
| 1207 unsigned int cdir2; /* current dir., degrees */ | |
| 1208 unsigned int cdepth2; /* measurement depth, 0.1m */ | |
| 1209 #define DAC1FID31_CDEPTH_NOT_AVAILABLE 301 | |
| 1210 unsigned int cspeed3; /* current speed in deciknots */ | |
| 1211 unsigned int cdir3; /* current dir., degrees */ | |
| 1212 unsigned int cdepth3; /* measurement depth, 0.1m */ | |
| 1213 unsigned int waveheight; /* in decimeters */ | |
| 1214 #define DAC1FID31_HEIGHT_NOT_AVAILABLE 31 | |
| 1215 unsigned int waveperiod; /* in seconds */ | |
| 1216 #define DAC1FID31_PERIOD_NOT_AVAILABLE 63 | |
| 1217 unsigned int wavedir; /* direction in degrees */ | |
| 1218 unsigned int swellheight; /* in decimeters */ | |
| 1219 unsigned int swellperiod; /* in seconds */ | |
| 1220 unsigned int swelldir; /* direction in degrees */ | |
| 1221 unsigned int seastate; /* Beaufort scale, 0-12 */ | |
| 1222 #define DAC1FID31_SEASTATE_NOT_AVAILABLE 15 | |
| 1223 int watertemp; /* units 0.1deg Celsius */ | |
| 1224 #define DAC1FID31_PRECIPTYPE_NOT_AVAILABLE 7 | |
| 1225 unsigned int preciptype; /* 0-7, enumerated */ | |
| 1226 unsigned int salinity; /* units of 0.1% */ | |
| 1227 #define DAC1FID31_SALINITY_NOT_AVAILABLE 510 | |
| 1228 bool ice; /* is there sea ice? */ | |
| 1229 } dac1fid31; | |
| 1230 }; | |
| 1231 } type8; | |
| 1232 /* Type 9 - Standard SAR Aircraft Position Report */ | |
| 1233 struct { | |
| 1234 unsigned int alt; /* altitude in meters */ | |
| 1235 #define AIS_ALT_NOT_AVAILABLE 4095 | |
| 1236 #define AIS_ALT_HIGH 4094 /* 4094 meters or higher */ | |
| 1237 unsigned int speed; /* speed over ground in deciknots */ | |
| 1238 #define AIS_SAR_SPEED_NOT_AVAILABLE 1023 | |
| 1239 #define AIS_SAR_FAST_MOVER 1022 | |
| 1240 bool accuracy; /* position accuracy */ | |
| 1241 int lon; /* longitude */ | |
| 1242 int lat; /* latitude */ | |
| 1243 unsigned int course; /* course over ground */ | |
| 1244 unsigned int second; /* seconds of UTC timestamp */ | |
| 1245 unsigned int regional; /* regional reserved */ | |
| 1246 unsigned int dte; /* data terminal enable */ | |
| 1247 //unsigned int spare; spare bits */ | |
| 1248 bool assigned; /* assigned-mode flag */ | |
| 1249 bool raim; /* RAIM flag */ | |
| 1250 unsigned int radio; /* radio status bits */ | |
| 1251 } type9; | |
| 1252 /* Type 10 - UTC/Date Inquiry */ | |
| 1253 struct { | |
| 1254 //unsigned int spare; | |
| 1255 unsigned int dest_mmsi; /* destination MMSI */ | |
| 1256 //unsigned int spare2; | |
| 1257 } type10; | |
| 1258 /* Type 12 - Safety-Related Message */ | |
| 1259 struct { | |
| 1260 unsigned int seqno; /* sequence number */ | |
| 1261 unsigned int dest_mmsi; /* destination MMSI */ | |
| 1262 bool retransmit; /* retransmit flag */ | |
| 1263 //unsigned int spare; spare bit(s) */ | |
| 1264 #define AIS_TYPE12_TEXT_MAX 157 /* 936 bits of six-bit, plus NUL */ | |
| 1265 char text[AIS_TYPE12_TEXT_MAX]; | |
| 1266 } type12; | |
| 1267 /* Type 14 - Safety-Related Broadcast Message */ | |
| 1268 struct { | |
| 1269 //unsigned int spare; spare bit(s) */ | |
| 1270 #define AIS_TYPE14_TEXT_MAX 161 /* 952 bits of six-bit, plus NUL */ | |
| 1271 char text[AIS_TYPE14_TEXT_MAX]; | |
| 1272 } type14; | |
| 1273 /* Type 15 - Interrogation */ | |
| 1274 struct { | |
| 1275 //unsigned int spare; spare bit(s) */ | |
| 1276 unsigned int mmsi1; | |
| 1277 unsigned int type1_1; | |
| 1278 unsigned int offset1_1; | |
| 1279 //unsigned int spare2; spare bit(s) */ | |
| 1280 unsigned int type1_2; | |
| 1281 unsigned int offset1_2; | |
| 1282 //unsigned int spare3; spare bit(s) */ | |
| 1283 unsigned int mmsi2; | |
| 1284 unsigned int type2_1; | |
| 1285 unsigned int offset2_1; | |
| 1286 //unsigned int spare4; spare bit(s) */ | |
| 1287 } type15; | |
| 1288 /* Type 16 - Assigned Mode Command */ | |
| 1289 struct { | |
| 1290 //unsigned int spare; spare bit(s) */ | |
| 1291 unsigned int mmsi1; | |
| 1292 unsigned int offset1; | |
| 1293 unsigned int increment1; | |
| 1294 unsigned int mmsi2; | |
| 1295 unsigned int offset2; | |
| 1296 unsigned int increment2; | |
| 1297 } type16; | |
| 1298 /* Type 17 - GNSS Broadcast Binary Message */ | |
| 1299 struct { | |
| 1300 //unsigned int spare; spare bit(s) */ | |
| 1301 #define AIS_GNSS_LATLON_SCALE 600.0 | |
| 1302 int lon; /* longitude */ | |
| 1303 int lat; /* latitude */ | |
| 1304 //unsigned int spare2; spare bit(s) */ | |
| 1305 #define AIS_TYPE17_BINARY_MAX 736 /* 920 bits */ | |
| 1306 size_t bitcount; /* bit count of the data */ | |
| 1307 char bitdata[(AIS_TYPE17_BINARY_MAX + 7) / 8]; | |
| 1308 } type17; | |
| 1309 /* Type 18 - Standard Class B CS Position Report */ | |
| 1310 struct { | |
| 1311 unsigned int reserved; /* altitude in meters */ | |
| 1312 unsigned int speed; /* speed over ground in deciknots */ | |
| 1313 bool accuracy; /* position accuracy */ | |
| 1314 int lon; /* longitude */ | |
| 1315 #define AIS_GNS_LON_NOT_AVAILABLE 0x1a838 | |
| 1316 int lat; /* latitude */ | |
| 1317 #define AIS_GNS_LAT_NOT_AVAILABLE 0xd548 | |
| 1318 unsigned int course; /* course over ground */ | |
| 1319 unsigned int heading; /* true heading */ | |
| 1320 unsigned int second; /* seconds of UTC timestamp */ | |
| 1321 unsigned int regional; /* regional reserved */ | |
| 1322 bool cs; /* carrier sense unit flag */ | |
| 1323 bool display; /* unit has attached display? */ | |
| 1324 bool dsc; /* unit attached to radio with DSC? */ | |
| 1325 bool band; /* unit can switch frequency bands? */ | |
| 1326 bool msg22; /* can accept Message 22 management? */ | |
| 1327 bool assigned; /* assigned-mode flag */ | |
| 1328 bool raim; /* RAIM flag */ | |
| 1329 unsigned int radio; /* radio status bits */ | |
| 1330 } type18; | |
| 1331 /* Type 19 - Extended Class B CS Position Report */ | |
| 1332 struct { | |
| 1333 unsigned int reserved; /* altitude in meters */ | |
| 1334 unsigned int speed; /* speed over ground in deciknots */ | |
| 1335 bool accuracy; /* position accuracy */ | |
| 1336 int lon; /* longitude */ | |
| 1337 int lat; /* latitude */ | |
| 1338 unsigned int course; /* course over ground */ | |
| 1339 unsigned int heading; /* true heading */ | |
| 1340 unsigned int second; /* seconds of UTC timestamp */ | |
| 1341 unsigned int regional; /* regional reserved */ | |
| 1342 char shipname[AIS_SHIPNAME_MAXLEN+1]; /* ship name */ | |
| 1343 unsigned int shiptype; /* ship type code */ | |
| 1344 unsigned int to_bow; /* dimension to bow */ | |
| 1345 unsigned int to_stern; /* dimension to stern */ | |
| 1346 unsigned int to_port; /* dimension to port */ | |
| 1347 unsigned int to_starboard; /* dimension to starboard */ | |
| 1348 unsigned int epfd; /* type of position fix deviuce */ | |
| 1349 bool raim; /* RAIM flag */ | |
| 1350 unsigned int dte; /* date terminal enable */ | |
| 1351 bool assigned; /* assigned-mode flag */ | |
| 1352 //unsigned int spare; spare bits */ | |
| 1353 } type19; | |
| 1354 /* Type 20 - Data Link Management Message */ | |
| 1355 struct { | |
| 1356 //unsigned int spare; spare bit(s) */ | |
| 1357 unsigned int offset1; /* TDMA slot offset */ | |
| 1358 unsigned int number1; /* number of xlots to allocate */ | |
| 1359 unsigned int timeout1; /* allocation timeout */ | |
| 1360 unsigned int increment1; /* repeat increment */ | |
| 1361 unsigned int offset2; /* TDMA slot offset */ | |
| 1362 unsigned int number2; /* number of xlots to allocate */ | |
| 1363 unsigned int timeout2; /* allocation timeout */ | |
| 1364 unsigned int increment2; /* repeat increment */ | |
| 1365 unsigned int offset3; /* TDMA slot offset */ | |
| 1366 unsigned int number3; /* number of xlots to allocate */ | |
| 1367 unsigned int timeout3; /* allocation timeout */ | |
| 1368 unsigned int increment3; /* repeat increment */ | |
| 1369 unsigned int offset4; /* TDMA slot offset */ | |
| 1370 unsigned int number4; /* number of xlots to allocate */ | |
| 1371 unsigned int timeout4; /* allocation timeout */ | |
| 1372 unsigned int increment4; /* repeat increment */ | |
| 1373 } type20; | |
| 1374 /* Type 21 - Aids to Navigation Report */ | |
| 1375 struct { | |
| 1376 unsigned int aid_type; /* aid type */ | |
| 1377 char name[35]; /* name of aid to navigation */ | |
| 1378 bool accuracy; /* position accuracy */ | |
| 1379 int lon; /* longitude */ | |
| 1380 int lat; /* latitude */ | |
| 1381 unsigned int to_bow; /* dimension to bow */ | |
| 1382 unsigned int to_stern; /* dimension to stern */ | |
| 1383 unsigned int to_port; /* dimension to port */ | |
| 1384 unsigned int to_starboard; /* dimension to starboard */ | |
| 1385 unsigned int epfd; /* type of EPFD */ | |
| 1386 unsigned int second; /* second of UTC timestamp */ | |
| 1387 bool off_position; /* off-position indicator */ | |
| 1388 unsigned int regional; /* regional reserved field */ | |
| 1389 bool raim; /* RAIM flag */ | |
| 1390 bool virtual_aid; /* is virtual station? */ | |
| 1391 bool assigned; /* assigned-mode flag */ | |
| 1392 //unsigned int spare; unused */ | |
| 1393 } type21; | |
| 1394 /* Type 22 - Channel Management */ | |
| 1395 struct { | |
| 1396 //unsigned int spare; spare bit(s) */ | |
| 1397 unsigned int channel_a; /* Channel A number */ | |
| 1398 unsigned int channel_b; /* Channel B number */ | |
| 1399 unsigned int txrx; /* transmit/receive mode */ | |
| 1400 bool power; /* high-power flag */ | |
| 1401 #define AIS_CHANNEL_LATLON_SCALE 600.0 | |
| 1402 union { | |
| 1403 struct { | |
| 1404 int ne_lon; /* NE corner longitude */ | |
| 1405 int ne_lat; /* NE corner latitude */ | |
| 1406 int sw_lon; /* SW corner longitude */ | |
| 1407 int sw_lat; /* SW corner latitude */ | |
| 1408 } area; | |
| 1409 struct { | |
| 1410 unsigned int dest1; /* addressed station MMSI 1 */ | |
| 1411 unsigned int dest2; /* addressed station MMSI 2 */ | |
| 1412 } mmsi; | |
| 1413 }; | |
| 1414 bool addressed; /* addressed vs. broadast flag */ | |
| 1415 bool band_a; /* fix 1.5kHz band for channel A */ | |
| 1416 bool band_b; /* fix 1.5kHz band for channel B */ | |
| 1417 unsigned int zonesize; /* size of transitional zone */ | |
| 1418 } type22; | |
| 1419 /* Type 23 - Group Assignment Command */ | |
| 1420 struct { | |
| 1421 int ne_lon; /* NE corner longitude */ | |
| 1422 int ne_lat; /* NE corner latitude */ | |
| 1423 int sw_lon; /* SW corner longitude */ | |
| 1424 int sw_lat; /* SW corner latitude */ | |
| 1425 //unsigned int spare; spare bit(s) */ | |
| 1426 unsigned int stationtype; /* station type code */ | |
| 1427 unsigned int shiptype; /* ship type code */ | |
| 1428 //unsigned int spare2; spare bit(s) */ | |
| 1429 unsigned int txrx; /* transmit-enable code */ | |
| 1430 unsigned int interval; /* report interval */ | |
| 1431 unsigned int quiet; /* quiet time */ | |
| 1432 //unsigned int spare3; spare bit(s) */ | |
| 1433 } type23; | |
| 1434 /* Type 24 - Class B CS Static Data Report */ | |
| 1435 struct { | |
| 1436 char shipname[AIS_SHIPNAME_MAXLEN+1]; /* vessel name */ | |
| 1437 unsigned int shiptype; /* ship type code */ | |
| 1438 char vendorid[8]; /* vendor ID */ | |
| 1439 char callsign[8]; /* callsign */ | |
| 1440 union { | |
| 1441 unsigned int mothership_mmsi; /* MMSI of main vessel */ | |
| 1442 struct { | |
| 1443 unsigned int to_bow; /* dimension to bow */ | |
| 1444 unsigned int to_stern; /* dimension to stern */ | |
| 1445 unsigned int to_port; /* dimension to port */ | |
| 1446 unsigned int to_starboard; /* dimension to starboard */ | |
| 1447 } dim; | |
| 1448 }; | |
| 1449 } type24; | |
| 1450 /* Type 25 - Addressed Binary Message */ | |
| 1451 struct { | |
| 1452 bool addressed; /* addressed-vs.broadcast flag */ | |
| 1453 bool structured; /* structured-binary flag */ | |
| 1454 unsigned int dest_mmsi; /* destination MMSI */ | |
| 1455 unsigned int app_id; /* Application ID */ | |
| 1456 #define AIS_TYPE25_BINARY_MAX 128 /* Up to 128 bits */ | |
| 1457 size_t bitcount; /* bit count of the data */ | |
| 1458 char bitdata[(AIS_TYPE25_BINARY_MAX + 7) / 8]; | |
| 1459 } type25; | |
| 1460 /* Type 26 - Addressed Binary Message */ | |
| 1461 struct { | |
| 1462 bool addressed; /* addressed-vs.broadcast flag */ | |
| 1463 bool structured; /* structured-binary flag */ | |
| 1464 unsigned int dest_mmsi; /* destination MMSI */ | |
| 1465 unsigned int app_id; /* Application ID */ | |
| 1466 #define AIS_TYPE26_BINARY_MAX 1004 /* Up to 128 bits */ | |
| 1467 size_t bitcount; /* bit count of the data */ | |
| 1468 char bitdata[(AIS_TYPE26_BINARY_MAX + 7) / 8]; | |
| 1469 unsigned int radio; /* radio status bits */ | |
| 1470 } type26; | |
| 1471 /* Type 27 - Long Range AIS Broadcast message */ | |
| 1472 struct { | |
| 1473 bool accuracy; /* position accuracy */ | |
| 1474 bool raim; /* RAIM flag */ | |
| 1475 unsigned int status; /* navigation status */ | |
| 1476 #define AIS_LONGRANGE_LATLON_SCALE 600.0 | |
| 1477 int lon; /* longitude */ | |
| 1478 #define AIS_LONGRANGE_LON_NOT_AVAILABLE 0x1a838 | |
| 1479 int lat; /* latitude */ | |
| 1480 #define AIS_LONGRANGE_LAT_NOT_AVAILABLE 0xd548 | |
| 1481 unsigned int speed; /* speed over ground in deciknots */ | |
| 1482 #define AIS_LONGRANGE_SPEED_NOT_AVAILABLE 63 | |
| 1483 unsigned int course; /* course over ground */ | |
| 1484 #define AIS_LONGRANGE_COURSE_NOT_AVAILABLE 511 | |
| 1485 bool gnss; /* are we reporting GNSS position? */ | |
| 1486 } type27; | |
| 1487 }; | |
| 1488 }; | |
| 1489 | |
| 1490 struct attitude_t { | |
| 1491 double heading; | |
| 1492 double pitch; | |
| 1493 double roll; | |
| 1494 double yaw; | |
| 1495 double dip; | |
| 1496 double mag_len; /* unitvector sqrt(x^2 + y^2 +z^2) */ | |
| 1497 double mag_x; | |
| 1498 double mag_y; | |
| 1499 double mag_z; | |
| 1500 double acc_len; /* unitvector sqrt(x^2 + y^2 +z^2) */ | |
| 1501 double acc_x; | |
| 1502 double acc_y; | |
| 1503 double acc_z; | |
| 1504 double gyro_x; | |
| 1505 double gyro_y; | |
| 1506 double temp; | |
| 1507 double depth; | |
| 1508 /* compass status -- TrueNorth (and any similar) devices only */ | |
| 1509 char mag_st; | |
| 1510 char pitch_st; | |
| 1511 char roll_st; | |
| 1512 char yaw_st; | |
| 1513 }; | |
| 1514 | |
| 1515 struct dop_t { | |
| 1516 /* Dilution of precision factors */ | |
| 1517 double xdop, ydop, pdop, hdop, vdop, tdop, gdop; | |
| 1518 }; | |
| 1519 | |
| 1520 struct rawdata_t { | |
| 1521 /* raw measurement data */ | |
| 1522 double codephase[MAXCHANNELS]; /* meters */ | |
| 1523 double carrierphase[MAXCHANNELS]; /* meters */ | |
| 1524 double pseudorange[MAXCHANNELS]; /* meters */ | |
| 1525 double deltarange[MAXCHANNELS]; /* meters/sec */ | |
| 1526 double doppler[MAXCHANNELS]; /* Hz */ | |
| 1527 double mtime[MAXCHANNELS]; /* sec */ | |
| 1528 unsigned satstat[MAXCHANNELS]; /* tracking status */ | |
| 1529 #define SAT_ACQUIRED 0x01 /* satellite acquired */ | |
| 1530 #define SAT_CODE_TRACK 0x02 /* code-tracking loop acquired */ | |
| 1531 #define SAT_CARR_TRACK 0x04 /* carrier-tracking loop acquired */ | |
| 1532 #define SAT_DATA_SYNC 0x08 /* data-bit synchronization done */ | |
| 1533 #define SAT_FRAME_SYNC 0x10 /* frame synchronization done */ | |
| 1534 #define SAT_EPHEMERIS 0x20 /* ephemeris collected */ | |
| 1535 #define SAT_FIX_USED 0x40 /* used for position fix */ | |
| 1536 }; | |
| 1537 | |
| 1538 struct version_t { | |
| 1539 char release[64]; /* external version */ | |
| 1540 char rev[64]; /* internal revision ID */ | |
| 1541 int proto_major, proto_minor; /* API major and minor versions */ | |
| 1542 char remote[GPS_PATH_MAX]; /* could be from a remote device */ | |
| 1543 }; | |
| 1544 | |
| 1545 struct devconfig_t { | |
| 1546 char path[GPS_PATH_MAX]; | |
| 1547 int flags; | |
| 1548 #define SEEN_GPS 0x01 | |
| 1549 #define SEEN_RTCM2 0x02 | |
| 1550 #define SEEN_RTCM3 0x04 | |
| 1551 #define SEEN_AIS 0x08 | |
| 1552 char driver[64]; | |
| 1553 char subtype[64]; | |
| 1554 double activated; | |
| 1555 unsigned int baudrate, stopbits; /* RS232 link parameters */ | |
| 1556 char parity; /* 'N', 'O', or 'E' */ | |
| 1557 double cycle, mincycle; /* refresh cycle time in seconds */ | |
| 1558 int driver_mode; /* is driver in native mode or not? */ | |
| 1559 }; | |
| 1560 | |
| 1561 struct policy_t { | |
| 1562 bool watcher; /* is watcher mode on? */ | |
| 1563 bool json; /* requesting JSON? */ | |
| 1564 bool nmea; /* requesting dumping as NMEA? */ | |
| 1565 int raw; /* requesting raw data? */ | |
| 1566 bool scaled; /* requesting report scaling? */ | |
| 1567 bool timing; /* requesting timing info */ | |
| 1568 int loglevel; /* requested log level of messages */ | |
| 1569 char devpath[GPS_PATH_MAX]; /* specific device to watch */ | |
| 1570 char remote[GPS_PATH_MAX]; /* ...if this was passthrough */ | |
| 1571 }; | |
| 1572 | |
| 1573 /* | |
| 1574 * Someday we may support Windows, under which socket_t is a separate type. | |
| 1575 * In the meantime, having a typedef for this semantic kind is no bad thing, | |
| 1576 * as it makes clearer what some declarations are doing without breaking | |
| 1577 * binary compatibility. | |
| 1578 */ | |
| 1579 typedef int socket_t; | |
| 1580 | |
| 1581 /* mode flags for setting streaming policy */ | |
| 1582 #define WATCH_ENABLE 0x000001u /* enable streaming */ | |
| 1583 #define WATCH_DISABLE 0x000002u /* disable watching */ | |
| 1584 #define WATCH_JSON 0x000010u /* JSON output */ | |
| 1585 #define WATCH_NMEA 0x000020u /* output in NMEA */ | |
| 1586 #define WATCH_RARE 0x000040u /* output of packets in hex */ | |
| 1587 #define WATCH_RAW 0x000080u /* output of raw packets */ | |
| 1588 #define WATCH_SCALED 0x000100u /* scale output to floats */ | |
| 1589 #define WATCH_TIMING 0x000200u /* timing information */ | |
| 1590 #define WATCH_DEVICE 0x000800u /* watch specific device */ | |
| 1591 #define WATCH_NEWSTYLE 0x010000u /* force JSON streaming */ | |
| 1592 #define WATCH_OLDSTYLE 0x020000u /* force old-style streaming */ | |
| 1593 | |
| 1594 /* | |
| 1595 * Main structure that includes all previous substructures | |
| 1596 */ | |
| 1597 | |
| 1598 struct gps_data_t { | |
| 1599 gps_mask_t set; /* has field been set since this was last cleared? */ | |
| 1600 #define ONLINE_SET (1llu<<1) | |
| 1601 #define TIME_SET (1llu<<2) | |
| 1602 #define TIMERR_SET (1llu<<3) | |
| 1603 #define LATLON_SET (1llu<<4) | |
| 1604 #define ALTITUDE_SET (1llu<<5) | |
| 1605 #define SPEED_SET (1llu<<6) | |
| 1606 #define TRACK_SET (1llu<<7) | |
| 1607 #define CLIMB_SET (1llu<<8) | |
| 1608 #define STATUS_SET (1llu<<9) | |
| 1609 #define MODE_SET (1llu<<10) | |
| 1610 #define DOP_SET (1llu<<11) | |
| 1611 #define HERR_SET (1llu<<12) | |
| 1612 #define VERR_SET (1llu<<13) | |
| 1613 #define ATTITUDE_SET (1llu<<14) | |
| 1614 #define SATELLITE_SET (1llu<<15) | |
| 1615 #define SPEEDERR_SET (1llu<<16) | |
| 1616 #define TRACKERR_SET (1llu<<17) | |
| 1617 #define CLIMBERR_SET (1llu<<18) | |
| 1618 #define DEVICE_SET (1llu<<19) | |
| 1619 #define DEVICELIST_SET (1llu<<20) | |
| 1620 #define DEVICEID_SET (1llu<<21) | |
| 1621 #define RTCM2_SET (1llu<<22) | |
| 1622 #define RTCM3_SET (1llu<<23) | |
| 1623 #define AIS_SET (1llu<<24) | |
| 1624 #define PACKET_SET (1llu<<25) | |
| 1625 #define SUBFRAME_SET (1llu<<26) | |
| 1626 #define GST_SET (1llu<<27) | |
| 1627 #define VERSION_SET (1llu<<28) | |
| 1628 #define POLICY_SET (1llu<<29) | |
| 1629 #define LOGMESSAGE_SET (1llu<<30) | |
| 1630 #define ERROR_SET (1llu<<31) | |
| 1631 #define SET_HIGH_BIT 31 | |
| 1632 timestamp_t online; /* NZ if GPS is on line, 0 if not. | |
| 1633 * | |
| 1634 * Note: gpsd clears this time when sentences | |
| 1635 * fail to show up within the GPS's normal | |
| 1636 * send cycle time. If the host-to-GPS | |
| 1637 * link is lossy enough to drop entire | |
| 1638 * sentences, this field will be | |
| 1639 * prone to false zero values. | |
| 1640 */ | |
| 1641 | |
| 1642 #ifndef USE_QT | |
| 1643 socket_t gps_fd; /* socket or file descriptor to GPS */ | |
| 1644 #else | |
| 1645 void* gps_fd; | |
| 1646 #endif | |
| 1647 struct gps_fix_t fix; /* accumulated PVT data */ | |
| 1648 | |
| 1649 double separation; /* Geoidal separation, MSL - WGS84 (Meters) */ | |
| 1650 | |
| 1651 /* GPS status -- always valid */ | |
| 1652 int status; /* Do we have a fix? */ | |
| 1653 #define STATUS_NO_FIX 0 /* no */ | |
| 1654 #define STATUS_FIX 1 /* yes, without DGPS */ | |
| 1655 #define STATUS_DGPS_FIX 2 /* yes, with DGPS */ | |
| 1656 | |
| 1657 /* precision of fix -- valid if satellites_used > 0 */ | |
| 1658 int satellites_used; /* Number of satellites used in solution */ | |
| 1659 int used[MAXCHANNELS]; /* PRNs of satellites used in solution */ | |
| 1660 struct dop_t dop; | |
| 1661 | |
| 1662 /* redundant with the estimate elements in the fix structure */ | |
| 1663 double epe; /* spherical position error, 95% confidence (meters) */ | |
| 1664 | |
| 1665 /* satellite status -- valid when satellites_visible > 0 */ | |
| 1666 timestamp_t skyview_time; /* skyview timestamp */ | |
| 1667 int satellites_visible; /* # of satellites in view */ | |
| 1668 int PRN[MAXCHANNELS]; /* PRNs of satellite */ | |
| 1669 int elevation[MAXCHANNELS]; /* elevation of satellite */ | |
| 1670 int azimuth[MAXCHANNELS]; /* azimuth */ | |
| 1671 double ss[MAXCHANNELS]; /* signal-to-noise ratio (dB) */ | |
| 1672 | |
| 1673 struct devconfig_t dev; /* device that shipped last update */ | |
| 1674 | |
| 1675 struct policy_t policy; /* our listening policy */ | |
| 1676 | |
| 1677 /* should be moved to privdata sometday */ | |
| 1678 char tag[MAXTAGLEN+1]; /* tag of last sentence processed */ | |
| 1679 | |
| 1680 /* pack things never reported together to reduce structure size */ | |
| 1681 #define UNION_SET (RTCM2_SET|RTCM3_SET|SUBFRAME_SET|AIS_SET|ATTITUDE_SET|V
ERSION_SET|DEVICELIST_SET|LOGMESSAGE_SET|ERROR_SET|GST_SET|VERSION_SET) | |
| 1682 union { | |
| 1683 /* unusual forms of sensor data that might come up the pipe */ | |
| 1684 struct rtcm2_t rtcm2; | |
| 1685 struct rtcm3_t rtcm3; | |
| 1686 struct subframe_t subframe; | |
| 1687 struct ais_t ais; | |
| 1688 struct attitude_t attitude; | |
| 1689 struct rawdata_t raw; | |
| 1690 struct gst_t gst; | |
| 1691 /* "artificial" structures for various protocol responses */ | |
| 1692 struct version_t version; | |
| 1693 struct { | |
| 1694 timestamp_t time; | |
| 1695 int ndevices; | |
| 1696 struct devconfig_t list[MAXUSERDEVS]; | |
| 1697 } devices; | |
| 1698 char error[256]; | |
| 1699 }; | |
| 1700 | |
| 1701 /* Private data - client code must not set this */ | |
| 1702 void *privdata; | |
| 1703 }; | |
| 1704 | |
| 1705 extern int gps_open(/*@null@*/const char *, /*@null@*/const char *, | |
| 1706 /*@out@*/struct gps_data_t *); | |
| 1707 extern int gps_close(struct gps_data_t *); | |
| 1708 extern int gps_send(struct gps_data_t *, const char *, ... ); | |
| 1709 extern int gps_read(/*@out@*/struct gps_data_t *); | |
| 1710 extern int gps_unpack(char *, struct gps_data_t *); | |
| 1711 extern bool gps_waiting(const struct gps_data_t *, int); | |
| 1712 extern int gps_stream(struct gps_data_t *, unsigned int, /*@null@*/void *); | |
| 1713 extern const char /*@observer@*/ *gps_data(const struct gps_data_t *); | |
| 1714 extern const char /*@observer@*/ *gps_errstr(const int); | |
| 1715 | |
| 1716 extern int gps_sock_open(/*@null@*/const char *, /*@null@*/const char *, | |
| 1717 /*@out@*/struct gps_data_t *); | |
| 1718 extern int gps_sock_read(/*@out@*/struct gps_data_t *); | |
| 1719 extern int gps_sock_close(struct gps_data_t *); | |
| 1720 extern int gps_sock_send(struct gps_data_t *, const char *); | |
| 1721 extern int gps_shm_open(/*@out@*/struct gps_data_t *); | |
| 1722 extern int gps_shm_read(struct gps_data_t *); | |
| 1723 extern bool gps_sock_waiting(const struct gps_data_t *, int); | |
| 1724 extern int gps_sock_stream(struct gps_data_t *, unsigned int, /*@null@*/void *); | |
| 1725 extern const char /*@observer@*/ *gps_sock_data(const struct gps_data_t *); | |
| 1726 extern void gps_shm_close(struct gps_data_t *); | |
| 1727 | |
| 1728 extern void libgps_trace(int errlevel, const char *, ...); | |
| 1729 | |
| 1730 /* dependencies on struct gpsdata_t end hrere */ | |
| 1731 | |
| 1732 extern void gps_clear_fix(/*@ out @*/struct gps_fix_t *); | |
| 1733 extern void gps_clear_dop( /*@out@*/ struct dop_t *); | |
| 1734 extern void gps_merge_fix(/*@ out @*/struct gps_fix_t *, | |
| 1735 gps_mask_t, | |
| 1736 /*@ in @*/struct gps_fix_t *); | |
| 1737 extern void gps_enable_debug(int, FILE *); | |
| 1738 extern /*@observer@*/const char *gps_maskdump(gps_mask_t); | |
| 1739 | |
| 1740 extern double safe_atof(const char *); | |
| 1741 extern time_t mkgmtime(register struct tm *); | |
| 1742 extern timestamp_t timestamp(void); | |
| 1743 extern timestamp_t iso8601_to_unix(char *); | |
| 1744 extern /*@observer@*/char *unix_to_iso8601(timestamp_t t, /*@ out @*/char[], siz
e_t len); | |
| 1745 extern double earth_distance(double, double, double, double); | |
| 1746 extern double earth_distance_and_bearings(double, double, double, double, | |
| 1747 /*@null@*//*@out@*/double *, | |
| 1748 /*@null@*//*@out@*/double *); | |
| 1749 extern double wgs84_separation(double, double); | |
| 1750 | |
| 1751 /* some multipliers for interpreting GPS output */ | |
| 1752 #define METERS_TO_FEET 3.2808399 /* Meters to U.S./British feet */ | |
| 1753 #define METERS_TO_MILES 0.00062137119 /* Meters to miles */ | |
| 1754 #define KNOTS_TO_MPH 1.1507794 /* Knots to miles per hour */ | |
| 1755 #define KNOTS_TO_KPH 1.852 /* Knots to kilometers per hour */ | |
| 1756 #define KNOTS_TO_MPS 0.51444444 /* Knots to meters per second */ | |
| 1757 #define MPS_TO_KPH 3.6 /* Meters per second to klicks/hr */ | |
| 1758 #define MPS_TO_MPH 2.2369363 /* Meters/second to miles per hour */ | |
| 1759 #define MPS_TO_KNOTS 1.9438445 /* Meters per second to knots */ | |
| 1760 /* miles and knots are both the international standard versions of the units */ | |
| 1761 | |
| 1762 /* angle conversion multipliers */ | |
| 1763 #define GPS_PI 3.1415926535897932384626433832795029 | |
| 1764 #define RAD_2_DEG 57.2957795130823208767981548141051703 | |
| 1765 #define DEG_2_RAD 0.0174532925199432957692369076848861271 | |
| 1766 | |
| 1767 /* geodetic constants */ | |
| 1768 #define WGS84A 6378137 /* equatorial radius */ | |
| 1769 #define WGS84F 298.257223563 /* flattening */ | |
| 1770 #define WGS84B 6356752.3142 /* polar radius */ | |
| 1771 | |
| 1772 /* netlib_connectsock() errno return values */ | |
| 1773 #define NL_NOSERVICE -1 /* can't get service entry */ | |
| 1774 #define NL_NOHOST -2 /* can't get host entry */ | |
| 1775 #define NL_NOPROTO -3 /* can't get protocol entry */ | |
| 1776 #define NL_NOSOCK -4 /* can't create socket */ | |
| 1777 #define NL_NOSOCKOPT -5 /* error SETSOCKOPT SO_REUSEADDR */ | |
| 1778 #define NL_NOCONNECT -6 /* can't connect to host/socket pair */ | |
| 1779 #define SHM_NOSHARED -7 /* shared-memory segment not available */ | |
| 1780 #define SHM_NOATTACH -8 /* shared-memory attach failed */ | |
| 1781 | |
| 1782 #define DEFAULT_GPSD_PORT "2947" /* IANA assignment */ | |
| 1783 #define DEFAULT_RTCM_PORT "2101" /* IANA assignment */ | |
| 1784 | |
| 1785 /* special host values for non-socket exports */ | |
| 1786 #define GPSD_SHARED_MEMORY "shared memory" | |
| 1787 | |
| 1788 /* | |
| 1789 * Platform-specific declarations | |
| 1790 */ | |
| 1791 | |
| 1792 #ifdef _WIN32 | |
| 1793 #define strtok_r(s,d,p) strtok_s(s,d,p) | |
| 1794 #endif | |
| 1795 | |
| 1796 /* Some libc's don't have strlcat/strlcpy. Local copies are provided */ | |
| 1797 #ifndef HAVE_STRLCAT | |
| 1798 size_t strlcat(/*@out@*/char *dst, /*@in@*/const char *src, size_t size); | |
| 1799 #endif | |
| 1800 #ifndef HAVE_STRLCPY | |
| 1801 size_t strlcpy(/*@out@*/char *dst, /*@in@*/const char *src, size_t size); | |
| 1802 #endif | |
| 1803 | |
| 1804 #ifdef __cplusplus | |
| 1805 } /* End of the 'extern "C"' block */ | |
| 1806 #endif | |
| 1807 | |
| 1808 /* gps.h ends here */ | |
| 1809 #endif /* _GPSD_GPS_H_ */ | |
| OLD | NEW |