| OLD | NEW |
| (Empty) |
| 1 /* $Id$ */ | |
| 2 #ifndef _GPSD_GPS_H_ | |
| 3 #define _GPSD_GPS_H_ | |
| 4 | |
| 5 /* gps.h -- interface of the libgps library */ | |
| 6 | |
| 7 #ifdef __cplusplus | |
| 8 extern "C" { | |
| 9 #endif | |
| 10 | |
| 11 #include <sys/types.h> | |
| 12 #include <sys/time.h> | |
| 13 #include <stdbool.h> | |
| 14 #include <inttypes.h> /* stdint.h would be smaller but not all have it */ | |
| 15 #include <limits.h> | |
| 16 #include <time.h> | |
| 17 #include <signal.h> | |
| 18 #ifndef S_SPLINT_S | |
| 19 #include <pthread.h> /* pacifies OpenBSD's compiler */ | |
| 20 #endif | |
| 21 | |
| 22 #define MAXTAGLEN 8 /* maximum length of sentence tag name */ | |
| 23 #define MAXCHANNELS 20 /* maximum GPS channels (*not* satellites!) */ | |
| 24 #define SIRF_CHANNELS 12 /* max channels allowed in SiRF format */ | |
| 25 #define GPS_PRNMAX 32 /* above this number are SBAS satellites */ | |
| 26 | |
| 27 /* | |
| 28 * The structure describing an uncertainty volume in kinematic space. | |
| 29 * This is what GPSes are meant to produce; all the other info is | |
| 30 * technical impedimenta. | |
| 31 * | |
| 32 * All double values use NAN to indicate data not available. | |
| 33 * | |
| 34 * Usually all the information in this structure was considered valid | |
| 35 * by the GPS at the time of update. This will be so if you are using | |
| 36 * a GPS chipset that speaks SiRF binary, Garmin binary, or Zodiac binary. | |
| 37 * This covers over 80% of GPS products in early 2005. | |
| 38 * | |
| 39 * If you are using a chipset that speaks NMEA, this structure is updated | |
| 40 * in bits by GPRMC (lat/lon, track, speed), GPGGA (alt, climb), GPGLL | |
| 41 * (lat/lon), and GPGSA (eph, epv). Most NMEA GPSes take a single fix | |
| 42 * at the beginning of a 1-second cycle and report the same timestamp in | |
| 43 * GPRMC, GPGGA, and GPGLL; for these, all info is guaranteed correctly | |
| 44 * synced to the time member, but you'll get different stages of the same | |
| 45 * update depending on where in the cycle you poll. A very few GPSes, | |
| 46 * like the Garmin 48, take a new fix before more than one of of | |
| 47 * GPRMC/GPGGA/GPGLL during a single cycle; thus, they may have different | |
| 48 * timestamps and some data in this structure can be up to 1 cycle (usually | |
| 49 * 1 second) older than the fix time. | |
| 50 * | |
| 51 * Error estimates are at 95% confidence. | |
| 52 */ | |
| 53 struct gps_fix_t { | |
| 54 double time; /* Time of update, seconds since Unix epoch */ | |
| 55 int mode; /* Mode of fix */ | |
| 56 #define MODE_NOT_SEEN 0 /* mode update not seen yet */ | |
| 57 #define MODE_NO_FIX 1 /* none */ | |
| 58 #define MODE_2D 2 /* good for latitude/longitude */ | |
| 59 #define MODE_3D 3 /* good for altitude/climb too */ | |
| 60 double ept; /* Expected time uncertainty */ | |
| 61 double latitude; /* Latitude in degrees (valid if mode >= 2) */ | |
| 62 double longitude; /* Longitude in degrees (valid if mode >= 2) */ | |
| 63 double eph; /* Horizontal position uncertainty, meters */ | |
| 64 double altitude; /* Altitude in meters (valid if mode == 3) */ | |
| 65 double epv; /* Vertical position uncertainty, meters */ | |
| 66 double track; /* Course made good (relative to true north) */ | |
| 67 double epd; /* Track uncertainty, degrees */ | |
| 68 double speed; /* Speed over ground, meters/sec */ | |
| 69 double eps; /* Speed uncertainty, meters/sec */ | |
| 70 double climb; /* Vertical speed, meters/sec */ | |
| 71 double epc; /* Vertical speed uncertainty */ | |
| 72 }; | |
| 73 | |
| 74 /* | |
| 75 * From the RCTM104 2.x standard: | |
| 76 * | |
| 77 * "The 30 bit words (as opposed to 32 bit words) coupled with a 50 Hz | |
| 78 * transmission rate provides a convenient timing capability where the | |
| 79 * times of word boundaries are a rational multiple of 0.6 seconds." | |
| 80 * | |
| 81 * "Each frame is N+2 words long, where N is the number of message data | |
| 82 * words. For example, a filler message (type 6 or 34) with no message | |
| 83 * data will have N=0, and will consist only of two header words. The | |
| 84 * maximum number of data words allowed by the format is 31, so that | |
| 85 * the longest possible message will have a total of 33 words." | |
| 86 */ | |
| 87 #define RTCM2_WORDS_MAX 33 | |
| 88 #define MAXCORRECTIONS 18 /* max correction count in type 1 or 9 */ | |
| 89 #define MAXSTATIONS 10 /* maximum stations in almanac, type 5 */ | |
| 90 /* RTCM104 doesn't specify this, so give it the largest reasonable value */ | |
| 91 #define MAXHEALTH (RTCM2_WORDS_MAX-2) | |
| 92 | |
| 93 #ifndef S_SPLINT_S | |
| 94 /* | |
| 95 * A nominally 30-bit word (24 bits of data, 6 bits of parity) | |
| 96 * used both in the GPS downlink protocol described in IS-GPS-200 | |
| 97 * and in the format for DGPS corrections used in RTCM-104v2. | |
| 98 */ | |
| 99 typedef /*@unsignedintegraltype@*/ uint32_t isgps30bits_t; | |
| 100 #endif /* S_SPLINT_S */ | |
| 101 | |
| 102 typedef enum {gps, glonass, galileo, unknown} navsystem; | |
| 103 | |
| 104 struct rtcm2_t { | |
| 105 /* header contents */ | |
| 106 unsigned type; /* RTCM message type */ | |
| 107 unsigned length; /* length (words) */ | |
| 108 double zcount; /* time within hour: GPS time, no leap secs */ | |
| 109 unsigned refstaid; /* reference station ID */ | |
| 110 unsigned seqnum; /* message sequence number (modulo 8) */ | |
| 111 unsigned stathlth; /* station health */ | |
| 112 | |
| 113 /* message data in decoded form */ | |
| 114 union { | |
| 115 struct { | |
| 116 unsigned int nentries; | |
| 117 struct rangesat_t { /* data from messages 1 & 9 */ | |
| 118 unsigned ident; /* satellite ID */ | |
| 119 unsigned udre; /* user diff. range error */ | |
| 120 unsigned issuedata; /* issue of data */ | |
| 121 double rangerr; /* range error */ | |
| 122 double rangerate; /* range error rate */ | |
| 123 } sat[MAXCORRECTIONS]; | |
| 124 } ranges; | |
| 125 struct { /* data for type 3 messages */ | |
| 126 bool valid; /* is message well-formed? */ | |
| 127 double x, y, z; | |
| 128 } ecef; | |
| 129 struct { /* data from type 4 messages */ | |
| 130 bool valid; /* is message well-formed? */ | |
| 131 navsystem system; | |
| 132 enum {local, global, invalid} sense; | |
| 133 char datum[6]; | |
| 134 double dx, dy, dz; | |
| 135 } reference; | |
| 136 struct { /* data from type 5 messages */ | |
| 137 unsigned int nentries; | |
| 138 struct consat_t { | |
| 139 unsigned ident; /* satellite ID */ | |
| 140 bool iodl; /* issue of data */ | |
| 141 unsigned int health; /* is satellite healthy? */ | |
| 142 #define HEALTH_NORMAL (0) /* Radiobeacon operation normal */ | |
| 143 #define HEALTH_UNMONITORED (1) /* No integrity monitor operating */ | |
| 144 #define HEALTH_NOINFO (2) /* No information available */ | |
| 145 #define HEALTH_DONOTUSE (3) /* Do not use this radiobeacon */ | |
| 146 int snr; /* signal-to-noise ratio, dB */ | |
| 147 #define SNR_BAD -1 /* not reported */ | |
| 148 unsigned int health_en; /* health enabled */ | |
| 149 bool new_data; /* new data? */ | |
| 150 bool los_warning; /* line-of-sight warning */ | |
| 151 unsigned int tou; /* time to unhealth, seconds */ | |
| 152 } sat[MAXHEALTH]; | |
| 153 } conhealth; | |
| 154 struct { /* data from type 7 messages */ | |
| 155 unsigned int nentries; | |
| 156 struct station_t { | |
| 157 double latitude, longitude; /* location */ | |
| 158 unsigned int range; /* range in km */ | |
| 159 double frequency; /* broadcast freq */ | |
| 160 unsigned int health; /* station health */ | |
| 161 unsigned int station_id; /* of the transmitter */ | |
| 162 unsigned int bitrate; /* of station transmissions */ | |
| 163 } station[MAXSTATIONS]; | |
| 164 } almanac; | |
| 165 /* data from type 16 messages */ | |
| 166 char message[(RTCM2_WORDS_MAX-2) * sizeof(isgps30bits_t)]; | |
| 167 /* data from messages of unknown type */ | |
| 168 isgps30bits_t words[RTCM2_WORDS_MAX-2]; | |
| 169 } msg_data; | |
| 170 }; | |
| 171 | |
| 172 /* RTCM3 report structures begin here */ | |
| 173 | |
| 174 #define RTCM3_MAX_SATELLITES 64 | |
| 175 #define RTCM3_MAX_DESCRIPTOR 31 | |
| 176 #define RTCM3_MAX_ANNOUNCEMENTS 32 | |
| 177 | |
| 178 struct rtcm3_rtk_hdr { /* header data from 1001, 1002, 1003, 1004 */ | |
| 179 /* Used for both GPS and GLONASS, but their timebases differ */ | |
| 180 unsigned int msgnum; /* Message number */ | |
| 181 unsigned int station_id; /* Reference Station ID */ | |
| 182 time_t tow; /* GPS Epoch Time (TOW) in ms, | |
| 183 or GLONASS Epoch Time in ms */ | |
| 184 bool sync; /* Synchronous GNSS Message Flag */ | |
| 185 ushort satcount; /* # Satellite Signals Processed */ | |
| 186 bool smoothing; /* Divergence-free Smoothing Indicator */ | |
| 187 ushort interval; /* Smoothing Interval */ | |
| 188 }; | |
| 189 | |
| 190 struct rtcm3_basic_rtk { | |
| 191 unsigned char indicator; /* Indicator */ | |
| 192 unsigned char channel; /* Satellite Frequency Channel Number | |
| 193 (GLONASS only) */ | |
| 194 double pseudorange; /* Pseudorange */ | |
| 195 double rangediff; /* PhaseRange – Pseudorange in meters */ | |
| 196 unsigned char locktime; /* Lock time Indicator */ | |
| 197 }; | |
| 198 | |
| 199 struct rtcm3_extended_rtk { | |
| 200 unsigned char indicator; /* Indicator */ | |
| 201 unsigned char channel; /* Satellite Frequency Channel Number | |
| 202 (GLONASS only) */ | |
| 203 double pseudorange; /* Pseudorange */ | |
| 204 double rangediff; /* PhaseRange – L1 Pseudorange */ | |
| 205 unsigned char locktime; /* Lock time Indicator */ | |
| 206 unsigned char ambiguity; /* Integer Pseudorange | |
| 207 Modulus Ambiguity */ | |
| 208 double CNR; /* Carrier-to-Noise Ratio */ | |
| 209 }; | |
| 210 | |
| 211 struct rtcm3_network_rtk_header { | |
| 212 unsigned int msgnum; /* Message number */ | |
| 213 unsigned int network_id; /* Network ID */ | |
| 214 unsigned int subnetwork_id; /* Subnetwork ID */ | |
| 215 time_t time; /* GPS Epoch Time (TOW) in ms */ | |
| 216 bool multimesg; /* GPS Multiple Message Indicator */ | |
| 217 unsigned master_id; /* Master Reference Station ID */ | |
| 218 unsigned aux_id; /* Auxilary Reference Station ID */ | |
| 219 unsigned char satcount; /* count of GPS satellites */ | |
| 220 }; | |
| 221 | |
| 222 struct rtcm3_correction_diff { | |
| 223 unsigned char ident; /* satellite ID */ | |
| 224 enum {reserved, correct, widelane, uncertain} ambiguity; | |
| 225 unsigned char nonsync; | |
| 226 double geometric_diff; /* Geometric Carrier Phase | |
| 227 Correction Difference (1016, 1017) */ | |
| 228 unsigned char iode; /* GPS IODE (1016, 1017) */ | |
| 229 double ionospheric_diff; /* Ionospheric Carrier Phase | |
| 230 Correction Difference (1015, 1017) */ | |
| 231 }; | |
| 232 | |
| 233 struct rtcm3_t { | |
| 234 /* header contents */ | |
| 235 unsigned type; /* RTCM 3.x message type */ | |
| 236 unsigned length; /* payload length, inclusive of checksum */ | |
| 237 | |
| 238 union { | |
| 239 /* 1001-1013 were present in the 3.0 version */ | |
| 240 struct { | |
| 241 struct rtcm3_rtk_hdr header; | |
| 242 struct { | |
| 243 unsigned ident; /* Satellite ID */ | |
| 244 struct rtcm3_basic_rtk L1; | |
| 245 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 246 } rtcm3_1001; | |
| 247 struct { | |
| 248 struct rtcm3_rtk_hdr header; | |
| 249 struct { | |
| 250 unsigned ident; /* Satellite ID */ | |
| 251 struct rtcm3_extended_rtk L1; | |
| 252 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 253 } rtcm3_1002; | |
| 254 struct { | |
| 255 struct rtcm3_rtk_hdr header; | |
| 256 struct { | |
| 257 unsigned ident; /* Satellite ID */ | |
| 258 struct rtcm3_basic_rtk L1; | |
| 259 struct rtcm3_basic_rtk L2; | |
| 260 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 261 } rtcm3_1003; | |
| 262 struct { | |
| 263 struct rtcm3_rtk_hdr header; | |
| 264 struct { | |
| 265 unsigned ident; /* Satellite ID */ | |
| 266 struct rtcm3_extended_rtk L1; | |
| 267 struct rtcm3_extended_rtk L2; | |
| 268 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 269 } rtcm3_1004; | |
| 270 struct { | |
| 271 unsigned int station_id; /* Reference Station ID */ | |
| 272 navsystem system; /* Which system is it? */ | |
| 273 bool reference_station; /* Reference-station indicator */ | |
| 274 bool single_receiver; /* Single Receiver Oscillator */ | |
| 275 double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ | |
| 276 } rtcm3_1005; | |
| 277 struct { | |
| 278 unsigned int station_id; /* Reference Station ID */ | |
| 279 navsystem system; /* Which system is it? */ | |
| 280 bool reference_station; /* Reference-station indicator */ | |
| 281 bool single_receiver; /* Single Receiver Oscillator */ | |
| 282 double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ | |
| 283 double height; /* Antenna height */ | |
| 284 } rtcm3_1006; | |
| 285 struct { | |
| 286 unsigned int station_id; /* Reference Station ID */ | |
| 287 char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ | |
| 288 unsigned char setup_id; | |
| 289 } rtcm3_1007; | |
| 290 struct { | |
| 291 unsigned int station_id; /* Reference Station ID */ | |
| 292 char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ | |
| 293 unsigned char setup_id; | |
| 294 char serial[RTCM3_MAX_DESCRIPTOR+1]; /* Serial # string */ | |
| 295 } rtcm3_1008; | |
| 296 struct { | |
| 297 struct rtcm3_rtk_hdr header; | |
| 298 struct { | |
| 299 unsigned ident; /* Satellite ID */ | |
| 300 struct rtcm3_basic_rtk L1; | |
| 301 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 302 } rtcm3_1009; | |
| 303 struct { | |
| 304 struct rtcm3_rtk_hdr header; | |
| 305 struct { | |
| 306 unsigned ident; /* Satellite ID */ | |
| 307 struct rtcm3_extended_rtk L1; | |
| 308 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 309 } rtcm3_1010; | |
| 310 struct { | |
| 311 struct rtcm3_rtk_hdr header; | |
| 312 struct { | |
| 313 unsigned ident; /* Satellite ID */ | |
| 314 struct rtcm3_extended_rtk L1; | |
| 315 struct rtcm3_extended_rtk L2; | |
| 316 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 317 } rtcm3_1011; | |
| 318 struct { | |
| 319 struct rtcm3_rtk_hdr header; | |
| 320 struct { | |
| 321 unsigned ident; /* Satellite ID */ | |
| 322 struct rtcm3_extended_rtk L1; | |
| 323 struct rtcm3_extended_rtk L2; | |
| 324 } rtk_data[RTCM3_MAX_SATELLITES]; | |
| 325 } rtcm3_1012; | |
| 326 struct { | |
| 327 unsigned int msgnum; /* Message number */ | |
| 328 unsigned int station_id; /* Reference Station ID */ | |
| 329 unsigned short mjd; /* Modified Julian Day (MJD) Number */ | |
| 330 unsigned int sod; /* Seconds of Day (UTC) */ | |
| 331 unsigned char leapsecs; /* Leap Seconds, GPS-UTC */ | |
| 332 unsigned char ncount; /* Count of announcements to follow */ | |
| 333 struct { | |
| 334 unsigned short id; | |
| 335 bool sync; | |
| 336 unsigned short interval; | |
| 337 } announcements[RTCM3_MAX_ANNOUNCEMENTS]; | |
| 338 } rtcm3_1013; | |
| 339 /* 1014-1017 were added in the 3.1 version */ | |
| 340 struct { | |
| 341 unsigned int msgnum; /* Message number */ | |
| 342 unsigned int network_id; /* Network ID */ | |
| 343 unsigned int subnetwork_id; /* Subnetwork ID */ | |
| 344 unsigned char stationcount; /* # auxiliary stations transmitted */ | |
| 345 unsigned int master_id; /* Master Reference Station ID */ | |
| 346 unsigned int aux_id; /* Auxilary Reference Station ID */ | |
| 347 double d_lat, d_lon, d_alt; /* Aux-master location delta */ | |
| 348 } rtcm3_1014; | |
| 349 struct { | |
| 350 struct rtcm3_network_rtk_header header; | |
| 351 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
| 352 } rtcm3_1015; | |
| 353 struct { | |
| 354 struct rtcm3_network_rtk_header header; | |
| 355 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
| 356 } rtcm3_1016; | |
| 357 struct { | |
| 358 struct rtcm3_network_rtk_header header; | |
| 359 struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; | |
| 360 } rtcm3_1017; | |
| 361 struct { | |
| 362 unsigned int msgnum; /* Message number */ | |
| 363 unsigned int ident; /* Satellite ID */ | |
| 364 unsigned int week; /* GPS Week Number */ | |
| 365 unsigned char sv_accuracy; /* GPS SV ACCURACY */ | |
| 366 enum {reserved_code, p, ca, l2c} code; | |
| 367 double idot; | |
| 368 unsigned char iode; | |
| 369 /* ephemeris fields, not scaled */ | |
| 370 unsigned int t_sub_oc; | |
| 371 signed int a_sub_f2; | |
| 372 signed int a_sub_f1; | |
| 373 signed int a_sub_f0; | |
| 374 unsigned int iodc; | |
| 375 signed int C_sub_rs; | |
| 376 signed int delta_sub_n; | |
| 377 signed int M_sub_0; | |
| 378 signed int C_sub_uc; | |
| 379 unsigned int e; | |
| 380 signed int C_sub_us; | |
| 381 unsigned int sqrt_sub_A; | |
| 382 unsigned int t_sub_oe; | |
| 383 signed int C_sub_ic; | |
| 384 signed int OMEGA_sub_0; | |
| 385 signed int C_sub_is; | |
| 386 signed int i_sub_0; | |
| 387 signed int C_sub_rc; | |
| 388 signed int argument_of_perigee; | |
| 389 signed int omegadot; | |
| 390 signed int t_sub_GD; | |
| 391 unsigned char sv_health; | |
| 392 bool p_data; | |
| 393 bool fit_interval; | |
| 394 } rtcm3_1019; | |
| 395 struct { | |
| 396 unsigned int msgnum; /* Message number */ | |
| 397 unsigned int ident; /* Satellite ID */ | |
| 398 unsigned short channel; /* Satellite Frequency Channel Number */ | |
| 399 /* ephemeris fields, not scaled */ | |
| 400 bool C_sub_n; | |
| 401 bool health_avAilability_indicator; | |
| 402 unsigned char P1; | |
| 403 unsigned short t_sub_k; | |
| 404 bool msb_of_B_sub_n; | |
| 405 bool P2; | |
| 406 bool t_sub_b; | |
| 407 signed int x_sub_n_t_of_t_sub_b_prime; | |
| 408 signed int x_sub_n_t_of_t_sub_b; | |
| 409 signed int x_sub_n_t_of_t_sub_b_prime_prime; | |
| 410 signed int y_sub_n_t_of_t_sub_b_prime; | |
| 411 signed int y_sub_n_t_of_t_sub_b; | |
| 412 signed int y_sub_n_t_of_t_sub_b_prime_prime; | |
| 413 signed int z_sub_n_t_of_t_sub_b_prime; | |
| 414 signed int z_sub_n_t_of_t_sub_b; | |
| 415 signed int z_sub_n_t_of_t_sub_b_prime_prime; | |
| 416 bool P3; | |
| 417 signed int gamma_sub_n_of_t_sub_b; | |
| 418 unsigned char MP; | |
| 419 bool Ml_n; | |
| 420 signed int tau_n_of_t_sub_b; | |
| 421 signed int M_delta_tau_sub_n; | |
| 422 unsigned int E_sub_n; | |
| 423 bool MP4; | |
| 424 unsigned char MF_sub_T; | |
| 425 unsigned char MN_sub_T; | |
| 426 unsigned char MM; | |
| 427 bool additioinal_data_availability; | |
| 428 unsigned int N_sup_A; | |
| 429 unsigned int tau_sub_c; | |
| 430 unsigned int M_N_sub_4; | |
| 431 signed int M_tau_sub_GPS; | |
| 432 bool M_l_sub_n; | |
| 433 } rtcm3_1020; | |
| 434 struct { | |
| 435 unsigned int msgnum; /* Message number */ | |
| 436 unsigned int station_id; /* Reference Station ID */ | |
| 437 unsigned short mjd; /* Modified Julian Day (MJD) Number */ | |
| 438 unsigned int sod; /* Seconds of Day (UTC) */ | |
| 439 unsigned char len; /* # Chars to follow */ | |
| 440 unsigned char unicode_units; | |
| 441 unsigned char text[128]; | |
| 442 } rtcm3_1029; | |
| 443 } rtcmtypes; | |
| 444 }; | |
| 445 | |
| 446 typedef /*@unsignedintegraltype@*/ unsigned int gps_mask_t; | |
| 447 | |
| 448 struct gps_data_t { | |
| 449 gps_mask_t set; /* has field been set since this was last cleared? */ | |
| 450 #define ONLINE_SET 0x00000001u | |
| 451 #define TIME_SET 0x00000002u | |
| 452 #define TIMERR_SET 0x00000004u | |
| 453 #define LATLON_SET 0x00000008u | |
| 454 #define ALTITUDE_SET 0x00000010u | |
| 455 #define SPEED_SET 0x00000020u | |
| 456 #define TRACK_SET 0x00000040u | |
| 457 #define CLIMB_SET 0x00000080u | |
| 458 #define STATUS_SET 0x00000100u | |
| 459 #define MODE_SET 0x00000200u | |
| 460 #define HDOP_SET 0x00000400u | |
| 461 #define VDOP_SET 0x00000800u | |
| 462 #define PDOP_SET 0x00001000u | |
| 463 #define TDOP_SET 0x00002000u | |
| 464 #define GDOP_SET 0x00004000u | |
| 465 #define DOP_SET (HDOP_SET|VDOP_SET|PDOP_SET|TDOP_SET|GDOP_SET) | |
| 466 #define HERR_SET 0x00008000u | |
| 467 #define VERR_SET 0x00010000u | |
| 468 #define PERR_SET 0x00020000u | |
| 469 #define ERR_SET (HERR_SET | VERR_SET | PERR_SET) | |
| 470 #define SATELLITE_SET 0x00040000u | |
| 471 #define PSEUDORANGE_SET 0x00080000u | |
| 472 #define USED_SET 0x00100000u | |
| 473 #define SPEEDERR_SET 0x00200000u | |
| 474 #define TRACKERR_SET 0x00400000u | |
| 475 #define CLIMBERR_SET 0x00800000u | |
| 476 #define DEVICE_SET 0x01000000u | |
| 477 #define DEVICELIST_SET 0x02000000u | |
| 478 #define DEVICEID_SET 0x04000000u | |
| 479 #define ERROR_SET 0x08000000u | |
| 480 #define CYCLE_START_SET 0x10000000u | |
| 481 #define RTCM2_SET 0x20000000u | |
| 482 #define RTCM3_SET 0x40000000u | |
| 483 #define FIX_SET (TIME_SET|MODE_SET|TIMERR_SET|LATLON_SET|HERR_SET|ALTITU
DE_SET|VERR_SET|TRACK_SET|TRACKERR_SET|SPEED_SET|SPEEDERR_SET|CLIMB_SET|CLIMBERR
_SET) | |
| 484 double online; /* NZ if GPS is on line, 0 if not. | |
| 485 * | |
| 486 * Note: gpsd clears this flag when sentences | |
| 487 * fail to show up within the GPS's normal | |
| 488 * send cycle time. If the host-to-GPS | |
| 489 * link is lossy enough to drop entire | |
| 490 * sentences, this flag will be | |
| 491 * prone to false negatives. | |
| 492 */ | |
| 493 | |
| 494 struct gps_fix_t fix; /* accumulated PVT data */ | |
| 495 | |
| 496 double separation; /* Geoidal separation, MSL - WGS84 (Meters) */ | |
| 497 | |
| 498 /* GPS status -- always valid */ | |
| 499 int status; /* Do we have a fix? */ | |
| 500 #define STATUS_NO_FIX 0 /* no */ | |
| 501 #define STATUS_FIX 1 /* yes, without DGPS */ | |
| 502 #define STATUS_DGPS_FIX 2 /* yes, with DGPS */ | |
| 503 | |
| 504 /* precision of fix -- valid if satellites_used > 0 */ | |
| 505 int satellites_used; /* Number of satellites used in solution */ | |
| 506 int used[MAXCHANNELS]; /* PRNs of satellites used in solution */ | |
| 507 double pdop, hdop, vdop, tdop, gdop; /* Dilution of precision */ | |
| 508 | |
| 509 /* redundant with the estimate elments in the fix structure */ | |
| 510 double epe; /* spherical position error, 95% confidence (meters) */ | |
| 511 | |
| 512 /* satellite status -- valid when satellites > 0 */ | |
| 513 int satellites; /* # of satellites in view */ | |
| 514 int PRN[MAXCHANNELS]; /* PRNs of satellite */ | |
| 515 int elevation[MAXCHANNELS]; /* elevation of satellite */ | |
| 516 int azimuth[MAXCHANNELS]; /* azimuth */ | |
| 517 int ss[MAXCHANNELS]; /* signal-to-noise ratio (dB) */ | |
| 518 | |
| 519 #if 0 /* not yet used or filled in */ | |
| 520 /* measurement data */ | |
| 521 double pseudorange[MAXCHANNELS]; /* meters */ | |
| 522 double deltarange[MAXCHANNELS]; /* meters/sec */ | |
| 523 double doppler[MAXCHANNELS]; /* Hz */ | |
| 524 unsigned satstat[MAXCHANNELS]; /* tracking status */ | |
| 525 #define SAT_ACQUIRED 0x01 /* satellite acquired */ | |
| 526 #define SAT_CODE_TRACK 0x02 /* code-tracking loop acquired */ | |
| 527 #define SAT_CARR_TRACK 0x04 /* carrier-tracking loop acquired */ | |
| 528 #define SAT_DATA_SYNC 0x08 /* data-bit synchronization done */ | |
| 529 #define SAT_FRAME_SYNC 0x10 /* frame synchronization done */ | |
| 530 #define SAT_EPHEMERIS 0x20 /* ephemeris collected */ | |
| 531 #define SAT_FIX_USED 0x40 /* used for position fix */ | |
| 532 #endif | |
| 533 | |
| 534 #if defined(TNT_ENABLE) || defined(OCEANSERVER_ENABLE) | |
| 535 /* compass status -- TrueNorth (and any similar) devices only */ | |
| 536 char headingStatus; | |
| 537 char pitchStatus; | |
| 538 char rollStatus; | |
| 539 double horzField; /* Magnitude of horizontal magnetic field */ | |
| 540 #endif | |
| 541 | |
| 542 #ifdef OCEANSERVER_ENABLE | |
| 543 double magnetic_length; /* unitvector sqrt(x^2 + y^2 +z^2) */ | |
| 544 double magnetic_field_x; | |
| 545 double magnetic_field_y; | |
| 546 double magnetic_field_z; | |
| 547 double acceleration_length; /* unitvector sqrt(x^2 + y^2 +z^2) */ | |
| 548 double acceleration_field_x; | |
| 549 double acceleration_field_y; | |
| 550 double acceleration_field_z; | |
| 551 double gyro_output_x; | |
| 552 double gyro_output_y; | |
| 553 double temperature; | |
| 554 #endif | |
| 555 | |
| 556 /* where and what gpsd thinks the device is */ | |
| 557 char gps_device[PATH_MAX]; /* only valid if non-null. */ | |
| 558 char *gps_id; /* only valid if non-null. */ | |
| 559 unsigned int baudrate, parity, stopbits; /* RS232 link parameters */ | |
| 560 unsigned int driver_mode; /* whether driver is in native mode or not */ | |
| 561 | |
| 562 /* RTCM-104 data */ | |
| 563 struct rtcm2_t rtcm2; | |
| 564 struct rtcm3_t rtcm3; | |
| 565 | |
| 566 /* device list */ | |
| 567 int ndevices; /* count of available devices */ | |
| 568 char **devicelist; /* list of pathnames */ | |
| 569 | |
| 570 /* profiling data for last sentence */ | |
| 571 bool profiling; /* profiling enabled? */ | |
| 572 char tag[MAXTAGLEN+1]; /* tag of last sentence processed */ | |
| 573 size_t sentence_length; /* character count of last sentence */ | |
| 574 double sentence_time; /* sentence timestamp */ | |
| 575 double d_xmit_time; /* beginning of sentence transmission */ | |
| 576 double d_recv_time; /* daemon receipt time (-> E1+T1) */ | |
| 577 double d_decode_time; /* daemon end-of-decode time (-> D1) */ | |
| 578 double poll_time; /* daemon poll time (-> W) */ | |
| 579 double emit_time; /* emission time (-> E2) */ | |
| 580 double c_recv_time; /* client receipt time (-> T2) */ | |
| 581 double c_decode_time; /* client end-of-decode time (-> D2) */ | |
| 582 double cycle, mincycle; /* refresh cycle time in seconds */ | |
| 583 | |
| 584 /* these members are private */ | |
| 585 int gps_fd; /* socket or file descriptor to GPS */ | |
| 586 void (*raw_hook)(struct gps_data_t *, char *, size_t len, int level);/* Raw-
mode hook for GPS data. */ | |
| 587 void (*thread_hook)(struct gps_data_t *, char *, size_t len, int level);/* T
hread-callback hook for GPS data. */ | |
| 588 }; | |
| 589 | |
| 590 extern /*@null@*/ struct gps_data_t *gps_open(const char *host, const char *port
); | |
| 591 int gps_close(struct gps_data_t *); | |
| 592 int gps_query(struct gps_data_t *gpsdata, const char *fmt, ... ); | |
| 593 int gps_poll(struct gps_data_t *gpsdata); | |
| 594 void gps_set_raw_hook(struct gps_data_t *gpsdata, void (*hook)(struct gps_data_t
*sentence, char *buf, size_t len, int level)); | |
| 595 int gps_set_callback(struct gps_data_t *gpsdata, void (*callback)(struct gps_dat
a_t *sentence, char *buf, size_t len, int level), pthread_t *handler); | |
| 596 int gps_del_callback(struct gps_data_t *gpsdata, pthread_t *handler); | |
| 597 | |
| 598 enum unit {unspecified, imperial, nautical, metric}; | |
| 599 enum unit gpsd_units(void); | |
| 600 enum deg_str_type { deg_dd, deg_ddmm, deg_ddmmss }; | |
| 601 extern /*@observer@*/ char *deg_to_str( enum deg_str_type type, double f); | |
| 602 | |
| 603 extern void gps_clear_fix(/*@ out @*/struct gps_fix_t *); | |
| 604 extern void gps_merge_fix(/*@ out @*/struct gps_fix_t *, | |
| 605 gps_mask_t, | |
| 606 /*@ in @*/struct gps_fix_t *); | |
| 607 extern unsigned int gps_valid_fields(/*@ in @*/struct gps_fix_t *); | |
| 608 extern char *gps_show_transfer(int); | |
| 609 | |
| 610 extern time_t mkgmtime(register struct tm *); | |
| 611 extern double timestamp(void); | |
| 612 extern double iso8601_to_unix(char *); | |
| 613 extern /*@observer@*/char *unix_to_iso8601(double t, /*@ out @*/char[], size_t l
en); | |
| 614 extern double gpstime_to_unix(int, double); | |
| 615 extern void unix_to_gpstime(double, /*@out@*/int *, /*@out@*/double *); | |
| 616 extern double earth_distance(double, double, double, double); | |
| 617 extern double wgs84_separation(double, double); | |
| 618 | |
| 619 /* some multipliers for interpreting GPS output */ | |
| 620 #define METERS_TO_FEET 3.2808399 /* Meters to U.S./British feet */ | |
| 621 #define METERS_TO_MILES 0.00062137119 /* Meters to miles */ | |
| 622 #define KNOTS_TO_MPH 1.1507794 /* Knots to miles per hour */ | |
| 623 #define KNOTS_TO_KPH 1.852 /* Knots to kilometers per hour */ | |
| 624 #define KNOTS_TO_MPS 0.51444444 /* Knots to meters per second */ | |
| 625 #define MPS_TO_KPH 3.6 /* Meters per second to klicks/hr */ | |
| 626 #define MPS_TO_MPH 2.2369363 /* Meters/second to miles per hour */ | |
| 627 #define MPS_TO_KNOTS 1.9438445 /* Meters per second to knots */ | |
| 628 /* miles and knots are both the international standard versions of the units */ | |
| 629 | |
| 630 /* angle conversion multipliers */ | |
| 631 #define GPS_PI 3.1415926535897932384626433832795029 | |
| 632 #define RAD_2_DEG 57.2957795130823208767981548141051703 | |
| 633 #define DEG_2_RAD 0.0174532925199432957692369076848861271 | |
| 634 | |
| 635 /* gps_open() errno return values */ | |
| 636 #define NL_NOSERVICE -1 /* can't get service entry */ | |
| 637 #define NL_NOHOST -2 /* can't get host entry */ | |
| 638 #define NL_NOPROTO -3 /* can't get protocol entry */ | |
| 639 #define NL_NOSOCK -4 /* can't create socket */ | |
| 640 #define NL_NOSOCKOPT -5 /* error SETSOCKOPT SO_REUSEADDR */ | |
| 641 #define NL_NOCONNECT -6 /* can't connect to host */ | |
| 642 | |
| 643 #define DEFAULT_GPSD_PORT "2947" /* IANA assignment */ | |
| 644 #define DEFAULT_RTCM_PORT "2101" /* IANA assignment */ | |
| 645 | |
| 646 #ifdef __cplusplus | |
| 647 } /* End of the 'extern "C"' block */ | |
| 648 #endif | |
| 649 | |
| 650 /* gps.h ends here */ | |
| 651 #endif /* _GPSD_GPS_H_ */ | |
| OLD | NEW |