diff options
author | miletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-12 00:21:54 +0000 |
---|---|---|
committer | miletus@chromium.org <miletus@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-11-12 00:21:54 +0000 |
commit | ee011009fd36781e3da02dbed0df3df39c215ff4 (patch) | |
tree | 5b86e109870bb0465a94778d47e80be5645e698f /third_party | |
parent | 10e91704461a3640dc931f468bed25c78fd82e34 (diff) | |
download | chromium_src-ee011009fd36781e3da02dbed0df3df39c215ff4.zip chromium_src-ee011009fd36781e3da02dbed0df3df39c215ff4.tar.gz chromium_src-ee011009fd36781e3da02dbed0df3df39c215ff4.tar.bz2 |
Make chrome communicate with gpsd through libgps/shared memory
Update gps.h header to 3.1 version to have shared memory export
libgps APIs. Adapt libgps_wrapper_linux to use shared memory to
communicate with gpsd.
We enable the libgps support on ChromeOS and drop the support
on destkop linux for now due to the fact that we can't control
what gpsd version will be present on the desktop system and the gps
data written to shared memory by gpsd maybe not be compatible
with what chrome/libgps is expecting.
If there is demand for desktop libgps support we can add it
back and investigate on using socket interface between libgps and gpsd.
BUG=103751
TEST=run
"tools/checklicenses/checklicenses.py third_party/gpsd/"
and make sure no license violation.
content_unittests --gtest_filter="*Gps*"
and make sure all unittests pass
Review URL: http://codereview.chromium.org/8463022
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109736 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'third_party')
-rw-r--r-- | third_party/gpsd/README.chromium | 13 | ||||
-rw-r--r-- | third_party/gpsd/release-3.1/gps.h (renamed from third_party/gpsd/release-2.94/gps.h) | 924 |
2 files changed, 818 insertions, 119 deletions
diff --git a/third_party/gpsd/README.chromium b/third_party/gpsd/README.chromium index 88a8130..5fd1245 100644 --- a/third_party/gpsd/README.chromium +++ b/third_party/gpsd/README.chromium @@ -1,19 +1,20 @@ Name: gpsd -URL: http://git.berlios.de/cgi-bin/gitweb.cgi?p=gpsd;a=summary -InfoURL: http://gpsd.berlios.de/ -Version: 2.94 +URL: http://download-mirror.savannah.gnu.org/releases/gpsd/ +InfoURL: http://catb.org/gpsd/ +Version: 3.1 License: BSD Description: -versions 2.94 +versions 3.1 gpsd is a service daemon that monitors one or more GPSes or AIS receivers attached to a host computer through serial or USB ports, making all data on the location/course/velocity of the sensors available to be queried on TCP port -2947 of the host computer. +2947 of the host computer. From version 3.1 on, shared memory export is also +availble for gps data communication between gpsd and clients. Local Modifications: No modifications. -Only the gps.h file is imported, as the client library (libgps.so) is +Only the gps.h file is imported, as the client library (libgps.so.20) is dynamically loaded (where present). Security Critical: yes diff --git a/third_party/gpsd/release-2.94/gps.h b/third_party/gpsd/release-3.1/gps.h index 901365f..4ecce8e 100644 --- a/third_party/gpsd/release-2.94/gps.h +++ b/third_party/gpsd/release-3.1/gps.h @@ -1,3 +1,4 @@ +/* gps.h -- interface of the libgps library */ /* * This file is Copyright (c) 2010 by the GPSD project * BSD terms apply: see the file COPYING in the distribution root for details. @@ -5,12 +6,6 @@ #ifndef _GPSD_GPS_H_ #define _GPSD_GPS_H_ -/* gps.h -- interface of the libgps library */ - -#ifdef _WIN32 -#define strtok_r(s,d,p) strtok_s(s,d,p) -#endif - #ifdef __cplusplus extern "C" { #endif @@ -35,11 +30,18 @@ extern "C" { #include <pthread.h> /* pacifies OpenBSD's compiler */ #endif -#define GPSD_API_MAJOR_VERSION 4 /* bump on incompatible changes */ -#define GPSD_API_MINOR_VERSION 1 /* bump on compatible changes */ +/* + * 4.1 - Base version for initial JSON protocol (Dec 2009, release 2.90) + * 4.2 - AIS application IDs split into DAC and FID (July 2010, release 2.95) + * 5.0 - MAXCHANNELS bumped from 20 to 32 for GLONASS (Mar 2011, release 2.96) + * gps_open() becomes reentrant, what gps_open_r() used to be. + * gps_poll() removed in favor of gps_read(). The raw hook is gone. + */ +#define GPSD_API_MAJOR_VERSION 5 /* bump on incompatible changes */ +#define GPSD_API_MINOR_VERSION 0 /* bump on compatible changes */ #define MAXTAGLEN 8 /* maximum length of sentence tag name */ -#define MAXCHANNELS 20 /* maximum GPS channels (*not* satellites!) */ +#define MAXCHANNELS 72 /* must be > 12 GPS + 12 GLONASS + 2 WAAS */ #define GPS_PRNMAX 32 /* above this number are SBAS satellites */ #define GPS_PATH_MAX 64 /* dev files usually have short names */ #define MAXUSERDEVS 4 /* max devices per user */ @@ -70,8 +72,10 @@ extern "C" { * * Error estimates are at 95% confidence. */ +typedef double timestamp_t; /* Unix time in seconds with fractional part */ + struct gps_fix_t { - double time; /* Time of update, seconds since Unix epoch */ + timestamp_t time; /* Time of update */ int mode; /* Mode of fix */ #define MODE_NOT_SEEN 0 /* mode update not seen yet */ #define MODE_NO_FIX 1 /* none */ @@ -92,6 +96,20 @@ struct gps_fix_t { double epc; /* Vertical speed uncertainty */ }; +/* + * The structure describing the pseudorange errors (GPGST) + */ +struct gst_t { + double utctime; + double rms_deviation; + double smajor_deviation; + double sminor_deviation; + double smajor_orientation; + double lat_err_deviation; + double lon_err_deviation; + double alt_err_deviation; +}; + /* * From the RCTM104 2.x standard: * @@ -142,14 +160,14 @@ struct rtcm2_t { union { struct { unsigned int nentries; - struct rangesat_t { /* data from messages 1 & 9 */ + struct gps_rangesat_t { /* data from messages 1 & 9 */ unsigned ident; /* satellite ID */ unsigned udre; /* user diff. range error */ - unsigned issuedata; /* issue of data */ - double rangerr; /* range error */ - double rangerate; /* range error rate */ + unsigned iod; /* issue of data */ + double prc; /* range error */ + double rrc; /* range error rate */ } sat[MAXCORRECTIONS]; - } ranges; + } gps_ranges; struct { /* data for type 3 messages */ bool valid; /* is message well-formed? */ double x, y, z; @@ -193,6 +211,28 @@ struct rtcm2_t { unsigned int bitrate; /* of station transmissions */ } station[MAXSTATIONS]; } almanac; + struct { /* data for type 13 messages */ + bool status; /* expect a text message */ + bool rangeflag; /* station range altered? */ + double lat, lon; /* station longitude/latitude */ + unsigned int range; /* transmission range in km */ + } xmitter; + struct { /* data from type 14 messages */ + unsigned int week; /* GPS week (0-1023) */ + unsigned int hour; /* Hour in week (0-167) */ + unsigned int leapsecs; /* Leap seconds (0-63) */ + } gpstime; + struct { + unsigned int nentries; + struct glonass_rangesat_t { /* data from message type 31 */ + unsigned ident; /* satellite ID */ + unsigned udre; /* user diff. range error */ + unsigned tod; /* issue of data */ + bool change; /* ephemeris change bit */ + double prc; /* range error */ + double rrc; /* range error rate */ + } sat[MAXCORRECTIONS]; + } glonass_ranges; /* data from type 16 messages */ char message[(RTCM2_WORDS_MAX-2) * sizeof(isgps30bits_t)]; /* data from messages of unknown type */ @@ -219,7 +259,7 @@ struct rtcm3_rtk_hdr { /* header data from 1001, 1002, 1003, 1004 */ struct rtcm3_basic_rtk { unsigned char indicator; /* Indicator */ - unsigned char channel; /* Satellite Frequency Channel Number + short channel; /* Satellite Frequency Channel Number (GLONASS only) */ double pseudorange; /* Pseudorange */ double rangediff; /* PhaseRange – Pseudorange in meters */ @@ -228,7 +268,7 @@ struct rtcm3_basic_rtk { struct rtcm3_extended_rtk { unsigned char indicator; /* Indicator */ - unsigned char channel; /* Satellite Frequency Channel Number + short channel; /* Satellite Frequency Channel Number (GLONASS only) */ double pseudorange; /* Pseudorange */ double rangediff; /* PhaseRange – L1 Pseudorange */ @@ -268,19 +308,19 @@ struct rtcm3_t { /* 1001-1013 were present in the 3.0 version */ struct { struct rtcm3_rtk_hdr header; - struct { + struct rtcm3_1001_t { unsigned ident; /* Satellite ID */ struct rtcm3_basic_rtk L1; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1001; - struct { + struct rtcm3_1002_t { struct rtcm3_rtk_hdr header; struct { unsigned ident; /* Satellite ID */ struct rtcm3_extended_rtk L1; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1002; - struct { + struct rtcm3_1003_t { struct rtcm3_rtk_hdr header; struct { unsigned ident; /* Satellite ID */ @@ -288,7 +328,7 @@ struct rtcm3_t { struct rtcm3_basic_rtk L2; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1003; - struct { + struct rtcm3_1004_t { struct rtcm3_rtk_hdr header; struct { unsigned ident; /* Satellite ID */ @@ -296,14 +336,14 @@ struct rtcm3_t { struct rtcm3_extended_rtk L2; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1004; - struct { + struct rtcm3_1005_t { unsigned int station_id; /* Reference Station ID */ int system; /* Which system is it? */ bool reference_station; /* Reference-station indicator */ bool single_receiver; /* Single Receiver Oscillator */ double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ } rtcm3_1005; - struct { + struct rtcm3_1006_t { unsigned int station_id; /* Reference Station ID */ int system; /* Which system is it? */ bool reference_station; /* Reference-station indicator */ @@ -311,32 +351,32 @@ struct rtcm3_t { double ecef_x, ecef_y, ecef_z; /* ECEF antenna location */ double height; /* Antenna height */ } rtcm3_1006; - struct { + struct rtcm3_1007_t { unsigned int station_id; /* Reference Station ID */ char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ unsigned char setup_id; } rtcm3_1007; - struct { + struct rtcm3_1008_t { unsigned int station_id; /* Reference Station ID */ char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ unsigned char setup_id; char serial[RTCM3_MAX_DESCRIPTOR+1]; /* Serial # string */ } rtcm3_1008; - struct { + struct rtcm3_1009_t { struct rtcm3_rtk_hdr header; struct { unsigned ident; /* Satellite ID */ struct rtcm3_basic_rtk L1; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1009; - struct { + struct rtcm3_1010_t { struct rtcm3_rtk_hdr header; struct { unsigned ident; /* Satellite ID */ struct rtcm3_extended_rtk L1; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1010; - struct { + struct rtcm3_1011_t { struct rtcm3_rtk_hdr header; struct { unsigned ident; /* Satellite ID */ @@ -344,7 +384,7 @@ struct rtcm3_t { struct rtcm3_extended_rtk L2; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1011; - struct { + struct rtcm3_1012_t { struct rtcm3_rtk_hdr header; struct { unsigned ident; /* Satellite ID */ @@ -352,20 +392,20 @@ struct rtcm3_t { struct rtcm3_extended_rtk L2; } rtk_data[RTCM3_MAX_SATELLITES]; } rtcm3_1012; - struct { + struct rtcm3_1013_t { unsigned int station_id; /* Reference Station ID */ unsigned short mjd; /* Modified Julian Day (MJD) Number */ unsigned int sod; /* Seconds of Day (UTC) */ unsigned char leapsecs; /* Leap Seconds, GPS-UTC */ unsigned char ncount; /* Count of announcements to follow */ struct { - unsigned short id; + unsigned short id; /* message type ID */ bool sync; - unsigned short interval; + unsigned short interval; /* interval in 0.1sec units */ } announcements[RTCM3_MAX_ANNOUNCEMENTS]; } rtcm3_1013; /* 1014-1017 were added in the 3.1 version */ - struct { + struct rtcm3_1014_t { unsigned int network_id; /* Network ID */ unsigned int subnetwork_id; /* Subnetwork ID */ unsigned char stationcount; /* # auxiliary stations transmitted */ @@ -373,20 +413,20 @@ struct rtcm3_t { unsigned int aux_id; /* Auxilary Reference Station ID */ double d_lat, d_lon, d_alt; /* Aux-master location delta */ } rtcm3_1014; - struct { + struct rtcm3_1015_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; } rtcm3_1015; - struct { + struct rtcm3_1016_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; } rtcm3_1016; - struct { + struct rtcm3_1017_t { struct rtcm3_network_rtk_header header; struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES]; } rtcm3_1017; /* 1018-1029 were in the 3.0 version */ - struct { + struct rtcm3_1019_t { unsigned int ident; /* Satellite ID */ unsigned int week; /* GPS Week Number */ unsigned char sv_accuracy; /* GPS SV ACCURACY */ @@ -419,7 +459,7 @@ struct rtcm3_t { bool p_data; bool fit_interval; } rtcm3_1019; - struct { + struct rtcm3_1020_t { unsigned int ident; /* Satellite ID */ unsigned short channel; /* Satellite Frequency Channel Number */ /* ephemeris fields, not scaled */ @@ -457,18 +497,335 @@ struct rtcm3_t { signed int M_tau_sub_GPS; bool M_l_sub_n; } rtcm3_1020; - struct { + struct rtcm3_1029_t { unsigned int station_id; /* Reference Station ID */ unsigned short mjd; /* Modified Julian Day (MJD) Number */ unsigned int sod; /* Seconds of Day (UTC) */ - unsigned char len; /* # Chars to follow */ - unsigned char unicode_units; + size_t len; /* # chars to follow */ + size_t unicode_units; /* # Unicode units in text */ unsigned char text[128]; } rtcm3_1029; + struct rtcm3_1033_t { + unsigned int station_id; /* Reference Station ID */ + char descriptor[RTCM3_MAX_DESCRIPTOR+1]; /* Description string */ + unsigned char setup_id; + char serial[RTCM3_MAX_DESCRIPTOR+1]; /* Serial # string */ + char receiver[RTCM3_MAX_DESCRIPTOR+1]; /* Receiver string */ + char firmware[RTCM3_MAX_DESCRIPTOR+1]; /* Firmware string */ + } rtcm3_1033; + char data[1024]; /* Max RTCM3 msg length is 1023 bytes */ } rtcmtypes; }; -typedef /*@unsignedintegraltype@*/ unsigned int gps_mask_t; +/* RTCM3 scaling constants */ +#define GPS_AMBIGUITY_MODULUS 299792.458 /* 1004, DF014*/ +#define GLONASS_AMBIGUITY_MODULUS 599584.916 /* 1012, DF044 */ +#define MESSAGE_INTERVAL_UNITS 0.1 /* 1013, DF047 */ + +/* + * Raw IS_GPS subframe data + */ + +/* The almanac is a subset of the clock and ephemeris data, with reduced + * precision. See IS-GPS-200E, Table 20-VI */ +struct almanac_t +{ + uint8_t sv; /* The satellite this refers to */ + /* toa, almanac reference time, 8 bits unsigned, seconds */ + uint8_t toa; + long l_toa; + /* SV health data, 8 bit unsigned bit map */ + uint8_t svh; + /* deltai, correction to inclination, 16 bits signed, semi-circles */ + int16_t deltai; + double d_deltai; + /* M0, Mean Anomaly at Reference Time, 24 bits signed, semi-circles */ + int32_t M0; + double d_M0; + /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly Epoch, + * 24 bits signed, semi-circles */ + int32_t Omega0; + double d_Omega0; + /* omega, Argument of Perigee, 24 bits signed, semi-circles */ + int32_t omega; + double d_omega; + /* af0, SV clock correction constant term + * 11 bits signed, seconds */ + int16_t af0; + double d_af0; + /* af1, SV clock correction first order term + * 11 bits signed, seconds/second */ + int16_t af1; + double d_af1; + /* eccentricity, 16 bits, unsigned, dimensionless */ + uint16_t e; + double d_eccentricity; + /* sqrt A, Square Root of the Semi-Major Axis + * 24 bits unsigned, square_root(meters) */ + uint32_t sqrtA; + double d_sqrtA; + /* Omega dot, Rate of Right Ascension, 16 bits signed, semi-circles/sec */ + int16_t Omegad; + double d_Omegad; +}; + +struct subframe_t { + /* subframe number, 3 bits, unsigned, 1 to 5 */ + uint8_t subframe_num; + /* data_id, denotes the NAV data structure of D(t), 2 bits, in + * IS-GPS-200E always == 0x1 */ + uint8_t data_id; + /* SV/page id used for subframes 4 & 5, 6 bits */ + uint8_t pageid; + /* tSVID, SV ID of the sat that transmitted this frame, 6 bits unsigned */ + uint8_t tSVID; + /* TOW, Time of Week of NEXT message, 17 bits unsigned, scale 6, seconds */ + uint32_t TOW17; + long l_TOW17; + /* integrity, URA bounds flag, 1 bit */ + bool integrity; + /* alert, alert flag, SV URA and/or the SV User Differential Range + * Accuracy (UDRA) may be worse than indicated, 1 bit */ + bool alert; + /* antispoof, A-S mode is ON in that SV, 1 bit */ + bool antispoof; + int is_almanac; + union { + /* subframe 1, part of ephemeris, see IS-GPS-200E, Table 20-II + * and Table 20-I */ + struct { + /* WN, Week Number, 10 bits unsigned, scale 1, weeks */ + uint16_t WN; + /* IODC, Issue of Data, Clock, 10 bits, unsigned, + * issued in 8 data ranges at the same time */ + uint16_t IODC; + /* toc, clock data reference time, 16 bits, unsigned, seconds + * scale 2**4, issued in 8 data ranges at the same time */ + uint16_t toc; + long l_toc; + /* l2, code on L2, 2 bits, bit map */ + uint8_t l2; + /* l2p, L2 P data flag, 1 bit */ + uint8_t l2p; + /* ura, SV accuracy, 4 bits unsigned index */ + unsigned int ura; + /* hlth, SV health, 6 bits unsigned bitmap */ + unsigned int hlth; + /* af0, SV clock correction constant term + * 22 bits signed, scale 2**-31, seconds */ + int32_t af0; + double d_af0; + /* af1, SV clock correction first order term + * 22 bits signed, scale 2**-43, seconds/second */ + int16_t af1; + double d_af1; + /* af2, SV clock correction second order term + * 8 bits signed, scale 2**-55, seconds/second**2 */ + int8_t af2; + double d_af2; + /* Tgd, L1-L2 correction term, 8 bits signed, scale 2**-31, + * seconds */ + int8_t Tgd; + double d_Tgd; + } sub1; + /* subframe 2, part of ephemeris, see IS-GPS-200E, Table 20-II + * and Table 20-III */ + struct { + /* Issue of Data (Ephemeris), + * equal to the 8 LSBs of the 10 bit IODC of the same data set */ + uint8_t IODE; + /* Age of Data Offset for the NMCT, 6 bits, scale 900, + * ignore if all ones, seconds */ + uint8_t AODO; + uint16_t u_AODO; + /* fit, FIT interval flag, indicates a fit interval greater than + * 4 hour, 1 bit */ + uint8_t fit; + /* toe, Reference Time Ephemeris, 16 bits unsigned, scale 2**4, + * seconds */ + uint16_t toe; + long l_toe; + /* Crs, Amplitude of the Sine Harmonic Correction Term to the + * Orbit Radius, 16 bits, scale 2**-5, signed, meters */ + int16_t Crs; + double d_Crs; + /* Cus, Amplitude of the Sine Harmonic Correction Term to the + * Argument of Latitude, 16 bits, signed, scale 2**-29, radians */ + int16_t Cus; + double d_Cus; + /* Cuc, Amplitude of the Cosine Harmonic Correction Term to the + * Argument of Latitude, 16 bits, signed, scale 2**-29, radians */ + int16_t Cuc; + double d_Cuc; + /* deltan, Mean Motion Difference From Computed Value + * Mean Motion Difference From Computed Value + * 16 bits, signed, scale 2**-43, semi-circles/sec */ + int16_t deltan; + double d_deltan; + /* M0, Mean Anomaly at Reference Time, 32 bits signed, + * scale 2**-31, semi-circles */ + int32_t M0; + double d_M0; + /* eccentricity, 32 bits, unsigned, scale 2**-33, dimensionless */ + uint32_t e; + double d_eccentricity; + /* sqrt A, Square Root of the Semi-Major Axis + * 32 bits unsigned, scale 2**-19, square_root(meters) */ + uint32_t sqrtA; + double d_sqrtA; + } sub2; + /* subframe 3, part of ephemeris, see IS-GPS-200E, Table 20-II, + * Table 20-III */ + struct { + /* Issue of Data (Ephemeris), 8 bits, unsigned + * equal to the 8 LSBs of the 10 bit IODC of the same data set */ + uint8_t IODE; + /* Rate of Inclination Angle, 14 bits signed, scale2**-43, + * semi-circles/sec */ + uint16_t IDOT; + double d_IDOT; + /* Cic, Amplitude of the Cosine Harmonic Correction Term to the + * Angle of Inclination, 16 bits signed, scale 2**-29, radians*/ + uint16_t Cic; + double d_Cic; + /* Cis, Amplitude of the Sine Harmonic Correction Term to the + * Angle of Inclination, 16 bits, unsigned, scale 2**-29, radians */ + int16_t Cis; + double d_Cis; + /* Crc, Amplitude of the Cosine Harmonic Correction Term to the + * Orbit Radius, 16 bits signed, scale 2**-5, meters */ + int16_t Crc; + double d_Crc; + /* i0, Inclination Angle at Reference Time, 32 bits, signed, + * scale 2**-31, semi-circles */ + int32_t i0; + double d_i0; + /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly + * Epoch, 32 bits signed, semi-circles */ + int32_t Omega0; + double d_Omega0; + /* omega, Argument of Perigee, 32 bits signed, scale 2**-31, + * semi-circles */ + int32_t omega; + double d_omega; + /* Omega dot, Rate of Right Ascension, 24 bits signed, + * scale 2**-43, semi-circles/sec */ + int32_t Omegad; + double d_Omegad; + } sub3; + struct { + struct almanac_t almanac; + } sub4; + /* subframe 4, page 13 */ + struct { + /* mapping ord ERD# to SV # is non trivial + * leave it alone. See IS-GPS-200E Section 20.3.3.5.1.9 */ + /* Estimated Range Deviation, 6 bits signed, meters */ + char ERD[33]; + /* ai, Availability Indicator, 2bits, bit map */ + unsigned char ai; + } sub4_13; + /* subframe 4, page 17, system message, 23 chars, plus nul */ + struct { + char str[24]; + } sub4_17; + /* subframe 4, page 18 */ + struct { + /* ionospheric and UTC data */ + /* A0, Bias coefficient of GPS time scale relative to UTC time + * scale, 32 bits signed, scale 2**-30, seconds */ + int32_t A0; + double d_A0; + /* A1, Drift coefficient of GPS time scale relative to UTC time + * scale, 24 bits signed, scale 2**-50, seconds/second */ + int32_t A1; + double d_A1; + + /* alphaX, the four coefficients of a cubic equation representing + * the amplitude of the vertical delay */ + + /* alpha0, 8 bits signed, scale w**-30, seconds */ + int8_t alpha0; + double d_alpha0; + /* alpha1, 8 bits signed, scale w**-27, seconds/semi-circle */ + int8_t alpha1; + double d_alpha1; + /* alpha2, 8 bits signed, scale w**-24, seconds/semi-circle**2 */ + int8_t alpha2; + double d_alpha2; + /* alpha3, 8 bits signed, scale w**-24, seconds/semi-circle**3 */ + int8_t alpha3; + double d_alpha3; + + /* betaX, the four coefficients of a cubic equation representing + * the period of the model */ + + /* beta0, 8 bits signed, scale w**11, seconds */ + int8_t beta0; + double d_beta0; + /* beta1, 8 bits signed, scale w**14, seconds/semi-circle */ + int8_t beta1; + double d_beta1; + /* beta2, 8 bits signed, scale w**16, seconds/semi-circle**2 */ + int8_t beta2; + double d_beta2; + /* beta3, 8 bits signed, scale w**16, seconds/semi-circle**3 */ + int8_t beta3; + double d_beta3; + + /* leap (delta t ls), current leap second, 8 bits signed, + * scale 1, seconds */ + int8_t leap; + /* lsf (delta t lsf), future leap second, 8 bits signed, + * scale 1, seconds */ + int8_t lsf; + + /* tot, reference time for UTC data, + * 8 bits unsigned, scale 2**12, seconds */ + uint8_t tot; + double d_tot; + + /* WNt, UTC reference week number, 8 bits unsigned, scale 1, + * weeks */ + uint8_t WNt; + /* WNlsf, Leap second reference Week Number, + * 8 bits unsigned, scale 1, weeks */ + uint8_t WNlsf; + /* DN, Leap second reference Day Number , 8 bits unsigned, + * scale 1, days */ + uint8_t DN; + } sub4_18; + /* subframe 4, page 25 */ + struct { + /* svf, A-S status and the configuration code of each SV + * 4 bits unsigned, bitmap */ + unsigned char svf[33]; + /* svh, SV health data for SV 25 through 32 + * 6 bits unsigned bitmap */ + uint8_t svhx[8]; + } sub4_25; + struct { + struct almanac_t almanac; + } sub5; + struct { + /* toa, Almanac reference Time, 8 bits unsigned, scale 2**12, + * seconds */ + uint8_t toa; + long l_toa; + /* WNa, Week Number almanac, 8 bits, scale 2, GPS Week + * Number % 256 */ + uint8_t WNa; + /* sv, SV health status, 6 bits, bitmap */ + uint8_t sv[25]; + } sub5_25; + }; +}; + +#ifndef S_SPLINT_S +typedef uint64_t gps_mask_t; +#else +typedef /*@unsignedintegraltype@*/ unsigned long long gps_mask_t; +#endif /* S_SPLINT_S */ /* * Is an MMSI number that of an auxiliary associated with a mother ship? @@ -479,6 +836,32 @@ typedef /*@unsignedintegraltype@*/ unsigned int gps_mask_t; */ #define AIS_AUXILIARY_MMSI(n) ((n) / 10000000 == 98) +/* N/A values and scaling constant for 25/24 bit lon/lat pairs */ +#define AIS_LON3_NOT_AVAILABLE 181000 +#define AIS_LAT3_NOT_AVAILABLE 91000 +#define AIS_LATLON3_SCALE 60000.0 + +/* N/A values and scaling constant for 28/27 bit lon/lat pairs */ +#define AIS_LON4_NOT_AVAILABLE 1810000 +#define AIS_LAT4_NOT_AVAILABLE 910000 +#define AIS_LATLON4_SCALE 600000.0 + +struct route_info { + unsigned int linkage; /* Message Linkage ID */ + unsigned int sender; /* Sender Class */ + unsigned int rtype; /* Route Type */ + unsigned int month; /* Start month */ + unsigned int day; /* Start day */ + unsigned int hour; /* Start hour */ + unsigned int minute; /* Start minute */ + unsigned int duration; /* Duration */ + int waycount; /* Waypoint count */ + struct waypoint_t { + signed int lon; /* Longitude */ + signed int lat; /* Latitude */ + } waypoints[16]; +}; + struct ais_t { unsigned int type; /* message type */ @@ -541,7 +924,7 @@ struct ais_t struct { unsigned int ais_version; /* AIS version level */ unsigned int imo; /* IMO identification */ - char callsign[8]; /* callsign */ + char callsign[7+1]; /* callsign */ #define AIS_SHIPNAME_MAXLEN 20 char shipname[AIS_SHIPNAME_MAXLEN+1]; /* vessel name */ unsigned int shiptype; /* ship type code */ @@ -555,7 +938,7 @@ struct ais_t unsigned int hour; /* UTC hour */ unsigned int minute; /* UTC minute */ unsigned int draught; /* draft in meters */ - char destination[21]; /* ship destination */ + char destination[20+1]; /* ship destination */ unsigned int dte; /* data terminal enable */ //unsigned int spare; spare bits */ } type5; @@ -565,10 +948,136 @@ struct ais_t unsigned int dest_mmsi; /* destination MMSI */ bool retransmit; /* retransmit flag */ //unsigned int spare; spare bit(s) */ - unsigned int app_id; /* Application ID */ + unsigned int dac; /* Application ID */ + unsigned int fid; /* Functional ID */ #define AIS_TYPE6_BINARY_MAX 920 /* 920 bits */ size_t bitcount; /* bit count of the data */ - char bitdata[(AIS_TYPE6_BINARY_MAX + 7) / 8]; + union { + char bitdata[(AIS_TYPE6_BINARY_MAX + 7) / 8]; + /* IMO236 - Dangerous Cargo Indication */ + struct { + char lastport[5+1]; /* Last Port Of Call */ + unsigned int lmonth; /* ETA month */ + unsigned int lday; /* ETA day */ + unsigned int lhour; /* ETA hour */ + unsigned int lminute; /* ETA minute */ + char nextport[5+1]; /* Next Port Of Call */ + unsigned int nmonth; /* ETA month */ + unsigned int nday; /* ETA day */ + unsigned int nhour; /* ETA hour */ + unsigned int nminute; /* ETA minute */ + char dangerous[20+1]; /* Main Dangerous Good */ + char imdcat[4+1]; /* IMD Category */ + unsigned int unid; /* UN Number */ + unsigned int amount; /* Amount of Cargo */ + unsigned int unit; /* Unit of Quantity */ + } dac1fid12; + /* IMO236 - Extended Ship Static and Voyage Related Data */ + struct { + unsigned int airdraught; /* Air Draught */ + } dac1fid15; + /* IMO236 - Number of Persons on board */ + struct { + unsigned persons; /* number of persons */ + } dac1fid16; + /* IMO289 - Clearance Time To Enter Port */ + struct { + unsigned int linkage; /* Message Linkage ID */ + unsigned int month; /* Month (UTC) */ + unsigned int day; /* Day (UTC) */ + unsigned int hour; /* Hour (UTC) */ + unsigned int minute; /* Minute (UTC) */ + char portname[20+1]; /* Name of Port & Berth */ + char destination[5+1]; /* Destination */ + signed int lon; /* Longitude */ + signed int lat; /* Latitude */ + } dac1fid18; + /* IMO289 - Berthing Data (addressed) */ + struct { + unsigned int linkage; /* Message Linkage ID */ + unsigned int berth_length; /* Berth length */ + unsigned int berth_depth; /* Berth Water Depth */ + unsigned int position; /* Mooring Position */ + unsigned int month; /* Month (UTC) */ + unsigned int day; /* Day (UTC) */ + unsigned int hour; /* Hour (UTC) */ + unsigned int minute; /* Minute (UTC) */ + unsigned int availability; /* Services Availability */ + unsigned int agent; /* Agent */ + unsigned int fuel; /* Bunker/fuel */ + unsigned int chandler; /* Chandler */ + unsigned int stevedore; /* Stevedore */ + unsigned int electrical; /* Electrical */ + unsigned int water; /* Potable water */ + unsigned int customs; /* Customs house */ + unsigned int cartage; /* Cartage */ + unsigned int crane; /* Crane(s) */ + unsigned int lift; /* Lift(s) */ + unsigned int medical; /* Medical facilities */ + unsigned int navrepair; /* Navigation repair */ + unsigned int provisions; /* Provisions */ + unsigned int shiprepair; /* Ship repair */ + unsigned int surveyor; /* Surveyor */ + unsigned int steam; /* Steam */ + unsigned int tugs; /* Tugs */ + unsigned int solidwaste; /* Waste disposal (solid) */ + unsigned int liquidwaste; /* Waste disposal (liquid) */ + unsigned int hazardouswaste; /* Waste disposal (hazardous) */ + unsigned int ballast; /* Reserved ballast exchange */ + unsigned int additional; /* Additional services */ + unsigned int regional1; /* Regional reserved 1 */ + unsigned int regional2; /* Regional reserved 2 */ + unsigned int future1; /* Reserved for future */ + unsigned int future2; /* Reserved for future */ + char berth_name[20+1]; /* Name of Berth */ + signed int berth_lon; /* Longitude */ + signed int berth_lat; /* Latitude */ + } dac1fid20; + /* IMO289 - Dangerous Cargo Indication */ + struct { + unsigned int unit; /* Unit of Quantity */ + unsigned int amount; /* Amount of Cargo */ + int ncargos; + struct cargo_t { + unsigned int code; /* Cargo code */ + unsigned int subtype; /* Cargo subtype */ + } cargos[28]; + } dac1fid25; + /* IMO289 - Route info (addressed) */ + struct route_info dac1fid28; + /* IMO289 - Text message (addressed) */ + struct { + unsigned int linkage; +#define AIS_DAC1FID30_TEXT_MAX 154 /* 920 bits of six-bit, plus NUL */ + char text[AIS_DAC1FID30_TEXT_MAX]; + } dac1fid30; + /* IMO289 & IMO236 - Tidal Window */ + struct { + unsigned int type; /* Message Type */ + unsigned int repeat; /* Repeat Indicator */ + unsigned int mmsi; /* Source MMSI */ + unsigned int seqno; /* Sequence Number */ + unsigned int dest_mmsi; /* Destination MMSI */ + signed int retransmit; /* Retransmit flag */ + unsigned int dac; /* DAC */ + unsigned int fid; /* FID */ + unsigned int month; /* Month */ + unsigned int day; /* Day */ + signed int ntidals; + struct tidal_t { + signed int lon; /* Longitude */ + signed int lat; /* Latitude */ + unsigned int from_hour; /* From UTC Hour */ + unsigned int from_min; /* From UTC Minute */ + unsigned int to_hour; /* To UTC Hour */ + unsigned int to_min; /* To UTC Minute */ +#define DAC1FID32_CDIR_NOT_AVAILABLE 360 + unsigned int cdir; /* Current Dir. Predicted */ +#define DAC1FID32_CSPEED_NOT_AVAILABLE 127 + unsigned int cspeed; /* Current Speed Predicted */ + } tidals[3]; + } dac1fid32; + }; } type6; /* Type 7 - Binary Acknowledge */ struct { @@ -581,10 +1090,144 @@ struct ais_t /* Type 8 - Broadcast Binary Message */ struct { //unsigned int spare; spare bit(s) */ - unsigned int app_id; /* Application ID */ + unsigned int dac; /* Designated Area Code */ + unsigned int fid; /* Functional ID */ #define AIS_TYPE8_BINARY_MAX 952 /* 952 bits */ size_t bitcount; /* bit count of the data */ - char bitdata[(AIS_TYPE8_BINARY_MAX + 7) / 8]; + union { + char bitdata[(AIS_TYPE8_BINARY_MAX + 7) / 8]; + /* IMO236 - Fairway Closed */ + struct { + char reason[20+1]; /* Reason For Closing */ + char closefrom[20+1]; /* Location Of Closing From */ + char closeto[20+1]; /* Location of Closing To */ + unsigned int radius; /* Radius extension */ +#define AIS_DAC1FID13_RADIUS_NOT_AVAILABLE 10001 + unsigned int extunit; /* Unit of extension */ +#define AIS_DAC1FID13_EXTUNIT_NOT_AVAILABLE 0 + unsigned int fday; /* From day (UTC) */ + unsigned int fmonth; /* From month (UTC) */ + unsigned int fhour; /* From hour (UTC) */ + unsigned int fminute; /* From minute (UTC) */ + unsigned int tday; /* To day (UTC) */ + unsigned int tmonth; /* To month (UTC) */ + unsigned int thour; /* To hour (UTC) */ + unsigned int tminute; /* To minute (UTC) */ + } dac1fid13; + /* IMO236 - Extended ship and voyage data */ + struct { + unsigned int airdraught; /* Air Draught */ + } dac1fid15; + /* IMO289 - VTS-generated/Synthetic Targets */ + struct { + signed int ntargets; + struct target_t { +#define DAC1FID17_IDTYPE_MMSI 0 +#define DAC1FID17_IDTYPE_IMO 1 +#define DAC1FID17_IDTYPE_CALLSIGN 2 +#define DAC1FID17_IDTYPE_OTHER 3 + unsigned int idtype; /* Identifier type */ + union target_id { /* Target identifier */ + unsigned int mmsi; + unsigned int imo; +#define DAC1FID17_ID_LENGTH 7 + char callsign[DAC1FID17_ID_LENGTH+1]; + char other[DAC1FID17_ID_LENGTH+1]; + } id; + signed int lat; /* Latitude */ + signed int lon; /* Longitude */ +#define DAC1FID17_COURSE_NOT_AVAILABLE 360 + unsigned int course; /* Course Over Ground */ + unsigned int second; /* Time Stamp */ +#define DAC1FID17_SPEED_NOT_AVAILABLE 255 + unsigned int speed; /* Speed Over Ground */ + } targets[4]; + } dac1fid17; + /* IMO 289 - Marine Traffic Signal */ + struct { + unsigned int linkage; /* Message Linkage ID */ + char station[20+1]; /* Name of Signal Station */ + signed int lon; /* Longitude */ + signed int lat; /* Latitude */ + unsigned int status; /* Status of Signal */ + unsigned int signal; /* Signal In Service */ + unsigned int hour; /* UTC hour */ + unsigned int minute; /* UTC minute */ + unsigned int nextsignal; /* Expected Next Signal */ + } dac1fid19; + /* IMO289 - Route info (broadcast) */ + struct route_info dac1fid27; + /* IMO289 - Text message (broadcast) */ + struct { + unsigned int linkage; +#define AIS_DAC1FID29_TEXT_MAX 162 /* 920 bits of six-bit, plus NUL */ + char text[AIS_DAC1FID29_TEXT_MAX]; + } dac1fid29; + /* IMO236 & IMO289 - Meteorological-Hydrological data */ + struct { + bool accuracy; /* position accuracy, <10m if true */ +#define DAC1FID31_LATLON_SCALE 1000 + int lon; /* longitude in minutes * .001 */ +#define DAC1FID31_LON_NOT_AVAILABLE (181*60*DAC1FID31_LATLON_SCALE) + int lat; /* longitude in minutes * .001 */ +#define DAC1FID31_LAT_NOT_AVAILABLE (91*60*DAC1FID31_LATLON_SCALE) + unsigned int day; /* UTC day */ + unsigned int hour; /* UTC hour */ + unsigned int minute; /* UTC minute */ + unsigned int wspeed; /* average wind speed */ + unsigned int wgust; /* wind gust */ +#define DAC1FID31_WIND_HIGH 126 +#define DAC1FID31_WIND_NOT_AVAILABLE 127 + unsigned int wdir; /* wind direction */ + unsigned int wgustdir; /* wind gust direction */ +#define DAC1FID31_DIR_NOT_AVAILABLE 360 + int airtemp; /* temperature, units 0.1C */ +#define DAC1FID31_AIRTEMP_NOT_AVAILABLE -1084 + unsigned int humidity; /* relative humidity, % */ +#define DAC1FID31_HUMIDITY_NOT_AVAILABLE 101 + int dewpoint; /* dew point, units 0.1C */ +#define DAC1FID31_DEWPOINT_NOT_AVAILABLE 501 + unsigned int pressure; /* air pressure, hpa */ +#define DAC1FID31_PRESSURE_NOT_AVAILABLE 511 +#define DAC1FID31_PRESSURE_HIGH 402 + unsigned int pressuretend; /* tendency */ +#define DAC1FID31_PRESSURETREND_NOT_AVAILABLE 3 + bool visgreater; /* visibility greater than */ + unsigned int visibility; /* units 0.1 nautical miles */ +#define DAC1FID31_VISIBILITY_NOT_AVAILABLE 127 + int waterlevel; /* decimeters or cm */ +#define DAC1FID11_WATERLEVEL_NOT_AVAILABLE 4001 +#define DAC1FID31_WATERLEVEL_NOT_AVAILABLE 40001 + unsigned int leveltrend; /* water level trend code */ +#define DAC1FID31_LEVELTREND_NOT_AVAILABLE 3 + unsigned int cspeed; /* current speed in deciknots */ +#define DAC1FID31_CSPEED_NOT_AVAILABLE 255 + unsigned int cdir; /* current dir., degrees */ + unsigned int cspeed2; /* current speed in deciknots */ + unsigned int cdir2; /* current dir., degrees */ + unsigned int cdepth2; /* measurement depth, 0.1m */ +#define DAC1FID31_CDEPTH_NOT_AVAILABLE 301 + unsigned int cspeed3; /* current speed in deciknots */ + unsigned int cdir3; /* current dir., degrees */ + unsigned int cdepth3; /* measurement depth, 0.1m */ + unsigned int waveheight; /* in decimeters */ +#define DAC1FID31_HEIGHT_NOT_AVAILABLE 31 + unsigned int waveperiod; /* in seconds */ +#define DAC1FID31_PERIOD_NOT_AVAILABLE 63 + unsigned int wavedir; /* direction in degrees */ + unsigned int swellheight; /* in decimeters */ + unsigned int swellperiod; /* in seconds */ + unsigned int swelldir; /* direction in degrees */ + unsigned int seastate; /* Beaufort scale, 0-12 */ +#define DAC1FID31_SEASTATE_NOT_AVAILABLE 15 + int watertemp; /* units 0.1deg Celsius */ +#define DAC1FID31_PRECIPTYPE_NOT_AVAILABLE 7 + unsigned int preciptype; /* 0-7, enumerated */ + unsigned int salinity; /* units of 0.1% */ +#define DAC1FID31_SALINITY_NOT_AVAILABLE 510 + bool ice; /* is there sea ice? */ + } dac1fid31; + }; } type8; /* Type 9 - Standard SAR Aircraft Position Report */ struct { @@ -825,6 +1468,22 @@ struct ais_t char bitdata[(AIS_TYPE26_BINARY_MAX + 7) / 8]; unsigned int radio; /* radio status bits */ } type26; + /* Type 27 - Long Range AIS Broadcast message */ + struct { + bool accuracy; /* position accuracy */ + bool raim; /* RAIM flag */ + unsigned int status; /* navigation status */ +#define AIS_LONGRANGE_LATLON_SCALE 600.0 + int lon; /* longitude */ +#define AIS_LONGRANGE_LON_NOT_AVAILABLE 0x1a838 + int lat; /* latitude */ +#define AIS_LONGRANGE_LAT_NOT_AVAILABLE 0xd548 + unsigned int speed; /* speed over ground in deciknots */ +#define AIS_LONGRANGE_SPEED_NOT_AVAILABLE 63 + unsigned int course; /* course over ground */ +#define AIS_LONGRANGE_COURSE_NOT_AVAILABLE 511 + bool gnss; /* are we reporting GNSS position? */ + } type27; }; }; @@ -880,6 +1539,7 @@ struct version_t { char release[64]; /* external version */ char rev[64]; /* internal revision ID */ int proto_major, proto_minor; /* API major and minor versions */ + char remote[GPS_PATH_MAX]; /* could be from a remote device */ }; struct devconfig_t { @@ -905,7 +1565,9 @@ struct policy_t { int raw; /* requesting raw data? */ bool scaled; /* requesting report scaling? */ bool timing; /* requesting timing info */ - char devpath[GPS_PATH_MAX]; /* specific device to watch */ + int loglevel; /* requested log level of messages */ + char devpath[GPS_PATH_MAX]; /* specific device to watch */ + char remote[GPS_PATH_MAX]; /* ...if this was passthrough */ }; /* @@ -917,17 +1579,17 @@ struct policy_t { typedef int socket_t; /* mode flags for setting streaming policy */ -#define WATCH_ENABLE 0x0001u /* enable streaming */ -#define WATCH_JSON 0x0002u /* enable JSON output */ -#define WATCH_NMEA 0x0004u /* enable output in NMEA */ -#define WATCH_RARE 0x0008u /* enable output of packets in hex */ -#define WATCH_RAW 0x0010u /* enable output of raw packets */ -#define WATCH_SCALED 0x0020u /* scale output to floats, when applicable */ -#define WATCH_NEWSTYLE 0x0040u /* force JSON streaming */ -#define WATCH_OLDSTYLE 0x0080u /* force old-style streaming */ -#define WATCH_DEVICE 0x0100u /* watch specific device */ -#define WATCH_DISABLE 0x0200u /* disable watching */ -#define POLL_NONBLOCK 0x1000u /* set non-blocking poll (experimental!) */ +#define WATCH_ENABLE 0x000001u /* enable streaming */ +#define WATCH_DISABLE 0x000002u /* disable watching */ +#define WATCH_JSON 0x000010u /* JSON output */ +#define WATCH_NMEA 0x000020u /* output in NMEA */ +#define WATCH_RARE 0x000040u /* output of packets in hex */ +#define WATCH_RAW 0x000080u /* output of raw packets */ +#define WATCH_SCALED 0x000100u /* scale output to floats */ +#define WATCH_TIMING 0x000200u /* timing information */ +#define WATCH_DEVICE 0x000800u /* watch specific device */ +#define WATCH_NEWSTYLE 0x010000u /* force JSON streaming */ +#define WATCH_OLDSTYLE 0x020000u /* force old-style streaming */ /* * Main structure that includes all previous substructures @@ -935,38 +1597,39 @@ typedef int socket_t; struct gps_data_t { gps_mask_t set; /* has field been set since this was last cleared? */ -#define ONLINE_SET 0x00000001u -#define TIME_SET 0x00000002u -#define TIMERR_SET 0x00000004u -#define LATLON_SET 0x00000008u -#define ALTITUDE_SET 0x00000010u -#define SPEED_SET 0x00000020u -#define TRACK_SET 0x00000040u -#define CLIMB_SET 0x00000080u -#define STATUS_SET 0x00000100u -#define MODE_SET 0x00000200u -#define DOP_SET 0x00000400u -#define VERSION_SET 0x00000800u -#define HERR_SET 0x00001000u -#define VERR_SET 0x00002000u -#define ATTITUDE_SET 0x00004000u -#define POLICY_SET 0x00008000u -#define SATELLITE_SET 0x00010000u -#define RAW_SET 0x00020000u -#define USED_SET 0x00040000u -#define SPEEDERR_SET 0x00080000u -#define TRACKERR_SET 0x00100000u -#define CLIMBERR_SET 0x00200000u -#define DEVICE_SET 0x00400000u -#define DEVICELIST_SET 0x00800000u -#define DEVICEID_SET 0x01000000u -#define ERROR_SET 0x02000000u -#define RTCM2_SET 0x04000000u -#define RTCM3_SET 0x08000000u -#define AIS_SET 0x10000000u -#define PACKET_SET 0x20000000u -#define AUXDATA_SET 0x80000000u /* reserved */ - double online; /* NZ if GPS is on line, 0 if not. +#define ONLINE_SET (1llu<<1) +#define TIME_SET (1llu<<2) +#define TIMERR_SET (1llu<<3) +#define LATLON_SET (1llu<<4) +#define ALTITUDE_SET (1llu<<5) +#define SPEED_SET (1llu<<6) +#define TRACK_SET (1llu<<7) +#define CLIMB_SET (1llu<<8) +#define STATUS_SET (1llu<<9) +#define MODE_SET (1llu<<10) +#define DOP_SET (1llu<<11) +#define HERR_SET (1llu<<12) +#define VERR_SET (1llu<<13) +#define ATTITUDE_SET (1llu<<14) +#define SATELLITE_SET (1llu<<15) +#define SPEEDERR_SET (1llu<<16) +#define TRACKERR_SET (1llu<<17) +#define CLIMBERR_SET (1llu<<18) +#define DEVICE_SET (1llu<<19) +#define DEVICELIST_SET (1llu<<20) +#define DEVICEID_SET (1llu<<21) +#define RTCM2_SET (1llu<<22) +#define RTCM3_SET (1llu<<23) +#define AIS_SET (1llu<<24) +#define PACKET_SET (1llu<<25) +#define SUBFRAME_SET (1llu<<26) +#define GST_SET (1llu<<27) +#define VERSION_SET (1llu<<28) +#define POLICY_SET (1llu<<29) +#define LOGMESSAGE_SET (1llu<<30) +#define ERROR_SET (1llu<<31) +#define SET_HIGH_BIT 31 + timestamp_t online; /* NZ if GPS is on line, 0 if not. * * Note: gpsd clears this time when sentences * fail to show up within the GPS's normal @@ -1000,7 +1663,7 @@ struct gps_data_t { double epe; /* spherical position error, 95% confidence (meters) */ /* satellite status -- valid when satellites_visible > 0 */ - double skyview_time; /* skyview timestamp */ + timestamp_t skyview_time; /* skyview timestamp */ int satellites_visible; /* # of satellites in view */ int PRN[MAXCHANNELS]; /* PRNs of satellite */ int elevation[MAXCHANNELS]; /* elevation of satellite */ @@ -1011,64 +1674,78 @@ struct gps_data_t { struct policy_t policy; /* our listening policy */ + /* should be moved to privdata sometday */ char tag[MAXTAGLEN+1]; /* tag of last sentence processed */ - void (*raw_hook)(struct gps_data_t *, char *, size_t len); /* Raw-mode hook for GPS data. */ - /* pack things never reported together to reduce structure size */ -#define UNION_SET (RTCM2_SET|RTCM3_SET|AIS_SET|VERSION_SET|DEVICELIST_SET|ERROR_SET) +#define UNION_SET (RTCM2_SET|RTCM3_SET|SUBFRAME_SET|AIS_SET|ATTITUDE_SET|VERSION_SET|DEVICELIST_SET|LOGMESSAGE_SET|ERROR_SET|GST_SET|VERSION_SET) union { /* unusual forms of sensor data that might come up the pipe */ struct rtcm2_t rtcm2; struct rtcm3_t rtcm3; + struct subframe_t subframe; struct ais_t ais; struct attitude_t attitude; struct rawdata_t raw; + struct gst_t gst; /* "artificial" structures for various protocol responses */ struct version_t version; struct { - double time; + timestamp_t time; int ndevices; struct devconfig_t list[MAXUSERDEVS]; } devices; - char error[80]; + char error[256]; }; /* Private data - client code must not set this */ void *privdata; }; -extern int gps_open_r(const char *host, const char *, +extern int gps_open(/*@null@*/const char *, /*@null@*/const char *, /*@out@*/struct gps_data_t *); -extern /*@null@*/struct gps_data_t *gps_open(const char *, const char *); extern int gps_close(struct gps_data_t *); extern int gps_send(struct gps_data_t *, const char *, ... ); -extern int gps_poll(struct gps_data_t *); -extern bool gps_waiting(struct gps_data_t *); +extern int gps_read(/*@out@*/struct gps_data_t *); +extern int gps_unpack(char *, struct gps_data_t *); +extern bool gps_waiting(const struct gps_data_t *, int); extern int gps_stream(struct gps_data_t *, unsigned int, /*@null@*/void *); -extern void gps_set_raw_hook(struct gps_data_t *, - void (*)(struct gps_data_t *, char *, size_t)); -extern char /*@observer@*/ *gps_errstr(const int); +extern const char /*@observer@*/ *gps_data(const struct gps_data_t *); +extern const char /*@observer@*/ *gps_errstr(const int); -/* this only needs to be visible for the unit tests */ -extern int gps_unpack(char *, struct gps_data_t *); +extern int gps_sock_open(/*@null@*/const char *, /*@null@*/const char *, + /*@out@*/struct gps_data_t *); +extern int gps_sock_read(/*@out@*/struct gps_data_t *); +extern int gps_sock_close(struct gps_data_t *); +extern int gps_sock_send(struct gps_data_t *, const char *); +extern int gps_shm_open(/*@out@*/struct gps_data_t *); +extern int gps_shm_read(struct gps_data_t *); +extern bool gps_sock_waiting(const struct gps_data_t *, int); +extern int gps_sock_stream(struct gps_data_t *, unsigned int, /*@null@*/void *); +extern const char /*@observer@*/ *gps_sock_data(const struct gps_data_t *); +extern void gps_shm_close(struct gps_data_t *); + +extern void libgps_trace(int errlevel, const char *, ...); /* dependencies on struct gpsdata_t end hrere */ extern void gps_clear_fix(/*@ out @*/struct gps_fix_t *); +extern void gps_clear_dop( /*@out@*/ struct dop_t *); extern void gps_merge_fix(/*@ out @*/struct gps_fix_t *, gps_mask_t, /*@ in @*/struct gps_fix_t *); extern void gps_enable_debug(int, FILE *); extern /*@observer@*/const char *gps_maskdump(gps_mask_t); +extern double safe_atof(const char *); extern time_t mkgmtime(register struct tm *); -extern double timestamp(void); -extern double iso8601_to_unix(char *); -extern /*@observer@*/char *unix_to_iso8601(double t, /*@ out @*/char[], size_t len); -extern double gpstime_to_unix(int, double); -extern void unix_to_gpstime(double, /*@out@*/int *, /*@out@*/double *); +extern timestamp_t timestamp(void); +extern timestamp_t iso8601_to_unix(char *); +extern /*@observer@*/char *unix_to_iso8601(timestamp_t t, /*@ out @*/char[], size_t len); extern double earth_distance(double, double, double, double); +extern double earth_distance_and_bearings(double, double, double, double, + /*@null@*//*@out@*/double *, + /*@null@*//*@out@*/double *); extern double wgs84_separation(double, double); /* some multipliers for interpreting GPS output */ @@ -1092,17 +1769,38 @@ extern double wgs84_separation(double, double); #define WGS84F 298.257223563 /* flattening */ #define WGS84B 6356752.3142 /* polar radius */ -/* gps_open() errno return values */ +/* netlib_connectsock() errno return values */ #define NL_NOSERVICE -1 /* can't get service entry */ #define NL_NOHOST -2 /* can't get host entry */ #define NL_NOPROTO -3 /* can't get protocol entry */ #define NL_NOSOCK -4 /* can't create socket */ #define NL_NOSOCKOPT -5 /* error SETSOCKOPT SO_REUSEADDR */ #define NL_NOCONNECT -6 /* can't connect to host/socket pair */ +#define SHM_NOSHARED -7 /* shared-memory segment not available */ +#define SHM_NOATTACH -8 /* shared-memory attach failed */ #define DEFAULT_GPSD_PORT "2947" /* IANA assignment */ #define DEFAULT_RTCM_PORT "2101" /* IANA assignment */ +/* special host values for non-socket exports */ +#define GPSD_SHARED_MEMORY "shared memory" + +/* + * Platform-specific declarations + */ + +#ifdef _WIN32 +#define strtok_r(s,d,p) strtok_s(s,d,p) +#endif + +/* Some libc's don't have strlcat/strlcpy. Local copies are provided */ +#ifndef HAVE_STRLCAT +size_t strlcat(/*@out@*/char *dst, /*@in@*/const char *src, size_t size); +#endif +#ifndef HAVE_STRLCPY +size_t strlcpy(/*@out@*/char *dst, /*@in@*/const char *src, size_t size); +#endif + #ifdef __cplusplus } /* End of the 'extern "C"' block */ #endif |