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