gps.h 129 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913
  1. /* gps.h -- interface of the libgps library
  2. *
  3. * This file is Copyright 2010 by the GPSD project
  4. * SPDX-License-Identifier: BSD-2-clause
  5. */
  6. #ifndef _GPSD_GPS_H_
  7. #define _GPSD_GPS_H_
  8. #ifdef __cplusplus
  9. extern "C" {
  10. #endif
  11. #include <inttypes.h> // stdint.h would be smaller but not all have it
  12. #include <limits.h>
  13. #include <pthread.h> // pacifies OpenBSD's compiler
  14. #include <signal.h>
  15. #include <stdbool.h>
  16. #include <stdint.h>
  17. #include <stdio.h>
  18. #include <sys/time.h> // for struct timespec
  19. #include <sys/types.h>
  20. #include <time.h>
  21. /*
  22. * 4.1 - Base version for initial JSON protocol (Dec 2009, release 2.90)
  23. * 4.2 - AIS application IDs split into DAC and FID (July 2010, release 2.95)
  24. * 5.0 - MAXCHANNELS bumped from 20 to 32 for GLONASS (Mar 2011, release 2.96)
  25. * gps_open() becomes reentrant, what gps_open_r() used to be.
  26. * gps_poll() removed in favor of gps_read(). The raw hook is gone.
  27. * (Aug 2011, release 3.0)
  28. * 5.1 - GPS_PATH_MAX uses system PATH_MAX; split24 flag added. New
  29. * model and serial members in part B of AIS type 24, conforming
  30. * with ITU-R 1371-4. New timedrift structure (Nov 2013, release 3.10).
  31. * 6.0 - AIS type 6 and 8 get 'structured' flag; GPS_PATH_MAX
  32. * shortened because devices has moved out of the tail union. Sentence
  33. * tag fields dropped from emitted JSON. The shape of the skyview
  34. * structure has changed to make working with the satellites-used
  35. * bits less confusing. (January 2015, release 3.12).
  36. * 6.1 - Add navdata_t for more (nmea2000) info.
  37. * 7.0 - add gps_fix_t.ecef (February 2018)
  38. * changed prototype of gps_read() to add buffer parameters
  39. * increased length of devconfig_t.subtype
  40. * add gnssid:svid:sigid to satellite_t
  41. * add mtime to attitude_t
  42. * changed MAXCHANNELS
  43. * 8.0 - Change shape of rawdata_t.
  44. * Added values for gps_data_t->status
  45. * Remove epe from gps_data_t, it duplicates gps_fix_t eph
  46. * Added sep (estimated spherical error, 3D)
  47. * Note: Some GPS call eph as epe, others call sep as epe
  48. * Add gps_fix_t datum string, and qErr
  49. * enlarge subtype to hold ZED-F9 string
  50. * MAXCHANNELS bumped from 120 to 140
  51. * Try to make PRN be NMEA 2.x-4.0 compliant, not 4.10 or u-blox
  52. * 9.0 add NED and geoid_sep variables to gps_fix_t
  53. * add health variable to satellite_t
  54. * change satellite_t elevation and azimuth to double
  55. * satellite_t elevation, azimuth, and ss use NAN for unknown value.
  56. * add altMSL, and depth, to gps_fix_t
  57. * add altHAE to gps_fix_t
  58. * mark altitude in gps_fix_t as deprecated and undefined
  59. * Move mag_var from gps_device_t to magnetic_var gps_data_t.
  60. * add dgps_age and dgps_station, to gps_fix_t
  61. * Change gps_fix_t.time from timestamp_t to timespec_t
  62. * Change gps_data_t.skyview_time from timestamp_t to timespec_t
  63. * Change gps_data_t.online from timestamp_t to timespec_t
  64. * Change gpst_t.utctime from double to timespec_t
  65. * Change devices.time from timestamp_t to timespec_t
  66. * Change sub4_18.d_tot from timestamp_t to time_t t_tot
  67. * Change devconfig_t.activated, cycle & mincycle to timespec_t
  68. * Remove unused timestamp() and unix_to_iso8601().
  69. * Remove unused iso8601_to_unix().
  70. * Remove unused struct timestamp_t entirely
  71. * Add DEG_NORM()
  72. * Move toff and pps out of gps_data_t.union.
  73. * Move gps_fix_t.qErr to gps_data_t.
  74. * Split devconfig_t.subtype into subtype and subtype1
  75. * 9.1 Add leap_seconds to gps_data_t
  76. * Fix rtcm3_1029_t.text length
  77. * Add/change many rtcm2 structs
  78. * Add/change many rtcm3 structs
  79. * 10 Move gps_data_t->status to gps_fix_t.status for better fix merging
  80. * Add wspeedt, wspeedr, wanglem, wanglet, wangler to gps_fix_t
  81. * Remove unused gps_data_t.navadata_t.
  82. * Add relPosL and relPosH to gps_fix_t.NED
  83. * 11 long l_toa becomes unsigned long l_toa
  84. * fix sub4_18 types.
  85. * 12 subframe_t expanded for more gnssId's, WN, etc.
  86. * Add orbit_t for generic orbital parameters
  87. * Add subframe.orbit and subframe.orbit1 to store orbit_t's
  88. * Add gyro_temp, gyro_z, msg, timeTag, to attitude_t
  89. * add imu[], and matching IMU_SET flag
  90. * move attitude out of the union, to stop conflicts.
  91. * 13 Add rtcm3_msm
  92. * fix tow in never used struct rtcm3_1015_t
  93. * remove never used struct rtcm3_1016_t and struct rtcm3_1017_t
  94. *
  95. */
  96. #define GPSD_API_MAJOR_VERSION 13 // bump on incompatible changes
  97. #define GPSD_API_MINOR_VERSION 0 // bump on compatible changes
  98. #define MAXCHANNELS 140 // u-blox 9 tracks 140 signals
  99. #define MAXUSERDEVS 4 // max devices per user
  100. #define GPS_PATH_MAX 128 // for names like /dev/serial/by-id/...
  101. // normalize degrees to 0 to 359
  102. #define DEG_NORM(deg) \
  103. if (0 > (deg)) {(deg) += 360;} else if (360 <= (deg)) {(deg) -= 360;};
  104. /*
  105. * The structure describing an uncertainty volume in kinematic space.
  106. * This is what GPSes are meant to produce; all the other info is
  107. * technical impedimenta.
  108. *
  109. * All the information in this structure was considered "valid"
  110. * by the GPS at the time of update. But "valid" doubles are likely
  111. * the same as NaN. Check "gps_mask_t set" before using integers and flags.
  112. *
  113. * Error estimates are at 95% confidence. Except when they are not.
  114. *
  115. * WARNING! loss of precision telling time as a double.
  116. * UNIX time to nanoSec precision is 62 significant bits
  117. * UNIX time to nanoSec precision after 2038 is 63 bits
  118. * That is why gpsd uses struct timespec.
  119. *
  120. * For more info: https://gpsd.io/gpsd-numbers-matter.html
  121. *
  122. * The u-blox ZED-F9P reports 0.1 mm, and 1e-9 (0.000000001) degree,
  123. * precision. That is about 12 decimal digits of precision.
  124. * It is certainly not that accurate, maybe soon.
  125. *
  126. * this easily fits in a C double which has 15.95 digits of precision
  127. * printf() format %f defaults to %.6f, which will truncate the result.
  128. * so print with %.7f, or even %9f, if you have a survey grade GPS.
  129. *
  130. * For more info: https://gpsd.io/gpsd-numbers-matter.html
  131. *
  132. * All double values use NAN to indicate data not available.
  133. * WARNING: Check all floats and doubles with isfinite() before using them!
  134. * isnan() is not sufficient.
  135. *
  136. * For more info: https://gps.io/gpsd-numbers-matter.html
  137. */
  138. typedef struct timespec timespec_t; // Unix time as sec, nsec
  139. /* GPS error estimates are all over the map, and often unspecified.
  140. * try for 1-sigma if we can... */
  141. struct gps_fix_t {
  142. timespec_t time; // Time of update
  143. int mode; // Mode of fix
  144. #define MODE_NOT_SEEN 0 // mode update not seen yet
  145. #define MODE_NO_FIX 1 // none
  146. #define MODE_2D 2 // good for latitude/longitude
  147. #define MODE_3D 3 // good for altitude/climb too
  148. /* GPS status, aka fix type, is a modifier (adjective) to
  149. * gps_data.mode. It is not a replacement for, or superset of, mode.
  150. * It is almost, but not quite, the same as the NMEA 4.x xxGGA GPS
  151. * Quality Indicator Values. Many GNSS receivers do not supply it.
  152. */
  153. int status; // What kind of fix?
  154. #define STATUS_UNK 0 // Unknown status
  155. // plain GPS (SPS Mode), without DGPS, PPS, RTK, DR, etc.
  156. #define STATUS_GPS 1
  157. #define STATUS_DGPS 2 // with DGPS
  158. #define STATUS_RTK_FIX 3 // with RTK Fixed
  159. #define STATUS_RTK_FLT 4 // with RTK Float
  160. #define STATUS_DR 5 // with dead reckoning
  161. #define STATUS_GNSSDR 6 // with GNSS + dead reckoning
  162. #define STATUS_TIME 7 // time only (surveyed in, manual)
  163. // Note that STATUS_SIM and MODE_NO_FIX can go together.
  164. #define STATUS_SIM 8 // simulated
  165. /* yes, Precise Positioning Service (PPS)
  166. * Not to be confused with Pulse per Second (PPS)
  167. * PPS is the encrypted military P(Y)-code */
  168. #define STATUS_PPS_FIX 9
  169. double ept; // Expected time uncertainty, seconds
  170. double latitude; // Latitude in degrees (valid if mode >= 2)
  171. double epy; // Latitude position uncertainty, meters
  172. double longitude; // Longitude in degrees (valid if mode >= 2)
  173. double epx; // Longitude position uncertainty, meters
  174. double altitude; // DEPRECATED, undefined.
  175. double altHAE; /* Altitude, height above ellipsoid.
  176. * in meters and probably WGS84
  177. * (valid if mode == 3)
  178. * MSL = altHAE - geoid_sep */
  179. double altMSL; // Altitude MSL (maybe EGM2008)
  180. double epv; // Vertical position uncertainty, meters
  181. double track; // Course made good (relative to true north)
  182. double epd; // Track uncertainty, degrees
  183. double speed; // Speed over ground, meters/sec
  184. double eps; // Speed uncertainty, meters/sec
  185. double climb; // Vertical speed, meters/sec
  186. double epc; // Vertical speed uncertainty
  187. // estimated position error horizontal (2D). Meters, maybe 50%, maybe 95%
  188. // aka estimated position error (epe)
  189. double eph; // estimated position error horizontal (2D)
  190. // spherical error probability, 3D. Meters, maybe 50%, maybe 95%
  191. // Garmin, not gpsd, calls this estimated position error (epe)
  192. double sep;
  193. /* Geoid separation (ellipsoid separation)
  194. * Height of MSL ellipsoid (geoid) above WGS84 ellipsoid.
  195. * Positive is MSL above WGS84. In meters */
  196. double geoid_sep;
  197. double magnetic_track; // Course (relative to Magnetic North)
  198. double magnetic_var; // magnetic variation in degrees
  199. // depth in meters, probably depth of water under the keel
  200. double depth;
  201. // ECEF data, all data in meters, and meters/second, or NaN
  202. struct {
  203. double x, y, z; // ECEF x, y, z
  204. double pAcc; // 3D Position Accuracy Estimate, likely SEP
  205. double vx, vy, vz; // ECEF x, y, z velocity
  206. double vAcc; // Velocity Accuracy Estimate, probably SEP
  207. } ecef;
  208. // NED data, all data in meters, and meters/second, or NaN
  209. struct {
  210. double relPosN, relPosE, relPosD; // NED relative positions
  211. double relPosL, relPosH; // relative length and heading
  212. double velN, velE, velD; // NED velocities
  213. } NED;
  214. char datum[40]; // map datum
  215. // DGPS stuff, often from xxGGA, or xxGNS
  216. double dgps_age; // age of DGPS data in tenths of seconds, -1 invalid
  217. /* DGPS Station used, max size is a guess
  218. * NMEA 2 says 0000-1023
  219. * RTCM 3, station ID is 0 to 4095.
  220. * u-blox UBX-NAV-DGPS is 16 bit integer */
  221. int dgps_station; // DGPS station ID, -1 invalid
  222. double wanglem; // Wind angle, magnetic, m/s
  223. double wangler; // Wind angle, relative, m/s
  224. double wanglet; // Wind angle, true, m/s
  225. double wspeedr; // Wind speed, relative, m/s
  226. double wspeedt; // Wind speed, true, m/s
  227. };
  228. /* Some GNSS receivers, like u-blox 8, can log fixes for later use.
  229. * That data goes in gps_log_t
  230. * Check all doubles with isfinite() before using
  231. */
  232. struct gps_log_t {
  233. double lon; // degrees
  234. double lat; // degrees
  235. double altHAE; // Height above Ellipsoid, meters
  236. double altMSL; // Mean Sea Level, meters
  237. double gSpeed; // Ground Speed, meters per second
  238. double heading; // true heading, degrees
  239. /* The accuracy estimates are near useless as they are not defined
  240. * statistically as CEP(50), one sigma, two sigma, etc.
  241. */
  242. double tAcc; // Time accuracy estimate, nano seconds
  243. double hAcc; // Horizontal accuracy estimate, meters
  244. double vAcc; // Vertical accuracy estimate, meters
  245. double sAcc; // Speed accuracy estimate, meters per second
  246. double headAcc; // Heading accuracy estimate, degrees
  247. double velN; // NED north velocity, meters per second
  248. double velE; // NED east velocity, meters per second
  249. double velD; // NED down velocity, meters per second
  250. double pDOP; // Position DOP
  251. // Odometer data
  252. double distance; // Ground distance since last reset, meters
  253. double totalDistance; // Total cumulative distance, meters
  254. double distanceStd; // Ground distance accuracy (1-sigma)
  255. timespec_t then; // time of log entry, zero if invalid
  256. // GPS status -- always valid, same values as gps_fix_t.status
  257. int status; // type of fix?
  258. uint32_t index_cnt; // message counter
  259. char fixType; // -1 = unset, 0 = None, 2 == 2D, 3 = 3D
  260. // Number of satellites used in Nav Solution, zero if invalid
  261. unsigned char numSV;
  262. char string[257]; // 256 max plus NUL
  263. };
  264. /*
  265. * Other GNSS birds reuse GPS PRNs.
  266. * It is an NMEA0183 convention to map them to pseudo-PRNs 65..437.
  267. * Very dependent on NMEA version.
  268. * (some other GPS receivers push them to 33 and above).
  269. */
  270. #define GLONASS_PRN_OFFSET 64
  271. /*
  272. * The structure describing the pseudorange errors (GPGST)
  273. */
  274. struct gst_t {
  275. timespec_t utctime;
  276. double rms_deviation;
  277. double smajor_deviation;
  278. double sminor_deviation;
  279. double smajor_orientation;
  280. double lat_err_deviation;
  281. double lon_err_deviation;
  282. double alt_err_deviation;
  283. };
  284. /*
  285. * From the RCTM104 2.x standard:
  286. *
  287. * "The 30 bit words (as opposed to 32 bit words) coupled with a 50 Hz
  288. * transmission rate provides a convenient timing capability where the
  289. * times of word boundaries are a rational multiple of 0.6 seconds."
  290. *
  291. * "Each frame is N+2 words long, where N is the number of message data
  292. * words. For example, a filler message (type 6 or 34) with no message
  293. * data will have N=0, and will consist only of two header words. The
  294. * maximum number of data words allowed by the format is 31, so that
  295. * the longest possible message will have a total of 33 words."
  296. */
  297. #define RTCM2_WORDS_MAX 33
  298. #define MAXCORRECTIONS 18 // max correction count in type 1 or 9
  299. #define MAXSTATIONS 10 // maximum stations in almanac, type 5
  300. // RTCM104 doesn't specify this, so give it the largest reasonable value
  301. #define MAXHEALTH (RTCM2_WORDS_MAX-2)
  302. /*
  303. * A nominally 30-bit word (24 bits of data, 6 bits of parity)
  304. * used both in the GPS downlink protocol described in IS-GPS-200
  305. * and in the format for DGPS corrections used in RTCM-104v2.
  306. */
  307. typedef uint32_t isgps30bits_t;
  308. /*
  309. * Values for "system" fields. Note, the encoding logic is sensitive to the
  310. * actual values of these; it's not sufficient that they're distinct.
  311. */
  312. #define NAVSYSTEM_GPS 0
  313. #define NAVSYSTEM_GLONASS 1
  314. #define NAVSYSTEM_GALILEO 2
  315. #define NAVSYSTEM_UNKNOWN 3
  316. struct rtcm2_t {
  317. // header contents
  318. unsigned type; // RTCM message type
  319. unsigned length; // payload length (words) not including 2 word header
  320. double zcount; // time within hour: GPS time, no leap secs
  321. unsigned refstaid; // reference station ID
  322. unsigned seqnum; // message sequence number (modulo 8)
  323. unsigned stathlth; // station health
  324. // message data in decoded form
  325. // Reference Station data for type 3/4/22/23/24/32 messages
  326. struct {
  327. bool valid; // is message well-formed?
  328. double x, y, z; // reference station position ECEF, meters
  329. double dx, dy, dz; // delta reference station position ECEF, meters
  330. double ah; // antenna height (above RP) meters
  331. double dx2, dy2, dz2; // L2 delta ref station position ECEF, meters
  332. unsigned char gs; // 0 == GPS, 1 == GLONASS
  333. char ant_desc[33]; // antenna descriptor
  334. char ant_serial[33]; // antenna serial number
  335. char ar; // 1 == ARP (Type 24) will follow
  336. unsigned char setup_id; // 0 == use standard IGS model
  337. } ref_sta;
  338. // RTK corrections, type 18/19/20/21
  339. struct {
  340. unsigned tom; // GNSS Time of Measurement, 0-5999999 micro sec
  341. unsigned char f; // 00 = L1, 10 = L2, 01 and 11 reserved
  342. unsigned char sm; // smoothing interval
  343. unsigned int nentries;
  344. struct rtk_sat_t {
  345. unsigned char m; // multiple message indicator
  346. unsigned char pc; // 0 == C/A code, 1 == P-Code
  347. unsigned char g; // 0 == GPS, 1 == GLONASS
  348. // satellite id (1 - 32), GPS PRN, or GLONASS clot number
  349. unsigned char ident;
  350. unsigned char dq; // data qaulity
  351. unsigned char clc; // cumulative loss of continuity
  352. unsigned char iod; // Issue of Data (GPS)/Time of Day (GLO)
  353. unsigned char me; // multipath error
  354. int carrier_phase; // signed 32 bits, 1/256 cycle
  355. int pseudorange; // signed 32 bits, 0.02 m
  356. unsigned char rrc; // range rate correction
  357. } sat[15];
  358. } rtk;
  359. union {
  360. struct {
  361. unsigned int nentries;
  362. struct gps_rangesat_t { // data from messages 1 & 9
  363. unsigned ident; // satellite ID
  364. unsigned udre; // user differential range error
  365. unsigned iod; // issue of data
  366. double prc; // range error
  367. double rrc; // range error rate
  368. } sat[MAXCORRECTIONS];
  369. } gps_ranges;
  370. struct { // data from type 4 messages
  371. bool valid; // is message well-formed?
  372. int system;
  373. int sense;
  374. #define SENSE_INVALID 0
  375. #define SENSE_GLOBAL 1
  376. #define SENSE_LOCAL 2
  377. char datum[6];
  378. double dx, dy, dz;
  379. } reference;
  380. struct { // data from type 5 messages
  381. unsigned int nentries;
  382. struct consat_t {
  383. unsigned ident; // satellite ID
  384. bool iodl; // issue of data
  385. unsigned int health; // is satellite healthy?
  386. #define HEALTH_NORMAL (0) // Radiobeacon operation normal
  387. #define HEALTH_UNMONITORED (1) // No integrity monitor operating
  388. #define HEALTH_NOINFO (2) // No information available
  389. #define HEALTH_DONOTUSE (3) // Do not use this radiobeacon
  390. int snr; // signal-to-noise ratio, dB
  391. #define SNR_BAD -1 // not reported
  392. bool health_en; // health enabled
  393. bool new_data; // new data?
  394. bool los_warning; // line-of-sight warning
  395. unsigned int tou; // time to unhealth, seconds
  396. } sat[MAXHEALTH];
  397. } conhealth;
  398. struct { // data from type 7 messages
  399. unsigned int nentries;
  400. struct station_t {
  401. double latitude, longitude; // location
  402. unsigned int range; // range in km
  403. double frequency; // broadcast freq
  404. unsigned int health; // station health
  405. unsigned int station_id; // of the transmitter
  406. unsigned int bitrate; // of station transmissions
  407. } station[MAXSTATIONS];
  408. } almanac;
  409. struct { // data for type 13 messages
  410. bool status; // expect a text message
  411. bool rangeflag; // station range altered?
  412. double lat, lon; // station longitude/latitude
  413. unsigned int range; // transmission range in km
  414. } xmitter;
  415. struct { // data from type 14 messages
  416. unsigned int week; // GPS week (0-1023)
  417. unsigned int hour; // Hour in week (0-167)
  418. unsigned int leapsecs; // Leap seconds (0-63)
  419. } gpstime;
  420. struct { // RTCM2 type 18
  421. int tom; // time of measurement
  422. // FIXME: add in sat words
  423. } rtcm2_18;
  424. struct { // RTCM2 type 19
  425. int tom; // time of measurement
  426. // FIXME: add in sat words
  427. } rtcm2_19;
  428. struct { // RTCM2 type 20
  429. int tom; // time of measurement
  430. // FIXME: add in sat words
  431. } rtcm2_20;
  432. struct { // RTCM2 type 21
  433. int tom; // time of measurement
  434. // FIXME: add in sat words
  435. } rtcm2_21;
  436. struct { // RTCM2 type 22
  437. unsigned char ecef_dx; // L1 ECEF delta-x
  438. unsigned char ecef_dy; // L1 ECEF delta-y
  439. unsigned char ecef_dz; // L1 ECEF delta-z
  440. unsigned char gs; // 0 is GPS, 1 is GLONASS
  441. unsigned char ah_flag; // 1 if ah is valid
  442. int ah; // Ant Height meters
  443. unsigned char l2ecef_dx; // L2 ECEF delta-x
  444. unsigned char l2ecef_dy; // L2 ECEF delta-y
  445. unsigned char l2ecef_dz; // L2 ECEF delta-z
  446. } rtcm2_22;
  447. struct { // RTCM2 type 24
  448. int64_t ecef_x; // ECEF X (m * 10e-4)
  449. int64_t ecef_y; // ECEF Y (m * 10e-4)
  450. int64_t ecef_z; // ECEF Z (m * 10e-4)
  451. unsigned char gs; // 0 is GPS, 1 is GLONASS
  452. unsigned char ah_flag; // 1 if ah is valid
  453. int ah; // Ant Height meters
  454. } rtcm2_24;
  455. struct {
  456. unsigned int nentries;
  457. struct glonass_rangesat_t { // data from message type 31
  458. unsigned ident; // satellite ID
  459. unsigned udre; // user differential range error
  460. unsigned tod; // issue of data
  461. bool change; // ephemeris change bit
  462. double prc; // range error
  463. double rrc; // range error rate
  464. } sat[MAXCORRECTIONS];
  465. } glonass_ranges;
  466. // data from type 16 messages
  467. char message[(RTCM2_WORDS_MAX - 2) * sizeof(isgps30bits_t)];
  468. // data from messages of unknown type, not including header
  469. isgps30bits_t words[RTCM2_WORDS_MAX - 2];
  470. };
  471. };
  472. // RTCM3 report structures begin here
  473. #define RTCM3_MAX_SATELLITES 64
  474. #define RTCM3_MAX_DESCRIPTOR 31
  475. #define RTCM3_MAX_ANNOUNCEMENTS 32
  476. #define RTCM3_GRID_SIZE 16 // RTCM3_1023
  477. #define RTCM3_DF148_SIZE 10
  478. enum RTCM3_QUALITY_INDICATOR_TRANSFORMATION
  479. {
  480. TR_UNKNOWN,
  481. TR_BETTER_0021,
  482. TR_BETTER_0050,
  483. TR_BETTER_0200,
  484. TR_BETTER_0500,
  485. TR_BETTER_2000,
  486. TR_BETTER_5000,
  487. TR_WORSE_5001
  488. }; // DF214, DF215
  489. enum RTCM3_QUALITY_INDICATOR_GRID_RESIDUALS
  490. {
  491. GR_UNKNOWN,
  492. GR_BETTER_010,
  493. GR_BETTER_020,
  494. GR_BETTER_050,
  495. GR_BETTER_100,
  496. GR_BETTER_200,
  497. GR_BETTER_500,
  498. GR_WORSE_501
  499. }; // DF216, DF217
  500. enum RTCM3_INTERPOLATION_INDICATOR
  501. {
  502. INTERP_BI_LINEAR,
  503. INTERP_BI_QUADRIC,
  504. INTERP_BI_SPLINE,
  505. INTERP_RESERVED
  506. }; // DF212, DF213
  507. enum RTCM3_PROJECTION_TYPE
  508. {
  509. PR_UNKNOWN,
  510. PR_TM,
  511. PR_TMS,
  512. PR_LCC1SP,
  513. PR_LCC2SP,
  514. PR_LCCW,
  515. PR_CS
  516. }; // DF170
  517. // Used for both GPS and GLONASS, but their timebases differ
  518. struct rtcm3_rtk_hdr { // header data from 1001, 1002, 1003, 1004
  519. unsigned int station_id; // Reference Station ID
  520. time_t tow; // GNSS Epoch Time in ms
  521. bool sync; // Synchronous GNSS Message Flag
  522. unsigned short satcount; // # Satellite Signals Processed
  523. bool smoothing; // Divergence-free Smoothing Indicator
  524. unsigned int interval; // Smoothing Interval
  525. };
  526. struct rtcm3_basic_rtk {
  527. unsigned char indicator; // Indicator
  528. // Satellite Frequency Channel Number (GLONASS only)
  529. unsigned int channel;
  530. double pseudorange; // Pseudorange
  531. double rangediff; // PhaseRange - Pseudorange in meters
  532. unsigned char locktime; // Lock time Indicator
  533. };
  534. struct rtcm3_extended_rtk {
  535. unsigned char indicator; // Indicator
  536. // Satellite Frequency Channel Number (GLONASS only)
  537. unsigned int channel;
  538. double pseudorange; // Pseudorange
  539. double rangediff; // PhaseRange - L1 Pseudorange
  540. unsigned char locktime; // Lock time Indicator
  541. unsigned char ambiguity; // Integer Pseudorange Modulus Ambiguity
  542. double CNR; // Carrier-to-Noise Ratio
  543. };
  544. // satellite data from MSM1 and MSM7
  545. struct rtcm3_msm_sat {
  546. unsigned rr_ms; // Milliseconds in GNSS Satellite rough ranges
  547. unsigned ext_info; // Extended Satellite info
  548. unsigned rr_m1; // Rough ranges Modulo 1 Milliseconds
  549. int rates_rphr; // Rough PhaseRange rates
  550. };
  551. // signal data from MSM1 and MSM7
  552. struct rtcm3_msm_sig {
  553. int pseudo_r; // Signal fine Pseudoranges
  554. int32_t phase_r; // Signal fine Phaseranges
  555. unsigned lti; // Lock Time Indicator
  556. unsigned cnr; // Signal CNRs
  557. int rates_phr; // Phase Range Rates
  558. bool half_amb; // Half-cycle ambiguity indicator
  559. };
  560. // header data from MSM1 to MSM7
  561. // Used for all GNSS, but their timebases differ
  562. struct rtcm3_msm_hdr {
  563. unsigned station_id; // Reference Station ID
  564. time_t tow; // GNSS Epoch Time in ms
  565. bool sync; // Synchronous GNSS Message Flag
  566. unsigned IODS; // IODS - Issue of Data Station
  567. unsigned char reserved; // reserved
  568. unsigned char steering; // Clock Steering Indicator
  569. unsigned char ext_clk; // External Clock Indicator
  570. bool smoothing; // Divergence-free Smoothing Indicator
  571. unsigned interval; // Smoothing Interval
  572. uint64_t sat_mask; // Satellite Mask
  573. uint32_t sig_mask; // Signal Mask
  574. uint64_t cell_mask; // Cell Mask
  575. // not part of the network message:
  576. unsigned char gnssid; // gnssid
  577. unsigned char msm; // 1 to 7, MSMx
  578. unsigned char n_sat; // Number of satellites derived from sat_mask
  579. unsigned char n_sig; // Number of signals derived from sig_mask
  580. unsigned char n_cell; // no. of sats * no. of sigs (<=64!)
  581. struct rtcm3_msm_sat sat[RTCM3_MAX_SATELLITES];
  582. struct rtcm3_msm_sig sig[RTCM3_MAX_SATELLITES];
  583. };
  584. struct rtcm3_network_rtk_header {
  585. unsigned int network_id; // Network ID
  586. unsigned int subnetwork_id; // Subnetwork ID
  587. unsigned long tow; // GPS Epoch Time (TOW). scale 0.1 s
  588. bool multimesg; // GPS Multiple Message Indicator
  589. unsigned master_id; // Master Reference Station ID
  590. unsigned aux_id; // Auxiliary Reference Station ID
  591. unsigned char satcount; // count of GPS satellites
  592. };
  593. struct rtcm3_correction_diff {
  594. unsigned char ident; // satellite ID
  595. enum {RESERVED, CORRECT, WIDELANE, UNCERTAIN} ambiguity;
  596. unsigned char nonsync;
  597. // Geometric Carrier Phase Correction Difference (1016, 1017)
  598. double geometric_diff;
  599. unsigned char iode; // GPS IODE (1016, 1017)
  600. // Ionospheric Carrier Phase Correction Difference (1015, 1017)
  601. double ionospheric_diff;
  602. };
  603. struct rtcm3_t {
  604. // header contents
  605. unsigned type; // RTCM 3.x message number (type)
  606. unsigned length; // payload length, inclusive of checksum
  607. union {
  608. // 1001-1013 were present in the 3.0 version
  609. struct {
  610. struct rtcm3_rtk_hdr header;
  611. struct rtcm3_1001_t {
  612. unsigned ident; // Satellite ID
  613. struct rtcm3_basic_rtk L1;
  614. } rtk_data[RTCM3_MAX_SATELLITES];
  615. } rtcm3_1001;
  616. struct {
  617. struct rtcm3_rtk_hdr header;
  618. struct rtcm3_1002_t {
  619. unsigned ident; // Satellite ID
  620. struct rtcm3_extended_rtk L1;
  621. } rtk_data[RTCM3_MAX_SATELLITES];
  622. } rtcm3_1002;
  623. struct rtcm3_1003_t {
  624. struct rtcm3_rtk_hdr header;
  625. struct {
  626. unsigned ident; // Satellite ID
  627. struct rtcm3_basic_rtk L1;
  628. struct rtcm3_basic_rtk L2;
  629. } rtk_data[RTCM3_MAX_SATELLITES];
  630. } rtcm3_1003;
  631. struct rtcm3_1004_t {
  632. struct rtcm3_rtk_hdr header;
  633. struct {
  634. unsigned ident; // Satellite ID
  635. struct rtcm3_extended_rtk L1;
  636. struct rtcm3_extended_rtk L2;
  637. } rtk_data[RTCM3_MAX_SATELLITES];
  638. } rtcm3_1004;
  639. struct rtcm3_1005_t {
  640. unsigned int station_id; // Reference Station ID
  641. int system; // Which system is it?
  642. bool reference_station; // Reference-station indicator
  643. bool single_receiver; // Single Receiver Oscillator
  644. double ecef_x, ecef_y, ecef_z; // ECEF antenna location
  645. } rtcm3_1005;
  646. struct rtcm3_1006_t {
  647. unsigned int station_id; // Reference Station ID
  648. int system; // Which system is it?
  649. bool reference_station; // Reference-station indicator
  650. bool single_receiver; // Single Receiver Oscillator
  651. double ecef_x, ecef_y, ecef_z; // ECEF antenna location
  652. double height; // Antenna height
  653. } rtcm3_1006;
  654. struct {
  655. unsigned int station_id; // Reference Station ID
  656. char descriptor[RTCM3_MAX_DESCRIPTOR+1]; // Description string
  657. unsigned int setup_id;
  658. } rtcm3_1007;
  659. struct {
  660. unsigned int station_id; // Reference Station ID
  661. char descriptor[RTCM3_MAX_DESCRIPTOR+1]; // Description string
  662. unsigned int setup_id;
  663. char serial[RTCM3_MAX_DESCRIPTOR+1]; // Serial # string
  664. } rtcm3_1008;
  665. struct {
  666. struct rtcm3_rtk_hdr header;
  667. struct rtcm3_1009_t {
  668. unsigned ident; // Satellite ID
  669. struct rtcm3_basic_rtk L1;
  670. } rtk_data[RTCM3_MAX_SATELLITES];
  671. } rtcm3_1009;
  672. struct {
  673. struct rtcm3_rtk_hdr header;
  674. struct rtcm3_1010_t {
  675. unsigned ident; // Satellite ID
  676. struct rtcm3_extended_rtk L1;
  677. } rtk_data[RTCM3_MAX_SATELLITES];
  678. } rtcm3_1010;
  679. struct {
  680. struct rtcm3_rtk_hdr header;
  681. struct rtcm3_1011_t {
  682. unsigned ident; // Satellite ID
  683. struct rtcm3_extended_rtk L1;
  684. struct rtcm3_extended_rtk L2;
  685. } rtk_data[RTCM3_MAX_SATELLITES];
  686. } rtcm3_1011;
  687. struct {
  688. struct rtcm3_rtk_hdr header;
  689. struct rtcm3_1012_t {
  690. unsigned ident; // Satellite ID
  691. struct rtcm3_extended_rtk L1;
  692. struct rtcm3_extended_rtk L2;
  693. } rtk_data[RTCM3_MAX_SATELLITES];
  694. } rtcm3_1012;
  695. struct {
  696. unsigned int station_id; // Reference Station ID
  697. unsigned short mjd; // Modified Julian Day (MJD) Number
  698. unsigned int sod; // Seconds of Day (UTC)
  699. unsigned char leapsecs; // Leap Seconds, GPS-UTC
  700. unsigned char ncount; // Count of announcements to follow
  701. struct rtcm3_1013_t {
  702. unsigned short id; // message type ID
  703. bool sync;
  704. unsigned short interval; // interval in 0.1sec units
  705. } announcements[RTCM3_MAX_ANNOUNCEMENTS];
  706. } rtcm3_1013;
  707. // 1014-1017 were added in the 3.1 version
  708. struct rtcm3_1014_t {
  709. unsigned int network_id; // Network ID
  710. unsigned int subnetwork_id; // Subnetwork ID
  711. unsigned int stationcount; // # auxiliary stations transmitted
  712. unsigned int master_id; // Master Reference Station ID
  713. unsigned int aux_id; // Auxiliary Reference Station ID
  714. double d_lat, d_lon, d_alt; // Aux-master location delta
  715. } rtcm3_1014;
  716. struct rtcm3_1015_t {
  717. // used for 1015, 1016, and 1017
  718. struct rtcm3_network_rtk_header header;
  719. struct rtcm3_correction_diff corrections[RTCM3_MAX_SATELLITES];
  720. } rtcm3_1015;
  721. // 1018-1029 were in the 3.0 version
  722. struct rtcm3_1019_t {
  723. unsigned int ident; // Satellite ID
  724. unsigned int week; // GPS Week Number
  725. unsigned char sv_accuracy; // GPS SV ACCURACY
  726. enum {reserved_code, p, ca, l2c} code;
  727. double idot;
  728. unsigned char iode;
  729. // ephemeris fields, not scaled
  730. unsigned int t_sub_oc;
  731. signed int a_sub_f2;
  732. signed int a_sub_f1;
  733. signed int a_sub_f0;
  734. unsigned int iodc;
  735. signed int C_sub_rs;
  736. signed int delta_sub_n;
  737. signed int M_sub_0;
  738. signed int C_sub_uc;
  739. unsigned int e;
  740. signed int C_sub_us;
  741. unsigned int sqrt_sub_A;
  742. unsigned int t_sub_oe;
  743. signed int C_sub_ic;
  744. signed int OMEGA_sub_0;
  745. signed int C_sub_is;
  746. signed int i_sub_0;
  747. signed int C_sub_rc;
  748. signed int argument_of_perigee;
  749. signed int omegadot;
  750. signed int t_sub_GD;
  751. unsigned char sv_health;
  752. bool p_data;
  753. bool fit_interval;
  754. } rtcm3_1019;
  755. struct rtcm3_1020_t {
  756. unsigned int ident; // Satellite ID
  757. unsigned short channel; // Satellite Frequency Channel Number
  758. // ephemeris fields, not scaled
  759. bool C_sub_n;
  760. bool health_avAilability_indicator;
  761. unsigned char P1;
  762. unsigned short t_sub_k;
  763. bool msb_of_B_sub_n;
  764. bool P2;
  765. bool t_sub_b;
  766. signed int x_sub_n_t_of_t_sub_b_prime;
  767. signed int x_sub_n_t_of_t_sub_b;
  768. signed int x_sub_n_t_of_t_sub_b_prime_prime;
  769. signed int y_sub_n_t_of_t_sub_b_prime;
  770. signed int y_sub_n_t_of_t_sub_b;
  771. signed int y_sub_n_t_of_t_sub_b_prime_prime;
  772. signed int z_sub_n_t_of_t_sub_b_prime;
  773. signed int z_sub_n_t_of_t_sub_b;
  774. signed int z_sub_n_t_of_t_sub_b_prime_prime;
  775. bool P3;
  776. signed int gamma_sub_n_of_t_sub_b;
  777. unsigned char MP;
  778. bool Ml_n;
  779. signed int tau_n_of_t_sub_b;
  780. signed int M_delta_tau_sub_n;
  781. unsigned int E_sub_n;
  782. bool MP4;
  783. unsigned char MF_sub_T;
  784. unsigned char MN_sub_T;
  785. unsigned char MM;
  786. bool additioinal_data_availability;
  787. unsigned int N_sup_A;
  788. unsigned int tau_sub_c;
  789. unsigned int M_N_sub_4;
  790. signed int M_tau_sub_GPS;
  791. bool M_l_sub_n;
  792. } rtcm3_1020;
  793. struct rtcm3_1021_t {
  794. // size_t src_len;
  795. char src_name[RTCM3_MAX_DESCRIPTOR+1]; // DF144, Source-Name
  796. // size_t tar_len;
  797. char tar_name[RTCM3_MAX_DESCRIPTOR+1]; // DF146, Target-Name
  798. // DF147, System Identification Number
  799. unsigned int sys_id_num;
  800. // DF148, Utilized Transformation Message Indicator
  801. bool ut_tr_msg_id[RTCM3_DF148_SIZE];
  802. // DF149, Plate Number 0-31 values
  803. unsigned char plate_number;
  804. // DF150, Computation Indicator, 0-15 values
  805. unsigned char computation_id;
  806. enum {
  807. H_GEOMETRIC, H_PHYS_TAR, H_PHYS_SRC, H_RESERVED
  808. } height_id; // DF151, Height Indicator, 0-3 values
  809. // Latitude of Origin, Longitude of Origin
  810. double lat_origin, lon_origin;
  811. // N/S Extension, E/W Extension
  812. double lat_extension, lon_extension;
  813. double x_trans, y_trans, z_trans; // dX, dY, dZ
  814. double x_rot, y_rot, z_rot; // rX, rY, rZ
  815. double ds; // DF162, partial scale
  816. // Major|Minor-Axis-Source, Major|Minor-Axis-Target
  817. double add_as, add_bs, add_at, add_bt;
  818. // Horizontal Quality Indicator
  819. enum RTCM3_QUALITY_INDICATOR_TRANSFORMATION quality_hori;
  820. // Vertical Quality Indicator
  821. enum RTCM3_QUALITY_INDICATOR_TRANSFORMATION quality_vert;
  822. } rtcm3_1021;
  823. struct {
  824. // DF147, System Identification Number
  825. unsigned int sys_id_num;
  826. // Horizontal Shift indicator
  827. bool shift_id_hori;
  828. bool shift_id_vert; // Vertical Shift indicator
  829. // Latitude of Origin, Longitude of Origin
  830. double lat_origin, lon_origin;
  831. // grid Extension Latitude, grid Extension Longitude
  832. double lat_extension, lon_extension;
  833. // mean offset of latitude, longitude, and elevation
  834. double lat_mean, lon_mean, hgt_mean;
  835. // 4*4 residual grid points
  836. struct rtcm3_1023_t {
  837. double lat_res, lon_res, hgt_res;
  838. } residuals[RTCM3_GRID_SIZE];
  839. // Horizontal interpolation method indicator
  840. enum RTCM3_INTERPOLATION_INDICATOR interp_meth_id_hori;
  841. // Vertical interpolation method indicator
  842. enum RTCM3_INTERPOLATION_INDICATOR interp_meth_id_vert;
  843. // Horizontal Grid quality indicator
  844. enum RTCM3_QUALITY_INDICATOR_GRID_RESIDUALS grd_qual_id_hori;
  845. // Vertical Grid quality indicator
  846. enum RTCM3_QUALITY_INDICATOR_GRID_RESIDUALS grd_qual_id_vert;
  847. unsigned short mjd; // Modified Julian Date
  848. } rtcm3_1023;
  849. struct rtcm3_1025_t {
  850. // DF147, System Identification Number
  851. unsigned int sys_id_num;
  852. enum RTCM3_PROJECTION_TYPE projection_type; // Projection Types
  853. // Latitude of Origin, Longitude of Origin
  854. double lat_origin, lon_origin;
  855. double add_sno; // DF173
  856. double false_east, false_north; // DF174, DF175
  857. } rtcm3_1025;
  858. struct rtcm3_1029_t
  859. {
  860. unsigned int station_id; // Reference Station ID
  861. unsigned short mjd; // Modified Julian Day (MJD) Number
  862. unsigned int sod; // Seconds of Day (UTC)
  863. size_t len; // # chars to follow
  864. size_t unicode_units; // # Unicode units (bytes) in text
  865. unsigned char text[255];
  866. } rtcm3_1029;
  867. struct rtcm3_1033_t {
  868. unsigned int station_id; // Reference Station ID
  869. char descriptor[RTCM3_MAX_DESCRIPTOR+1]; // Description string
  870. unsigned int setup_id;
  871. char serial[RTCM3_MAX_DESCRIPTOR+1]; // Serial # string
  872. char receiver[RTCM3_MAX_DESCRIPTOR+1]; // Receiver string
  873. char firmware[RTCM3_MAX_DESCRIPTOR+1]; // Firmware string
  874. } rtcm3_1033;
  875. struct {
  876. unsigned int station_id; // Reference Station ID
  877. unsigned char bias_indicator;
  878. unsigned char signals_mask;
  879. int l1_ca_bias; // GLONASS L1 C/A Code-Phase Bias
  880. int l1_p_bias; // GLONASS L1 P Code-Phase Bias
  881. int l2_ca_bias; // GLONASS L2 C/A Code-Phase Bias
  882. int l2_p_bias; // GLONASS L2 P Code-Phase Bias
  883. } rtcm3_1230;
  884. struct rtcm3_msm_hdr rtcm3_msm;
  885. unsigned char data[1024]; // Max RTCM3 msg length is 1023 bytes
  886. } rtcmtypes;
  887. };
  888. // RTCM3 scaling constants
  889. #define GPS_AMBIGUITY_MODULUS 299792.458 // 1004, DF014
  890. #define GLONASS_AMBIGUITY_MODULUS 599584.916 // 1012, DF044
  891. #define MESSAGE_INTERVAL_UNITS 0.1 // 1013, DF047
  892. /*
  893. * The one true structure for (most) orbital data.
  894. * Before using any datum, check for validity, or isfinite()
  895. *
  896. * Why only store scaled data? With 7 constellations, each with an
  897. * almanac and ephemeris, that would be 14 unique non-scaled sets.
  898. * Too much work.
  899. *
  900. */
  901. struct orbit
  902. {
  903. // orbit type, 0 == invalid, 1 = ephemeris, 2 == almanac
  904. uint8_t type;
  905. #define ORBIT_INVALID 0
  906. #define ORBIT_EPHEMERIS 1
  907. #define ORBIT_ALMANAC 2
  908. // The satellite this refers to, zero if struct invalid
  909. uint8_t sv;
  910. // SV health data, random format, -1 if invalid
  911. // Issue of Data, IODa, IODc, IODe., -1 is invalid
  912. int8_t IODA;
  913. int8_t IODC;
  914. int8_t IODE;
  915. int8_t E5bHS; // Galileo E5b health status, -1 invalid
  916. int8_t E1BHS; // Galileo E1B health status, -1 invalid
  917. // AODC, Age of Data Clock, BDS, -1 if invalid
  918. int AODC;
  919. // AODE, Age of Data Ephemeris, BDS, -1 if invalid
  920. int AODE;
  921. // SISA(E1,E5a), -1 if invalid
  922. int SISAa;
  923. // SISA(E1,E5b), -1 if invalid
  924. int SISAb;
  925. // SV health data, random format, -1 if invalid
  926. int svh;
  927. // URAI, BDS, -1 if invalid
  928. int URAI;
  929. // Week Number, -1 if invalid
  930. int WN;
  931. // longs
  932. // toa, time of almanac, -1 if invalid
  933. long toa;
  934. // toc, time of clock, -1 if invalid
  935. long toc;
  936. // toe, time of ephemeris, -1 if invalid
  937. long toe;
  938. // LSBs of toe, seconds, -1 if invalid
  939. long toeLSB;
  940. // MSBs of toe, seconds, scaled, -1 if invalid
  941. long toeMSB;
  942. // af0, aka a0, SV clock correction constant term, seconds
  943. double af0;
  944. // af1, aka a1, SV clock correction first order term, seconds/second
  945. double af1;
  946. // af2, aka a2, SV clock correction second order term, seconds/second**2
  947. double af2;
  948. // alpha0, seconds
  949. double alpha0;
  950. // alpha1, seconds/semi-circle
  951. double alpha1;
  952. // alpha2, seconds/semi-circle**2
  953. double alpha2;
  954. // alpha3, seconds/semi-circle**3
  955. double alpha3;
  956. // beta0, seconds
  957. double beta0;
  958. // beta1, seconds/semi-circle
  959. double beta1;
  960. // beta2, seconds/semi-circle**2
  961. double beta2;
  962. // beta3, seconds/semi-circle**3
  963. double beta3;
  964. /* Cic, Amplitude of the Cosine Harmonic Correction Term to the
  965. * Angle of Inclination, radians*/
  966. double Cic;
  967. /* Cis, Amplitude of the Sine Harmonic Correction Term to the
  968. * Angle of Inclination, radians */
  969. double Cis;
  970. /* Crc, Amplitude of the Cosine Harmonic Correction Term to the
  971. * Orbit Radius, meters */
  972. double Crc;
  973. /* Crs, Amplitude of the Sine Harmonic Correction Term to the
  974. * Orbit Radius, signed, meters */
  975. double Crs;
  976. /* Cuc, Amplitude of the Cosine Harmonic Correction Term to the
  977. * Argument of Latitude, 16 bits, radians */
  978. double Cuc;
  979. /* Cus, Amplitude of the Sine Harmonic Correction Term to the
  980. * Argument of Latitude, radians */
  981. double Cus;
  982. // deltai, correction to inclination, semi-circles
  983. double deltai;
  984. // deltan, Mean motion difference from computed value, semicircles/sec
  985. double deltan;
  986. // eccentricity, unsigned, dimensionless
  987. double eccentricity;
  988. // i0, Inclination Angle at Reference Time, signed, semi-circles
  989. // range +/- 1
  990. double i0;
  991. // IDOT (BDS), idot (GAL) Rate of Inclination Angle, * semi-circles/sec
  992. double IDOT;
  993. // M0, Mean Anomaly at Reference Time, semi-circles, range +/- 1
  994. double M0;
  995. /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly Epoch,
  996. * semi-circles, range +/- 1 */
  997. double Omega0;
  998. // Omega dot, Rate of Right Ascension, semi-circles/sec
  999. double Omegad;
  1000. // omega, Argument of Perigee, semi-circles, range +/- 1
  1001. double omega;
  1002. // sqrt A, Square Root of the Semi-Major Axis, square_root(meters)
  1003. double sqrtA;
  1004. // TGD1, TGD2, Time Group Delay 1, 2, BDS, seconds
  1005. double TGD1;
  1006. double TGD2;
  1007. };
  1008. typedef struct orbit orbit_t;
  1009. /*
  1010. * Raw IS_GPS subframe data
  1011. */
  1012. /* The almanac is a subset of the clock and ephemeris data, with reduced
  1013. * precision. See IS-GPS-200, Table 20-VI */
  1014. struct almanac_t
  1015. {
  1016. uint8_t sv; // The satellite this refers to
  1017. // toa, almanac reference time, 8 bits unsigned, seconds
  1018. uint8_t toa;
  1019. unsigned long l_toa;
  1020. // SV health data, 8 bit unsigned bit map
  1021. uint8_t svh;
  1022. // deltai, correction to inclination, 16 bits signed, semi-circles
  1023. int16_t deltai;
  1024. double d_deltai;
  1025. // M0, Mean Anomaly at Reference Time, 24 bits signed, semi-circles
  1026. int32_t M0;
  1027. double d_M0;
  1028. /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly Epoch,
  1029. * 24 bits signed, semi-circles */
  1030. int32_t Omega0;
  1031. double d_Omega0;
  1032. // omega, Argument of Perigee, 24 bits signed, semi-circles
  1033. int32_t omega;
  1034. double d_omega;
  1035. /* af0, SV clock correction constant term
  1036. * 11 bits signed, seconds */
  1037. int16_t af0;
  1038. double d_af0;
  1039. /* af1, SV clock correction first order term
  1040. * 11 bits signed, seconds/second */
  1041. int16_t af1;
  1042. double d_af1;
  1043. // eccentricity, 16 bits, unsigned, dimensionless
  1044. uint16_t e;
  1045. double d_eccentricity;
  1046. /* sqrt A, Square Root of the Semi-Major Axis
  1047. * 24 bits unsigned, square_root(meters) */
  1048. uint32_t sqrtA;
  1049. double d_sqrtA;
  1050. // Omega dot, Rate of Right Ascension, 16 bits signed, semi-circles/sec
  1051. int16_t Omegad;
  1052. double d_Omegad;
  1053. };
  1054. struct subframe_t {
  1055. // different gnss use different subframes.
  1056. uint8_t gnssId;
  1057. // subframe number, GPS, 3 bits, unsigned, 1 to 5, 0 == invalid
  1058. uint8_t subframe_num;
  1059. /* data_id, denotes the NAV data structure of D(t), 2 bits, in
  1060. * IS-GPS-200 always == 0x1 */
  1061. uint8_t data_id;
  1062. // SV/page id used for subframes 4 & 5, 6 bits
  1063. uint8_t pageid;
  1064. // tSVID, SV ID of the sat that transmitted this frame, 6 bits unsigned
  1065. uint8_t tSVID;
  1066. /* TOW17, Time of Week of next Subframe.
  1067. * 17 bits unsigned, 0 to 100,799, scale 6, seconds, -1 if invalid */
  1068. int32_t TOW17; // 0 to 100,799, or 0 to 604,794
  1069. // integrity, URA bounds flag, 1 bit
  1070. bool integrity;
  1071. /* alert, alert flag, SV URA and/or the SV User Differential Range
  1072. * Accuracy (UDRA) may be worse than indicated, 1 bit */
  1073. bool alert;
  1074. // antispoof, A-S mode is ON in that SV, 1 bit
  1075. bool antispoof;
  1076. // Week Number for sending constellation, -1 for invalid
  1077. int WN;
  1078. // 1 == almanac, 2 == orbit
  1079. int is_almanac;
  1080. #define SUBFRAME_ALMANAC 1
  1081. #define SUBFRAME_ORBIT 2
  1082. // generic almanac, ephemeris
  1083. orbit_t orbit;
  1084. // Galileo sends two 1/2 almanacs at one time. 2nd one goes here.
  1085. orbit_t orbit1;
  1086. union {
  1087. /* subframe 1, part of ephemeris, see IS-GPS-200, Table 20-II
  1088. * and Table 20-I */
  1089. struct {
  1090. // WN, Week Number, 10 bits unsigned, scale 1, weeks
  1091. uint16_t WN;
  1092. /* IODC, Issue of Data, Clock, 10 bits, unsigned,
  1093. * issued in 8 data ranges at the same time */
  1094. uint16_t IODC;
  1095. /* toc, clock data reference time, 16 bits, unsigned, seconds
  1096. * scale 2**4, issued in 8 data ranges at the same time */
  1097. uint16_t toc;
  1098. long l_toc;
  1099. // l2, code on L2, 2 bits, bit map
  1100. uint8_t l2;
  1101. // l2p, L2 P data flag, 1 bit
  1102. uint8_t l2p;
  1103. // ura, SV accuracy, 4 bits unsigned index
  1104. unsigned int ura;
  1105. // hlth, SV health, 6 bits unsigned bitmap
  1106. unsigned int hlth;
  1107. /* af0, SV clock correction constant term
  1108. * 22 bits signed, scale 2**-31, seconds */
  1109. int32_t af0;
  1110. double d_af0;
  1111. /* af1, SV clock correction first order term
  1112. * 22 bits signed, scale 2**-43, seconds/second */
  1113. int16_t af1;
  1114. double d_af1;
  1115. /* af2, SV clock correction second order term
  1116. * 8 bits signed, scale 2**-55, seconds/second**2 */
  1117. int8_t af2;
  1118. double d_af2;
  1119. /* Tgd, L1-L2 correction term, 8 bits signed, scale 2**-31,
  1120. * seconds */
  1121. int8_t Tgd;
  1122. double d_Tgd;
  1123. } sub1;
  1124. /* subframe 2, part of ephemeris, see IS-GPS-200, Table 20-II
  1125. * and Table 20-III */
  1126. struct {
  1127. /* Issue of Data (Ephemeris),
  1128. * equal to the 8 LSBs of the 10 bit IODC of the same data set */
  1129. uint8_t IODE;
  1130. /* Age of Data Offset for the NMCT, 6 bits, scale 900,
  1131. * ignore if all ones, seconds */
  1132. uint8_t AODO;
  1133. uint16_t u_AODO;
  1134. /* fit, FIT interval flag, indicates a fit interval greater than
  1135. * 4 hour, 1 bit */
  1136. uint8_t fit;
  1137. /* toe, Reference Time Ephemeris, 16 bits unsigned, scale 2**4,
  1138. * seconds */
  1139. uint16_t toe;
  1140. unsigned long l_toe;
  1141. /* Crs, Amplitude of the Sine Harmonic Correction Term to the
  1142. * Orbit Radius, 16 bits, scale 2**-5, signed, meters */
  1143. int16_t Crs;
  1144. double d_Crs;
  1145. /* Cus, Amplitude of the Sine Harmonic Correction Term to the
  1146. * Argument of Latitude, 16 bits, signed, scale 2**-29, radians */
  1147. int16_t Cus;
  1148. double d_Cus;
  1149. /* Cuc, Amplitude of the Cosine Harmonic Correction Term to the
  1150. * Argument of Latitude, 16 bits, signed, scale 2**-29, radians */
  1151. int16_t Cuc;
  1152. double d_Cuc;
  1153. /* deltan, Mean Motion Difference From Computed Value
  1154. * Mean Motion Difference From Computed Value
  1155. * 16 bits, signed, scale 2**-43, semi-circles/sec */
  1156. int16_t deltan;
  1157. double d_deltan;
  1158. /* M0, Mean Anomaly at Reference Time, 32 bits signed,
  1159. * scale 2**-31, semi-circles */
  1160. int32_t M0;
  1161. double d_M0;
  1162. // eccentricity, 32 bits, unsigned, scale 2**-33, dimensionless
  1163. uint32_t e;
  1164. double d_eccentricity;
  1165. /* sqrt A, Square Root of the Semi-Major Axis
  1166. * 32 bits unsigned, scale 2**-19, square_root(meters) */
  1167. uint32_t sqrtA;
  1168. double d_sqrtA;
  1169. } sub2;
  1170. /* subframe 3, part of ephemeris, see IS-GPS-200, Table 20-II,
  1171. * Table 20-III */
  1172. struct {
  1173. /* Issue of Data (Ephemeris), 8 bits, unsigned
  1174. * equal to the 8 LSBs of the 10 bit IODC of the same data set */
  1175. uint8_t IODE;
  1176. /* Rate of Inclination Angle, 14 bits signed, scale2**-43,
  1177. * semi-circles/sec */
  1178. int16_t IDOT;
  1179. double d_IDOT;
  1180. /* Cic, Amplitude of the Cosine Harmonic Correction Term to the
  1181. * Angle of Inclination, 16 bits signed, scale 2**-29, radians*/
  1182. int16_t Cic;
  1183. double d_Cic;
  1184. /* Cis, Amplitude of the Sine Harmonic Correction Term to the
  1185. * Angle of Inclination, 16 bits, unsigned, scale 2**-29, radians */
  1186. int16_t Cis;
  1187. double d_Cis;
  1188. /* Crc, Amplitude of the Cosine Harmonic Correction Term to the
  1189. * Orbit Radius, 16 bits signed, scale 2**-5, meters */
  1190. int16_t Crc;
  1191. double d_Crc;
  1192. /* i0, Inclination Angle at Reference Time, 32 bits, signed,
  1193. * scale 2**-31, semi-circles */
  1194. int32_t i0;
  1195. double d_i0;
  1196. /* Omega0, Longitude of Ascending Node of Orbit Plane at Weekly
  1197. * Epoch, 32 bits signed, semi-circles */
  1198. int32_t Omega0;
  1199. double d_Omega0;
  1200. /* omega, Argument of Perigee, 32 bits signed, scale 2**-31,
  1201. * semi-circles */
  1202. int32_t omega;
  1203. double d_omega;
  1204. /* Omega dot, Rate of Right Ascension, 24 bits signed,
  1205. * scale 2**-43, semi-circles/sec */
  1206. int32_t Omegad;
  1207. double d_Omegad;
  1208. } sub3;
  1209. struct {
  1210. struct almanac_t almanac;
  1211. } sub4;
  1212. // subframe 4, page 13
  1213. struct {
  1214. /* mapping ord ERD# to SV # is non trivial
  1215. * leave it alone. See IS-GPS-200 Section 20.3.3.5.1.9
  1216. * Estimated Range Deviation, 6 bits signed, meters */
  1217. int8_t ERD[33];
  1218. // ai, Availability Indicator, 2bits, bit map
  1219. uint8_t ai;
  1220. } sub4_13;
  1221. // subframe 4, page 17, system message, 23 chars, plus nul
  1222. struct {
  1223. char str[24];
  1224. } sub4_17;
  1225. // subframe 4, page 18
  1226. struct { // ionospheric and UTC data
  1227. /* A0, Bias coefficient of GPS time scale relative to UTC time
  1228. * scale, 32 bits signed, scale 2**-30, seconds */
  1229. int32_t A0;
  1230. double d_A0;
  1231. /* A1, Drift coefficient of GPS time scale relative to UTC time
  1232. * scale, 24 bits signed, scale 2**-50, seconds/second */
  1233. int32_t A1;
  1234. double d_A1;
  1235. /* alphaX, the four coefficients of a cubic equation representing
  1236. * the amplitude of the vertical delay */
  1237. // alpha0, 8 bits signed, scale w**-30, seconds
  1238. int8_t alpha0;
  1239. double d_alpha0;
  1240. // alpha1, 8 bits signed, scale w**-27, seconds/semi-circle
  1241. int8_t alpha1;
  1242. double d_alpha1;
  1243. // alpha2, 8 bits signed, scale w**-24, seconds/semi-circle**2
  1244. int8_t alpha2;
  1245. double d_alpha2;
  1246. // alpha3, 8 bits signed, scale w**-24, seconds/semi-circle**3
  1247. int8_t alpha3;
  1248. double d_alpha3;
  1249. /* betaX, the four coefficients of a cubic equation representing
  1250. * the period of the model */
  1251. // beta0, 8 bits signed, scale w**11, seconds
  1252. int8_t beta0;
  1253. double d_beta0;
  1254. // beta1, 8 bits signed, scale w**14, seconds/semi-circle
  1255. int8_t beta1;
  1256. double d_beta1;
  1257. // beta2, 8 bits signed, scale w**16, seconds/semi-circle**2
  1258. int8_t beta2;
  1259. double d_beta2;
  1260. // beta3, 8 bits signed, scale w**16, seconds/semi-circle**3
  1261. int8_t beta3;
  1262. double d_beta3;
  1263. /* leap (delta t ls), current leap second, 8 bits signed,
  1264. * scale 1, seconds */
  1265. int8_t leap;
  1266. /* lsf (delta t lsf), future leap second, 8 bits signed,
  1267. * scale 1, seconds */
  1268. int8_t lsf;
  1269. /* tot, reference time for UTC data,
  1270. * 16 bits unsigned, scale 2**12, 0 to 604,784 seconds */
  1271. uint16_t tot;
  1272. unsigned long t_tot;
  1273. // WNt, UTC reference week number, 8 bits unsigned, scale 1, weeks
  1274. uint8_t WNt;
  1275. /* WNlsf, Leap second reference Week Number,
  1276. * 8 bits unsigned, scale 1, weeks */
  1277. uint8_t WNlsf;
  1278. /* DN, Leap second reference Day Number , 8 bits unsigned,
  1279. * scale 1, days */
  1280. uint8_t DN;
  1281. } sub4_18;
  1282. // subframe 4, page 25
  1283. struct {
  1284. /* svf, A-S status and the configuration code of each SV
  1285. * 4 bits unsigned, bitmap */
  1286. unsigned char svf[33];
  1287. /* svh, SV health data for SV 25 through 32
  1288. * 6 bits unsigned bitmap */
  1289. uint8_t svhx[8];
  1290. } sub4_25;
  1291. struct {
  1292. struct almanac_t almanac;
  1293. } sub5;
  1294. struct {
  1295. /* toa, Almanac reference Time, 8 bits unsigned, scale 2**12,
  1296. * seconds */
  1297. uint8_t toa;
  1298. unsigned long l_toa;
  1299. /* WNa, Week Number almanac, 8 bits, scale 2, GPS Week
  1300. * Number % 256 */
  1301. uint8_t WNa;
  1302. // sv, SV health status, 6 bits, bitmap
  1303. uint8_t sv[25];
  1304. } sub5_25;
  1305. };
  1306. };
  1307. typedef uint64_t gps_mask_t;
  1308. /*
  1309. * Is an MMSI number that of an auxiliary associated with a mother ship?
  1310. * We need to be able to test this for decoding AIS Type 24 messages.
  1311. * According to <http://www.navcen.uscg.gov/marcomms/gmdss/mmsi.htm#format>,
  1312. * auxiliary-craft MMSIs have the form 98MIDXXXX, where MID is a country
  1313. * code and XXXX the vessel ID.
  1314. */
  1315. #define AIS_AUXILIARY_MMSI(n) ((n) / 10000000 == 98)
  1316. // N/A values and scaling constant for 25/24 bit lon/lat pairs
  1317. #define AIS_LON3_NOT_AVAILABLE 181000
  1318. #define AIS_LAT3_NOT_AVAILABLE 91000
  1319. #define AIS_LATLON3_DIV 60000.0
  1320. // N/A values and scaling constant for 28/27 bit lon/lat pairs
  1321. #define AIS_LON4_NOT_AVAILABLE 1810000
  1322. #define AIS_LAT4_NOT_AVAILABLE 910000
  1323. #define AIS_LATLON4_DIV 600000.0
  1324. struct route_info {
  1325. unsigned int linkage; // Message Linkage ID
  1326. unsigned int sender; // Sender Class
  1327. unsigned int rtype; // Route Type
  1328. unsigned int month; // Start month
  1329. unsigned int day; // Start day
  1330. unsigned int hour; // Start hour
  1331. unsigned int minute; // Start minute
  1332. unsigned int duration; // Duration
  1333. int waycount; // Waypoint count
  1334. struct waypoint_t {
  1335. signed int lon; // Longitude
  1336. signed int lat; // Latitude
  1337. } waypoints[16];
  1338. };
  1339. struct ais_t
  1340. {
  1341. unsigned int type; // message type
  1342. unsigned int repeat; // Repeat indicator
  1343. unsigned int mmsi; // MMSI
  1344. union {
  1345. // Types 1-3 Common navigation info
  1346. struct {
  1347. unsigned int status; // navigation status
  1348. signed turn; // rate of turn
  1349. #define AIS_TURN_HARD_LEFT -127
  1350. #define AIS_TURN_HARD_RIGHT 127
  1351. #define AIS_TURN_NOT_AVAILABLE 128
  1352. unsigned int speed; // speed over ground in deciknots
  1353. #define AIS_SPEED_NOT_AVAILABLE 1023
  1354. #define AIS_SPEED_FAST_MOVER 1022 // >= 102.2 knots
  1355. bool accuracy; // position accuracy
  1356. #define AIS_LATLON_DIV 600000.0
  1357. int lon; // longitude
  1358. #define AIS_LON_NOT_AVAILABLE 0x6791AC0
  1359. int lat; // latitude
  1360. #define AIS_LAT_NOT_AVAILABLE 0x3412140
  1361. unsigned int course; // course over ground
  1362. #define AIS_COURSE_NOT_AVAILABLE 3600
  1363. unsigned int heading; // true heading
  1364. #define AIS_HEADING_NOT_AVAILABLE 511
  1365. /* seconds of UTC time, 0 to 59.
  1366. * 60 == N/A, 61 == manual, 62 == dead reckoning,
  1367. * 63 == inoperative */
  1368. unsigned int second;
  1369. #define AIS_SEC_NOT_AVAILABLE 60
  1370. #define AIS_SEC_MANUAL 61
  1371. #define AIS_SEC_ESTIMATED 62
  1372. #define AIS_SEC_INOPERATIVE 63
  1373. unsigned int maneuver; // maneuver indicator
  1374. // unsigned int spare; // spare bits
  1375. bool raim; // RAIM flag
  1376. unsigned int radio; // radio status bits
  1377. } type1;
  1378. // Type 4 - Base Station Report & Type 11 - UTC and Date Response
  1379. struct {
  1380. unsigned int year; // UTC year
  1381. #define AIS_YEAR_NOT_AVAILABLE 0
  1382. unsigned int month; // UTC month
  1383. #define AIS_MONTH_NOT_AVAILABLE 0
  1384. unsigned int day; // UTC day
  1385. #define AIS_DAY_NOT_AVAILABLE 0
  1386. unsigned int hour; // UTC hour
  1387. #define AIS_HOUR_NOT_AVAILABLE 24
  1388. unsigned int minute; // UTC minute
  1389. #define AIS_MINUTE_NOT_AVAILABLE 60
  1390. unsigned int second; // UTC second
  1391. #define AIS_SECOND_NOT_AVAILABLE 60
  1392. bool accuracy; // fix quality
  1393. int lon; // longitude
  1394. int lat; // latitude
  1395. unsigned int epfd; // type of position fix device
  1396. // unsigned int spare; // spare bits
  1397. bool raim; // RAIM flag
  1398. unsigned int radio; // radio status bits
  1399. } type4;
  1400. // Type 5 - Ship static and voyage related data
  1401. struct {
  1402. unsigned int ais_version; // AIS version level
  1403. unsigned int imo; // IMO identification
  1404. // cppcheck-suppress arrayIndexOutOfBounds
  1405. char callsign[7+1]; // callsign
  1406. #define AIS_SHIPNAME_MAXLEN 20
  1407. // cppcheck-suppress arrayIndexOutOfBounds
  1408. char shipname[AIS_SHIPNAME_MAXLEN+1]; // vessel name
  1409. unsigned int shiptype; // ship type code
  1410. unsigned int to_bow; // dimension to bow
  1411. unsigned int to_stern; // dimension to stern
  1412. unsigned int to_port; // dimension to port
  1413. unsigned int to_starboard; // dimension to starboard
  1414. unsigned int epfd; // type of position fix device
  1415. unsigned int month; // UTC month
  1416. unsigned int day; // UTC day
  1417. unsigned int hour; // UTC hour
  1418. unsigned int minute; // UTC minute
  1419. unsigned int draught; // draft in meters
  1420. char destination[20+1]; // ship destination
  1421. unsigned int dte; // data terminal enable
  1422. // unsigned int spare; // spare bits
  1423. } type5;
  1424. // Type 6 - Addressed Binary Message
  1425. struct {
  1426. unsigned int seqno; // sequence number
  1427. unsigned int dest_mmsi; // destination MMSI
  1428. bool retransmit; // retransmit flag
  1429. // unsigned int spare; // spare bit(s)
  1430. unsigned int dac; // Application ID
  1431. unsigned int fid; // Functional ID
  1432. bool structured; // True match for DAC/FID?
  1433. #define AIS_TYPE6_BINARY_MAX 920 // 920 bits
  1434. size_t bitcount; // bit count of the data
  1435. union {
  1436. // cppcheck-suppress arrayIndexOutOfBounds
  1437. char bitdata[(AIS_TYPE6_BINARY_MAX + 7) / 8];
  1438. // Inland AIS - ETA at lock/bridge/terminal
  1439. struct {
  1440. char country[2+1]; // UN Country Code
  1441. char locode[3+1]; // UN/LOCODE
  1442. char section[5+1]; // Fairway section
  1443. char terminal[5+1]; // Terminal code
  1444. char hectometre[5+1]; // Fairway hectometre
  1445. unsigned int month; // ETA month
  1446. unsigned int day; // ETA day
  1447. unsigned int hour; // ETA hour
  1448. unsigned int minute; // ETA minute
  1449. unsigned int tugs; // Assisting Tugs
  1450. unsigned int airdraught; // Air Draught
  1451. } dac200fid21;
  1452. // Inland AIS - ETA at lock/bridge/terminal
  1453. struct {
  1454. char country[2+1]; // UN Country Code
  1455. char locode[3+1]; // UN/LOCODE
  1456. char section[5+1]; // Fairway section
  1457. char terminal[5+1]; // Terminal code
  1458. char hectometre[5+1]; // Fairway hectometre
  1459. unsigned int month; // RTA month
  1460. unsigned int day; // RTA day
  1461. unsigned int hour; // RTA hour
  1462. unsigned int minute; // RTA minute
  1463. unsigned int status; // Status
  1464. #define DAC200FID22_STATUS_OPERATIONAL 0
  1465. #define DAC200FID22_STATUS_LIMITED 1
  1466. #define DAC200FID22_STATUS_OUT_OF_ORDER 2
  1467. #define DAC200FID22_STATUS_NOT_AVAILABLE 0
  1468. } dac200fid22;
  1469. // Inland AIS - Number of persons on board
  1470. struct {
  1471. unsigned int crew; // # crew on board
  1472. unsigned int passengers; // # passengers on board
  1473. unsigned int personnel; // # personnel on board
  1474. #define DAC200FID55_COUNT_NOT_AVAILABLE 255
  1475. } dac200fid55;
  1476. // GLA - AtoN monitoring data (UK/ROI)
  1477. struct {
  1478. unsigned int ana_int; // Analogue (internal)
  1479. unsigned int ana_ext1; // Analogue (external #1)
  1480. unsigned int ana_ext2; // Analogue (external #2)
  1481. unsigned int racon; // RACON status
  1482. unsigned int light; // Light status
  1483. bool alarm; // Health alarm
  1484. unsigned int stat_ext; // Status bits (external)
  1485. bool off_pos; // Off position status
  1486. } dac235fid10;
  1487. // IMO236 - Dangerous Cargo Indication
  1488. struct {
  1489. char lastport[5+1]; // Last Port Of Call
  1490. unsigned int lmonth; // ETA month
  1491. unsigned int lday; // ETA day
  1492. unsigned int lhour; // ETA hour
  1493. unsigned int lminute; // ETA minute
  1494. char nextport[5+1]; // Next Port Of Call
  1495. unsigned int nmonth; // ETA month
  1496. unsigned int nday; // ETA day
  1497. unsigned int nhour; // ETA hour
  1498. unsigned int nminute; // ETA minute
  1499. char dangerous[20+1]; // Main Dangerous Good
  1500. char imdcat[4+1]; // IMD Category
  1501. unsigned int unid; // UN Number
  1502. unsigned int amount; // Amount of Cargo
  1503. unsigned int unit; // Unit of Quantity
  1504. } dac1fid12;
  1505. // IMO236 - Extended Ship Static and Voyage Related Data
  1506. struct {
  1507. unsigned int airdraught; // Air Draught
  1508. } dac1fid15;
  1509. // IMO236 - Number of Persons on board
  1510. struct {
  1511. unsigned persons; // number of persons
  1512. } dac1fid16;
  1513. // IMO289 - Clearance Time To Enter Port
  1514. struct {
  1515. unsigned int linkage; // Message Linkage ID
  1516. unsigned int month; // Month (UTC)
  1517. unsigned int day; // Day (UTC)
  1518. unsigned int hour; // Hour (UTC)
  1519. unsigned int minute; // Minute (UTC)
  1520. char portname[20+1]; // Name of Port & Berth
  1521. char destination[5+1]; // Destination
  1522. signed int lon; // Longitude
  1523. signed int lat; // Latitude
  1524. } dac1fid18;
  1525. // IMO289 - Berthing Data (addressed)
  1526. struct {
  1527. unsigned int linkage; // Message Linkage ID
  1528. unsigned int berth_length; // Berth length
  1529. unsigned int berth_depth; // Berth Water Depth
  1530. unsigned int position; // Mooring Position
  1531. unsigned int month; // Month (UTC)
  1532. unsigned int day; // Day (UTC)
  1533. unsigned int hour; // Hour (UTC)
  1534. unsigned int minute; // Minute (UTC)
  1535. unsigned int availability; // Services Availability
  1536. unsigned int agent; // Agent
  1537. unsigned int fuel; // Bunker/fuel
  1538. unsigned int chandler; // Chandler
  1539. unsigned int stevedore; // Stevedore
  1540. unsigned int electrical; // Electrical
  1541. unsigned int water; // Potable water
  1542. unsigned int customs; // Customs house
  1543. unsigned int cartage; // Cartage
  1544. unsigned int crane; // Crane(s)
  1545. unsigned int lift; // Lift(s)
  1546. unsigned int medical; // Medical facilities
  1547. unsigned int navrepair; // Navigation repair
  1548. unsigned int provisions; // Provisions
  1549. unsigned int shiprepair; // Ship repair
  1550. unsigned int surveyor; // Surveyor
  1551. unsigned int steam; // Steam
  1552. unsigned int tugs; // Tugs
  1553. unsigned int solidwaste; // Waste disposal (solid)
  1554. unsigned int liquidwaste; // Waste disposal (liquid)
  1555. unsigned int hazardouswaste; // Waste disposal (hazardous)
  1556. unsigned int ballast; // Reserved ballast exchange
  1557. unsigned int additional; // Additional services
  1558. unsigned int regional1; // Regional reserved 1
  1559. unsigned int regional2; // Regional reserved 2
  1560. unsigned int future1; // Reserved for future
  1561. unsigned int future2; // Reserved for future
  1562. char berth_name[20+1]; // Name of Berth
  1563. signed int berth_lon; // Longitude
  1564. signed int berth_lat; // Latitude
  1565. } dac1fid20;
  1566. // IMO289 - Weather observation report from ship
  1567. // *** WORK IN PROGRESS - NOT YET DECODED ***
  1568. struct {
  1569. bool wmo; // true if WMO variant
  1570. union {
  1571. struct {
  1572. char location[20+1]; // Location
  1573. signed int lon; // Longitude
  1574. signed int lat; // Latitude
  1575. unsigned int day; // Report day
  1576. unsigned int hour; // Report hour
  1577. unsigned int minute; // Report minute
  1578. bool vislimit; // Max range?
  1579. unsigned int visibility; // Units of 0.1 nm
  1580. #define DAC1FID21_VISIBILITY_NOT_AVAILABLE 127
  1581. #define DAC1FID21_VISIBILITY_SCALE 10.0
  1582. unsigned humidity; // units of 1%
  1583. unsigned int wspeed; // average wind speed
  1584. unsigned int wgust; // wind gust
  1585. #define DAC1FID21_WSPEED_NOT_AVAILABLE 127
  1586. unsigned int wdir; // wind direction
  1587. #define DAC1FID21_WDIR_NOT_AVAILABLE 360
  1588. unsigned int pressure; // air pressure, hpa
  1589. #define DAC1FID21_NONWMO_PRESSURE_NOT_AVAILABLE 403
  1590. #define DAC1FID21_NONWMO_PRESSURE_HIGH 402 // > 1200hPa
  1591. #define DAC1FID21_NONWMO_PRESSURE_OFFSET 400 // N/A
  1592. unsigned int pressuretend; // tendency
  1593. int airtemp; // temp, units 0.1C
  1594. #define DAC1FID21_AIRTEMP_NOT_AVAILABLE -1024
  1595. #define DAC1FID21_AIRTEMP_SCALE 10.0
  1596. unsigned int watertemp; // units 0.1degC
  1597. #define DAC1FID21_WATERTEMP_NOT_AVAILABLE 501
  1598. #define DAC1FID21_WATERTEMP_SCALE 10.0
  1599. unsigned int waveperiod; // in seconds
  1600. #define DAC1FID21_WAVEPERIOD_NOT_AVAILABLE 63
  1601. unsigned int wavedir; // direction in deg
  1602. #define DAC1FID21_WAVEDIR_NOT_AVAILABLE 360
  1603. unsigned int swellheight; // in decimeters
  1604. unsigned int swellperiod; // in seconds
  1605. unsigned int swelldir; // direction in deg
  1606. } nonwmo_obs;
  1607. struct {
  1608. signed int lon; // Longitude
  1609. signed int lat; // Latitude
  1610. unsigned int month; // UTC month
  1611. unsigned int day; // Report day
  1612. unsigned int hour; // Report hour
  1613. unsigned int minute; // Report minute
  1614. unsigned int course; // course over ground
  1615. unsigned int speed; // speed, m/s
  1616. #define DAC1FID21_SOG_NOT_AVAILABLE 31
  1617. #define DAC1FID21_SOG_HIGH_SPEED 30
  1618. #define DAC1FID21_SOG_SCALE 2.0
  1619. unsigned int heading; // true heading
  1620. #define DAC1FID21_HDG_NOT_AVAILABLE 127
  1621. #define DAC1FID21_HDG_SCALE 5.0
  1622. unsigned int pressure; // units of hPa * 0.1
  1623. #define DAC1FID21_WMO_PRESSURE_SCALE 10
  1624. #define DAC1FID21_WMO_PRESSURE_OFFSET 90.0
  1625. unsigned int pdelta; // units of hPa * 0.1
  1626. #define DAC1FID21_PDELTA_SCALE 10
  1627. #define DAC1FID21_PDELTA_OFFSET 50.0
  1628. unsigned int ptend; // enumerated
  1629. unsigned int twinddir; // in 5 degree steps
  1630. #define DAC1FID21_TWINDDIR_NOT_AVAILABLE 127
  1631. unsigned int twindspeed; // meters per second
  1632. #define DAC1FID21_TWINDSPEED_SCALE 2
  1633. #define DAC1FID21_RWINDSPEED_NOT_AVAILABLE 255
  1634. unsigned int rwinddir; // in 5 degree steps
  1635. #define DAC1FID21_RWINDDIR_NOT_AVAILABLE 127
  1636. unsigned int rwindspeed; // meters per second
  1637. #define DAC1FID21_RWINDSPEED_SCALE 2
  1638. #define DAC1FID21_RWINDSPEED_NOT_AVAILABLE 255
  1639. unsigned int mgustspeed; // meters per second
  1640. #define DAC1FID21_MGUSTSPEED_SCALE 2
  1641. #define DAC1FID21_MGUSTSPEED_NOT_AVAILABLE 255
  1642. unsigned int mgustdir; // in 5 degree steps
  1643. #define DAC1FID21_MGUSTDIR_NOT_AVAILABLE 127
  1644. unsigned int airtemp; // degrees K
  1645. #define DAC1FID21_AIRTEMP_OFFSET 223
  1646. unsigned humidity; // units of 1%
  1647. #define DAC1FID21_HUMIDITY_NOT_VAILABLE 127
  1648. // some trailing fields are missing
  1649. } wmo_obs;
  1650. };
  1651. } dac1fid21;
  1652. // *** WORK IN PROGRESS ENDS HERE ***
  1653. // IMO289 - Dangerous Cargo Indication
  1654. struct {
  1655. unsigned int unit; // Unit of Quantity
  1656. unsigned int amount; // Amount of Cargo
  1657. int ncargos;
  1658. struct cargo_t {
  1659. unsigned int code; // Cargo code
  1660. unsigned int subtype; // Cargo subtype
  1661. } cargos[28];
  1662. } dac1fid25;
  1663. // IMO289 - Route info (addressed)
  1664. struct route_info dac1fid28;
  1665. // IMO289 - Text message (addressed
  1666. struct {
  1667. unsigned int linkage;
  1668. #define AIS_DAC1FID30_TEXT_MAX 154 // 920 bits of six-bit, plus NUL
  1669. char text[AIS_DAC1FID30_TEXT_MAX];
  1670. } dac1fid30;
  1671. // IMO289 & IMO236 - Tidal Window
  1672. struct {
  1673. unsigned int month; // Month
  1674. unsigned int day; // Day
  1675. signed int ntidals;
  1676. struct tidal_t {
  1677. signed int lon; // Longitude
  1678. signed int lat; // Latitude
  1679. unsigned int from_hour; // From UTC Hour
  1680. unsigned int from_min; // From UTC Minute
  1681. unsigned int to_hour; // To UTC Hour
  1682. unsigned int to_min; // To UTC Minute
  1683. #define DAC1FID32_CDIR_NOT_AVAILABLE 360
  1684. unsigned int cdir; // Current Dir. Predicted
  1685. #define DAC1FID32_CSPEED_NOT_AVAILABLE 127
  1686. unsigned int cspeed; // Current Speed Predicted
  1687. } tidals[3];
  1688. } dac1fid32;
  1689. };
  1690. } type6;
  1691. // Type 7 - Binary Acknowledge
  1692. struct {
  1693. unsigned int mmsi1;
  1694. unsigned int seqno1;
  1695. unsigned int mmsi2;
  1696. unsigned int seqno2;
  1697. unsigned int mmsi3;
  1698. unsigned int seqno3;
  1699. unsigned int mmsi4;
  1700. unsigned int seqno4;
  1701. // spares ignored, they're only padding here
  1702. } type7;
  1703. // Type 8 - Broadcast Binary Message
  1704. struct {
  1705. unsigned int dac; // Designated Area Code
  1706. unsigned int fid; // Functional ID
  1707. #define AIS_TYPE8_BINARY_MAX 952 // 952 bits
  1708. size_t bitcount; // bit count of the data
  1709. bool structured; // True match for DAC/FID?
  1710. union {
  1711. // cppcheck-suppress arrayIndexOutOfBounds
  1712. char bitdata[(AIS_TYPE8_BINARY_MAX + 7) / 8];
  1713. // Inland static ship and voyage-related data
  1714. struct {
  1715. char vin[8+1]; // European Vessel ID
  1716. unsigned int length; // Length of ship
  1717. unsigned int beam; // Beam of ship
  1718. unsigned int shiptype; // Ship/combination type
  1719. unsigned int hazard; // Hazardous cargo
  1720. #define DAC200FID10_HAZARD_MAX 5
  1721. unsigned int draught; // Draught
  1722. unsigned int loaded; // Loaded/Unloaded
  1723. bool speed_q; // Speed inf. quality
  1724. bool course_q; // Course inf. quality
  1725. bool heading_q; // Heading inf. quality
  1726. } dac200fid10;
  1727. // Inland AIS EMMA Warning
  1728. struct {
  1729. unsigned int start_year; // Start Year
  1730. unsigned int start_month; // Start Month
  1731. unsigned int start_day; // Start Day
  1732. unsigned int end_year; // End Year
  1733. unsigned int end_month; // End Month
  1734. unsigned int end_day; // End Day
  1735. unsigned int start_hour; // Start Hour
  1736. unsigned int start_minute; // Start Minute
  1737. unsigned int end_hour; // End Hour
  1738. unsigned int end_minute; // End Minute
  1739. signed int start_lon; // Start Longitude
  1740. signed int start_lat; // Start Latitude
  1741. signed int end_lon; // End Longitude
  1742. signed int end_lat; // End Latitude
  1743. unsigned int type; // Type
  1744. #define DAC200FID23_TYPE_UNKNOWN 0
  1745. signed int min; // Min value
  1746. #define DAC200FID23_MIN_UNKNOWN 255
  1747. signed int max; // Max value
  1748. #define DAC200FID23_MAX_UNKNOWN 255
  1749. unsigned int intensity; // Classification
  1750. #define DAC200FID23_CLASS_UNKNOWN 0
  1751. unsigned int wind; // Wind Direction
  1752. #define DAC200FID23_WIND_UNKNOWN 0
  1753. } dac200fid23;
  1754. struct {
  1755. char country[2+1]; // UN Country Code
  1756. signed int ngauges;
  1757. struct gauge_t {
  1758. unsigned int id; // Gauge ID
  1759. #define DAC200FID24_GAUGE_ID_UNKNOWN 0
  1760. signed int level; // Water Level
  1761. #define DAC200FID24_GAUGE_LEVEL_UNKNOWN 0
  1762. } gauges[4];
  1763. } dac200fid24;
  1764. struct {
  1765. signed int lon; // Signal Longitude
  1766. signed int lat; // Signal Latitude
  1767. unsigned int form; // Signal form
  1768. #define DAC200FID40_FORM_UNKNOWN 0
  1769. unsigned int facing; // Signal orientation
  1770. #define DAC200FID40_FACING_UNKNOWN 0
  1771. unsigned int direction; // Direction of impact
  1772. #define DAC200FID40_DIRECTION_UNKNOWN 0
  1773. unsigned int status; // Light Status
  1774. #define DAC200FID40_STATUS_UNKNOWN 0
  1775. } dac200fid40;
  1776. /* IMO236 - Meteorological-Hydrological data
  1777. * Trial message, not to be used after January 2013
  1778. * Replaced by IMO289 (DAC 1, FID 31)
  1779. */
  1780. struct {
  1781. #define DAC1FID11_LATLON_SCALE 1000
  1782. int lon; // longitude in minutes * .001
  1783. #define DAC1FID11_LON_NOT_AVAILABLE 0xFFFFFF
  1784. int lat; // latitude in minutes * .001
  1785. #define DAC1FID11_LAT_NOT_AVAILABLE 0x7FFFFF
  1786. unsigned int day; // UTC day
  1787. unsigned int hour; // UTC hour
  1788. unsigned int minute; // UTC minute
  1789. unsigned int wspeed; // average wind speed
  1790. unsigned int wgust; // wind gust
  1791. #define DAC1FID11_WSPEED_NOT_AVAILABLE 127
  1792. unsigned int wdir; // wind direction
  1793. unsigned int wgustdir; // wind gust direction
  1794. #define DAC1FID11_WDIR_NOT_AVAILABLE 511
  1795. unsigned int airtemp; // temperature, units 0.1C
  1796. #define DAC1FID11_AIRTEMP_NOT_AVAILABLE 2047
  1797. #define DAC1FID11_AIRTEMP_OFFSET 600
  1798. #define DAC1FID11_AIRTEMP_DIV 10.0
  1799. unsigned int humidity; // relative humidity, %
  1800. #define DAC1FID11_HUMIDITY_NOT_AVAILABLE 127
  1801. unsigned int dewpoint; // dew point, units 0.1C
  1802. #define DAC1FID11_DEWPOINT_NOT_AVAILABLE 1023
  1803. #define DAC1FID11_DEWPOINT_OFFSET 200
  1804. #define DAC1FID11_DEWPOINT_DIV 10.0
  1805. unsigned int pressure; // air pressure, hpa
  1806. #define DAC1FID11_PRESSURE_NOT_AVAILABLE 511
  1807. #define DAC1FID11_PRESSURE_OFFSET -800
  1808. unsigned int pressuretend; // tendency
  1809. #define DAC1FID11_PRESSURETREND_NOT_AVAILABLE 3
  1810. unsigned int visibility; // units 0.1 nautical miles
  1811. #define DAC1FID11_VISIBILITY_NOT_AVAILABLE 255
  1812. #define DAC1FID11_VISIBILITY_DIV 10.0
  1813. int waterlevel; // decimeters
  1814. #define DAC1FID11_WATERLEVEL_NOT_AVAILABLE 511
  1815. #define DAC1FID11_WATERLEVEL_OFFSET 100
  1816. #define DAC1FID11_WATERLEVEL_DIV 10.0
  1817. unsigned int leveltrend; // water level trend code
  1818. #define DAC1FID11_WATERLEVELTREND_NOT_AVAILABLE 3
  1819. unsigned int cspeed; // surface current speed in deciknots
  1820. #define DAC1FID11_CSPEED_NOT_AVAILABLE 255
  1821. #define DAC1FID11_CSPEED_DIV 10.0
  1822. unsigned int cdir; // surface current dir., degrees
  1823. #define DAC1FID11_CDIR_NOT_AVAILABLE 511
  1824. unsigned int cspeed2; // current speed in deciknots
  1825. unsigned int cdir2; // current dir., degrees
  1826. unsigned int cdepth2; // measurement depth, m
  1827. #define DAC1FID11_CDEPTH_NOT_AVAILABLE 31
  1828. unsigned int cspeed3; // current speed in deciknots
  1829. unsigned int cdir3; // current dir., degrees
  1830. unsigned int cdepth3; // measurement depth, m
  1831. unsigned int waveheight; // in decimeters
  1832. #define DAC1FID11_WAVEHEIGHT_NOT_AVAILABLE 255
  1833. #define DAC1FID11_WAVEHEIGHT_DIV 10.0
  1834. unsigned int waveperiod; // in seconds
  1835. #define DAC1FID11_WAVEPERIOD_NOT_AVAILABLE 63
  1836. unsigned int wavedir; // direction in degrees
  1837. #define DAC1FID11_WAVEDIR_NOT_AVAILABLE 511
  1838. unsigned int swellheight; // in decimeters
  1839. unsigned int swellperiod; // in seconds
  1840. unsigned int swelldir; // direction in degrees
  1841. unsigned int seastate; // Beaufort scale, 0-12
  1842. #define DAC1FID11_SEASTATE_NOT_AVAILABLE 15
  1843. unsigned int watertemp; // units 0.1deg Celsius
  1844. #define DAC1FID11_WATERTEMP_NOT_AVAILABLE 1023
  1845. #define DAC1FID11_WATERTEMP_OFFSET 100
  1846. #define DAC1FID11_WATERTEMP_DIV 10.0
  1847. unsigned int preciptype; // 0-7, enumerated
  1848. #define DAC1FID11_PRECIPTYPE_NOT_AVAILABLE 7
  1849. unsigned int salinity; // units of 0.1ppt
  1850. #define DAC1FID11_SALINITY_NOT_AVAILABLE 511
  1851. #define DAC1FID11_SALINITY_DIV 10.0
  1852. unsigned int ice; // is there sea ice?
  1853. #define DAC1FID11_ICE_NOT_AVAILABLE 3
  1854. } dac1fid11;
  1855. // IMO236 - Fairway Closed
  1856. struct {
  1857. char reason[20+1]; // Reason For Closing
  1858. char closefrom[20+1]; // Location Of Closing From
  1859. char closeto[20+1]; // Location of Closing To
  1860. unsigned int radius; // Radius extension
  1861. #define AIS_DAC1FID13_RADIUS_NOT_AVAILABLE 10001
  1862. unsigned int extunit; // Unit of extension
  1863. #define AIS_DAC1FID13_EXTUNIT_NOT_AVAILABLE 0
  1864. unsigned int fday; // From day (UTC)
  1865. unsigned int fmonth; // From month (UTC)
  1866. unsigned int fhour; // From hour (UTC)
  1867. unsigned int fminute; // From minute (UTC)
  1868. unsigned int tday; // To day (UTC)
  1869. unsigned int tmonth; // To month (UTC)
  1870. unsigned int thour; // To hour (UTC)
  1871. unsigned int tminute; // To minute (UTC)
  1872. } dac1fid13;
  1873. // IMO236 - Extended ship and voyage data
  1874. struct {
  1875. unsigned int airdraught; // Air Draught
  1876. } dac1fid15;
  1877. // IMO286 - Number of Persons on board
  1878. struct {
  1879. unsigned persons; // number of persons
  1880. } dac1fid16;
  1881. // IMO289 - VTS-generated/Synthetic Targets
  1882. struct {
  1883. signed int ntargets;
  1884. struct target_t {
  1885. #define DAC1FID17_IDTYPE_MMSI 0
  1886. #define DAC1FID17_IDTYPE_IMO 1
  1887. #define DAC1FID17_IDTYPE_CALLSIGN 2
  1888. #define DAC1FID17_IDTYPE_OTHER 3
  1889. unsigned int idtype; // Identifier type
  1890. union target_id { // Target identifier
  1891. unsigned int mmsi;
  1892. unsigned int imo;
  1893. #define DAC1FID17_ID_LENGTH 7
  1894. // cppcheck-suppress arrayIndexOutOfBounds
  1895. char callsign[DAC1FID17_ID_LENGTH+1];
  1896. char other[DAC1FID17_ID_LENGTH+1];
  1897. } id;
  1898. signed int lat; // Latitude
  1899. signed int lon; // Longitude
  1900. #define DAC1FID17_COURSE_NOT_AVAILABLE 360
  1901. unsigned int course; // Course Over Ground
  1902. unsigned int second; // Time Stamp
  1903. #define DAC1FID17_SPEED_NOT_AVAILABLE 255
  1904. unsigned int speed; // Speed Over Ground
  1905. } targets[4];
  1906. } dac1fid17;
  1907. // IMO 289 - Marine Traffic Signal
  1908. struct {
  1909. unsigned int linkage; // Message Linkage ID
  1910. char station[20+1]; // Name of Signal Station
  1911. signed int lon; // Longitude
  1912. signed int lat; // Latitude
  1913. unsigned int status; // Status of Signal
  1914. unsigned int signal; // Signal In Service
  1915. unsigned int hour; // UTC hour
  1916. unsigned int minute; // UTC minute
  1917. unsigned int nextsignal; // Expected Next Signal
  1918. } dac1fid19;
  1919. // IMO289 - Route info (broadcast)
  1920. struct route_info dac1fid27;
  1921. // IMO289 - Text message (broadcast)
  1922. struct {
  1923. unsigned int linkage;
  1924. #define AIS_DAC1FID29_TEXT_MAX 162 // 920 bits of six-bit, plus NUL
  1925. char text[AIS_DAC1FID29_TEXT_MAX];
  1926. } dac1fid29;
  1927. // IMO289 - Meteorological-Hydrological data
  1928. struct {
  1929. bool accuracy; // position accuracy, <10m if true
  1930. #define DAC1FID31_LATLON_SCALE 1000
  1931. int lon; // longitude in minutes * .001
  1932. #define DAC1FID31_LON_NOT_AVAILABLE (181*60*DAC1FID31_LATLON_SCALE)
  1933. int lat; // longitude in minutes * .001
  1934. #define DAC1FID31_LAT_NOT_AVAILABLE (91*60*DAC1FID31_LATLON_SCALE)
  1935. unsigned int day; // UTC day
  1936. unsigned int hour; // UTC hour
  1937. unsigned int minute; // UTC minute
  1938. unsigned int wspeed; // average wind speed
  1939. unsigned int wgust; // wind gust
  1940. #define DAC1FID31_WIND_HIGH 126
  1941. #define DAC1FID31_WIND_NOT_AVAILABLE 127
  1942. unsigned int wdir; // wind direction
  1943. unsigned int wgustdir; // wind gust direction
  1944. #define DAC1FID31_DIR_NOT_AVAILABLE 360
  1945. int airtemp; // temperature, units 0.1C
  1946. #define DAC1FID31_AIRTEMP_NOT_AVAILABLE -1024
  1947. #define DAC1FID31_AIRTEMP_DIV 10.0
  1948. unsigned int humidity; // relative humidity, %
  1949. #define DAC1FID31_HUMIDITY_NOT_AVAILABLE 101
  1950. int dewpoint; // dew point, units 0.1C
  1951. #define DAC1FID31_DEWPOINT_NOT_AVAILABLE 501
  1952. #define DAC1FID31_DEWPOINT_DIV 10.0
  1953. unsigned int pressure; // air pressure, hpa
  1954. #define DAC1FID31_PRESSURE_NOT_AVAILABLE 511
  1955. #define DAC1FID31_PRESSURE_HIGH 402
  1956. #define DAC1FID31_PRESSURE_OFFSET -799
  1957. unsigned int pressuretend; // tendency
  1958. #define DAC1FID31_PRESSURETEND_NOT_AVAILABLE 3
  1959. bool visgreater; // visibility greater than
  1960. unsigned int visibility; // units 0.1 nautical miles
  1961. #define DAC1FID31_VISIBILITY_NOT_AVAILABLE 127
  1962. #define DAC1FID31_VISIBILITY_DIV 10.0
  1963. int waterlevel; // cm
  1964. #define DAC1FID31_WATERLEVEL_NOT_AVAILABLE 4001
  1965. #define DAC1FID31_WATERLEVEL_OFFSET 1000
  1966. #define DAC1FID31_WATERLEVEL_DIV 100.0
  1967. unsigned int leveltrend; // water level trend code
  1968. #define DAC1FID31_WATERLEVELTREND_NOT_AVAILABLE 3
  1969. unsigned int cspeed; // current speed in deciknots
  1970. #define DAC1FID31_CSPEED_NOT_AVAILABLE 255
  1971. #define DAC1FID31_CSPEED_DIV 10.0
  1972. unsigned int cdir; // current dir., degrees
  1973. unsigned int cspeed2; // current speed in deciknots
  1974. unsigned int cdir2; // current dir., degrees
  1975. unsigned int cdepth2; // measurement depth, 0.1m
  1976. #define DAC1FID31_CDEPTH_NOT_AVAILABLE 301
  1977. #define DAC1FID31_CDEPTH_SCALE 10.0
  1978. unsigned int cspeed3; // current speed in deciknots
  1979. unsigned int cdir3; // current dir., degrees
  1980. unsigned int cdepth3; // measurement depth, 0.1m
  1981. unsigned int waveheight; // in decimeters
  1982. #define DAC1FID31_HEIGHT_NOT_AVAILABLE 31
  1983. #define DAC1FID31_HEIGHT_DIV 10.0
  1984. unsigned int waveperiod; // in seconds
  1985. #define DAC1FID31_PERIOD_NOT_AVAILABLE 63
  1986. unsigned int wavedir; // direction in degrees
  1987. unsigned int swellheight; // in decimeters
  1988. unsigned int swellperiod; // in seconds
  1989. unsigned int swelldir; // direction in degrees
  1990. unsigned int seastate; // Beaufort scale, 0-12
  1991. #define DAC1FID31_SEASTATE_NOT_AVAILABLE 15
  1992. int watertemp; // units 0.1deg Celsius
  1993. #define DAC1FID31_WATERTEMP_NOT_AVAILABLE 601
  1994. #define DAC1FID31_WATERTEMP_DIV 10.0
  1995. unsigned int preciptype; // 0-7, enumerated
  1996. #define DAC1FID31_PRECIPTYPE_NOT_AVAILABLE 7
  1997. unsigned int salinity; // units of 0.1 permil (ca. PSU)
  1998. #define DAC1FID31_SALINITY_NOT_AVAILABLE 510
  1999. #define DAC1FID31_SALINITY_DIV 10.0
  2000. unsigned int ice; // is there sea ice?
  2001. #define DAC1FID31_ICE_NOT_AVAILABLE 3
  2002. } dac1fid31;
  2003. };
  2004. } type8;
  2005. // Type 9 - Standard SAR Aircraft Position Report
  2006. struct {
  2007. unsigned int alt; // altitude in meters
  2008. #define AIS_ALT_NOT_AVAILABLE 4095
  2009. #define AIS_ALT_HIGH 4094 // 4094 meters or higher
  2010. unsigned int speed; // speed over ground in deciknots
  2011. #define AIS_SAR_SPEED_NOT_AVAILABLE 1023
  2012. #define AIS_SAR_FAST_MOVER 1022
  2013. bool accuracy; // position accuracy
  2014. int lon; // longitude
  2015. int lat; // latitude
  2016. unsigned int course; // course over ground
  2017. /* seconds of UTC time, 0 to 59.
  2018. * 60 == N/A, 61 == manual, 62 == dead reckoning,
  2019. * 63 == inoperative */
  2020. unsigned int second; // seconds of UTC time
  2021. unsigned int regional; // regional reserved
  2022. unsigned int dte; // data terminal enable
  2023. // unsigned int spare; // spare bits
  2024. bool assigned; // assigned-mode flag
  2025. bool raim; // RAIM flag
  2026. unsigned int radio; // radio status bits
  2027. } type9;
  2028. // Type 10 - UTC/Date Inquiry
  2029. struct {
  2030. // unsigned int spare;
  2031. unsigned int dest_mmsi; // destination MMSI
  2032. // unsigned int spare2;
  2033. } type10;
  2034. // Type 12 - Safety-Related Message
  2035. struct {
  2036. unsigned int seqno; // sequence number
  2037. unsigned int dest_mmsi; // destination MMSI
  2038. bool retransmit; // retransmit flag
  2039. // unsigned int spare; // spare bit(s)
  2040. #define AIS_TYPE12_TEXT_MAX 157 // 936 bits of six-bit, plus NUL
  2041. char text[AIS_TYPE12_TEXT_MAX];
  2042. } type12;
  2043. // Type 14 - Safety-Related Broadcast Message
  2044. struct {
  2045. // unsigned int spare; // spare bit(s)
  2046. #define AIS_TYPE14_TEXT_MAX 161 // 952 bits of six-bit, plus NUL
  2047. char text[AIS_TYPE14_TEXT_MAX];
  2048. } type14;
  2049. // Type 15 - Interrogation
  2050. struct {
  2051. // unsigned int spare; // spare bit(s)
  2052. unsigned int mmsi1;
  2053. unsigned int type1_1;
  2054. unsigned int offset1_1;
  2055. // unsigned int spare2; // spare bit(s)
  2056. unsigned int type1_2;
  2057. unsigned int offset1_2;
  2058. // unsigned int spare3; // spare bit(s)
  2059. unsigned int mmsi2;
  2060. unsigned int type2_1;
  2061. unsigned int offset2_1;
  2062. // unsigned int spare4; // spare bit(s)
  2063. } type15;
  2064. // Type 16 - Assigned Mode Command
  2065. struct {
  2066. // unsigned int spare; // spare bit(s)
  2067. unsigned int mmsi1;
  2068. unsigned int offset1;
  2069. unsigned int increment1;
  2070. unsigned int mmsi2;
  2071. unsigned int offset2;
  2072. unsigned int increment2;
  2073. } type16;
  2074. // Type 17 - GNSS Broadcast Binary Message
  2075. struct {
  2076. // unsigned int spare; // spare bit(s)
  2077. #define AIS_GNSS_LATLON_DIV 600.0
  2078. int lon; // longitude
  2079. int lat; // latitude
  2080. // unsigned int spare2; // spare bit(s)
  2081. #define AIS_TYPE17_BINARY_MAX 736 // 920 bits
  2082. size_t bitcount; // bit count of the data
  2083. char bitdata[(AIS_TYPE17_BINARY_MAX + 7) / 8];
  2084. } type17;
  2085. // Type 18 - Standard Class B CS Position Report
  2086. struct {
  2087. unsigned int reserved; // altitude in meters
  2088. unsigned int speed; // speed over ground in deciknots
  2089. bool accuracy; // position accuracy
  2090. int lon; // longitude
  2091. #define AIS_GNS_LON_NOT_AVAILABLE 0x1a838
  2092. int lat; // latitude
  2093. #define AIS_GNS_LAT_NOT_AVAILABLE 0xd548
  2094. unsigned int course; // course over ground
  2095. unsigned int heading; // true heading
  2096. /* seconds of UTC time, 0 to 59.
  2097. * 60 == N/A, 61 == manual, 62 == dead reckoning,
  2098. * 63 == inoperative */
  2099. unsigned int second;
  2100. unsigned int regional; // regional reserved
  2101. bool cs; // carrier sense unit flag
  2102. bool display; // unit has attached display?
  2103. bool dsc; // unit attached to radio with DSC?
  2104. bool band; // unit can switch frequency bands?
  2105. bool msg22; // can accept Message 22 management?
  2106. bool assigned; // assigned-mode flag
  2107. bool raim; // RAIM flag
  2108. unsigned int radio; // radio status bits
  2109. } type18;
  2110. // Type 19 - Extended Class B CS Position Report
  2111. struct {
  2112. unsigned int reserved; // altitude in meters
  2113. unsigned int speed; // speed over ground in deciknots
  2114. bool accuracy; // position accuracy
  2115. int lon; // longitude
  2116. int lat; // latitude
  2117. unsigned int course; // course over ground
  2118. unsigned int heading; // true heading
  2119. /* seconds of UTC time, 0 to 59.
  2120. * 60 == N/A, 61 == manual, 62 == dead reckoning,
  2121. * 63 == inoperative */
  2122. unsigned int second;
  2123. unsigned int regional; /* regional reserved */
  2124. // cppcheck-suppress arrayIndexOutOfBounds
  2125. char shipname[AIS_SHIPNAME_MAXLEN+1]; /* ship name */
  2126. unsigned int shiptype; /* ship type code */
  2127. unsigned int to_bow; /* dimension to bow */
  2128. unsigned int to_stern; /* dimension to stern */
  2129. unsigned int to_port; /* dimension to port */
  2130. unsigned int to_starboard; /* dimension to starboard */
  2131. unsigned int epfd; /* type of position fix device */
  2132. bool raim; /* RAIM flag */
  2133. unsigned int dte; /* date terminal enable */
  2134. bool assigned; /* assigned-mode flag */
  2135. //unsigned int spare; spare bits */
  2136. } type19;
  2137. /* Type 20 - Data Link Management Message */
  2138. struct {
  2139. //unsigned int spare; spare bit(s) */
  2140. unsigned int offset1; /* TDMA slot offset */
  2141. unsigned int number1; /* number of xlots to allocate */
  2142. unsigned int timeout1; /* allocation timeout */
  2143. unsigned int increment1; /* repeat increment */
  2144. unsigned int offset2; /* TDMA slot offset */
  2145. unsigned int number2; /* number of xlots to allocate */
  2146. unsigned int timeout2; /* allocation timeout */
  2147. unsigned int increment2; /* repeat increment */
  2148. unsigned int offset3; /* TDMA slot offset */
  2149. unsigned int number3; /* number of xlots to allocate */
  2150. unsigned int timeout3; /* allocation timeout */
  2151. unsigned int increment3; /* repeat increment */
  2152. unsigned int offset4; /* TDMA slot offset */
  2153. unsigned int number4; /* number of xlots to allocate */
  2154. unsigned int timeout4; /* allocation timeout */
  2155. unsigned int increment4; /* repeat increment */
  2156. } type20;
  2157. /* Type 21 - Aids to Navigation Report */
  2158. struct {
  2159. unsigned int aid_type; /* aid type */
  2160. char name[35]; /* name of aid to navigation */
  2161. bool accuracy; /* position accuracy */
  2162. int lon; /* longitude */
  2163. int lat; /* latitude */
  2164. unsigned int to_bow; /* dimension to bow */
  2165. unsigned int to_stern; /* dimension to stern */
  2166. unsigned int to_port; /* dimension to port */
  2167. unsigned int to_starboard; /* dimension to starboard */
  2168. unsigned int epfd; /* type of EPFD */
  2169. /* seconds of UTC time, 0 to 59.
  2170. * 60 == N/A, 61 == manual, 62 == dead reckoning,
  2171. * 63 == inoperative */
  2172. unsigned int second;
  2173. bool off_position; /* off-position indicator */
  2174. unsigned int regional; /* regional reserved field */
  2175. bool raim; /* RAIM flag */
  2176. bool virtual_aid; /* is virtual station? */
  2177. bool assigned; /* assigned-mode flag */
  2178. //unsigned int spare; unused */
  2179. } type21;
  2180. /* Type 22 - Channel Management */
  2181. struct {
  2182. //unsigned int spare; spare bit(s) */
  2183. unsigned int channel_a; /* Channel A number */
  2184. unsigned int channel_b; /* Channel B number */
  2185. unsigned int txrx; /* transmit/receive mode */
  2186. bool power; /* high-power flag */
  2187. #define AIS_CHANNEL_LATLON_DIV 600.0
  2188. union {
  2189. struct {
  2190. int ne_lon; /* NE corner longitude */
  2191. int ne_lat; /* NE corner latitude */
  2192. int sw_lon; /* SW corner longitude */
  2193. int sw_lat; /* SW corner latitude */
  2194. } area;
  2195. struct {
  2196. unsigned int dest1; /* addressed station MMSI 1 */
  2197. unsigned int dest2; /* addressed station MMSI 2 */
  2198. } mmsi;
  2199. };
  2200. bool addressed; /* addressed vs. broadcast flag */
  2201. bool band_a; /* fix 1.5kHz band for channel A */
  2202. bool band_b; /* fix 1.5kHz band for channel B */
  2203. unsigned int zonesize; /* size of transitional zone */
  2204. } type22;
  2205. /* Type 23 - Group Assignment Command */
  2206. struct {
  2207. int ne_lon; /* NE corner longitude */
  2208. int ne_lat; /* NE corner latitude */
  2209. int sw_lon; /* SW corner longitude */
  2210. int sw_lat; /* SW corner latitude */
  2211. //unsigned int spare; spare bit(s) */
  2212. unsigned int stationtype; /* station type code */
  2213. unsigned int shiptype; /* ship type code */
  2214. //unsigned int spare2; spare bit(s) */
  2215. unsigned int txrx; /* transmit-enable code */
  2216. unsigned int interval; /* report interval */
  2217. unsigned int quiet; /* quiet time */
  2218. //unsigned int spare3; spare bit(s) */
  2219. } type23;
  2220. /* Type 24 - Class B CS Static Data Report */
  2221. struct {
  2222. char shipname[AIS_SHIPNAME_MAXLEN+1]; /* vessel name */
  2223. enum {
  2224. both,
  2225. part_a,
  2226. part_b,
  2227. } part;
  2228. unsigned int shiptype; /* ship type code */
  2229. char vendorid[8]; /* vendor ID */
  2230. unsigned int model; /* unit model code */
  2231. unsigned int serial; /* serial number */
  2232. char callsign[8]; /* callsign */
  2233. union {
  2234. unsigned int mothership_mmsi; /* MMSI of main vessel */
  2235. struct {
  2236. unsigned int to_bow; /* dimension to bow */
  2237. unsigned int to_stern; /* dimension to stern */
  2238. unsigned int to_port; /* dimension to port */
  2239. unsigned int to_starboard; /* dimension to starboard */
  2240. } dim;
  2241. };
  2242. } type24;
  2243. /* Type 25 - Addressed Binary Message */
  2244. struct {
  2245. bool addressed; /* addressed-vs.broadcast flag */
  2246. bool structured; /* structured-binary flag */
  2247. unsigned int dest_mmsi; /* destination MMSI */
  2248. unsigned int app_id; /* Application ID */
  2249. #define AIS_TYPE25_BINARY_MAX 128 /* Up to 128 bits */
  2250. size_t bitcount; /* bit count of the data */
  2251. char bitdata[(AIS_TYPE25_BINARY_MAX + 7) / 8];
  2252. } type25;
  2253. /* Type 26 - Addressed Binary Message */
  2254. struct {
  2255. bool addressed; /* addressed-vs.broadcast flag */
  2256. bool structured; /* structured-binary flag */
  2257. unsigned int dest_mmsi; /* destination MMSI */
  2258. unsigned int app_id; /* Application ID */
  2259. #define AIS_TYPE26_BINARY_MAX 1004 /* Up to 128 bits */
  2260. size_t bitcount; /* bit count of the data */
  2261. char bitdata[(AIS_TYPE26_BINARY_MAX + 7) / 8];
  2262. unsigned int radio; /* radio status bits */
  2263. } type26;
  2264. /* Type 27 - Long Range AIS Broadcast message */
  2265. struct {
  2266. bool accuracy; /* position accuracy */
  2267. bool raim; /* RAIM flag */
  2268. unsigned int status; /* navigation status */
  2269. #define AIS_LONGRANGE_LATLON_DIV 600.0
  2270. int lon; /* longitude */
  2271. #define AIS_LONGRANGE_LON_NOT_AVAILABLE 0x1a838
  2272. int lat; /* latitude */
  2273. #define AIS_LONGRANGE_LAT_NOT_AVAILABLE 0xd548
  2274. unsigned int speed; /* speed over ground in deciknots */
  2275. #define AIS_LONGRANGE_SPEED_NOT_AVAILABLE 63
  2276. unsigned int course; /* course over ground */
  2277. #define AIS_LONGRANGE_COURSE_NOT_AVAILABLE 511
  2278. bool gnss; /* are we reporting GNSS position? */
  2279. } type27;
  2280. };
  2281. };
  2282. /* basic data, per PRN, from GPGSA and GPGSV, or GPS binary messages */
  2283. /* FIXME: u-blox 9 no longer uses PRN */
  2284. struct satellite_t {
  2285. /* SNR. signal-to-noise ratio, 0 to 254 dB, u-blox can be 0 to 63.
  2286. * -1 for n/a */
  2287. double ss;
  2288. bool used; /* this satellite used in solution */
  2289. /* PRN of this satellite, 1 to 437, 0 for n/a
  2290. * sadly there is no standard, but many different implementations of
  2291. * how to code PRN
  2292. */
  2293. short PRN; /* PRN numbering per NMEA 2.x to 4.0, not 4.10 */
  2294. double elevation; /* elevation of satellite, -90 to 90 deg, NAN for n/a */
  2295. double azimuth; /* azimuth, 0 to 359 deg, NAN1 for n/a */
  2296. /* gnssid:svid:sigid, as defined by u-blox 8/9:
  2297. * gnssid svid (native PRN)
  2298. * 0 = GPS 1-32
  2299. * 1 = SBAS 120-158
  2300. * 2 = Galileo 1-36
  2301. * 3 - BeiDou 1-37
  2302. * 4 = IMES 1-10
  2303. * 5 = QZSS 1-5 Undocumented u-blox goes to 7
  2304. * 6 = GLONASS 1-32, 255
  2305. * 7 = NavIC (IRNSS) 1-11 ZED-F9T
  2306. *
  2307. * gnssid:svid:sigid, as defined by NMEA 4.11, NOT USED HERE!
  2308. * 1 = GPS 1-32
  2309. * 1 = SBAS 33-64, 152-158
  2310. * 1 = QZSS 193-202 (u-blox extended NMEA 4.10)
  2311. * 2 = GLONASS 65-96, null
  2312. * 3 = Galileo 1-36
  2313. * 4 - BeiDou 1-37
  2314. * 5 = QZSS 1-10 (NMEA 4.11)
  2315. * 6 = NavIC (IRNSS) NMEA 4.11+
  2316. * x = IMES 173-182 (u-blox extended NMEA 3.10)
  2317. *
  2318. * Note: other GNSS receivers use different mappings!
  2319. */
  2320. unsigned char gnssid;
  2321. /* defines for u-blox gnssId, as used in satellite_t */
  2322. #define GNSSID_GPS 0
  2323. #define GNSSID_SBAS 1
  2324. #define GNSSID_GAL 2
  2325. #define GNSSID_BD 3
  2326. #define GNSSID_IMES 4
  2327. #define GNSSID_QZSS 5
  2328. #define GNSSID_GLO 6
  2329. #define GNSSID_IRNSS 7 // ZED-F9T
  2330. #define GNSSID_CNT 8 /* count for array size */
  2331. /* ignore gnssid and sigid if svid is zero */
  2332. unsigned char svid;
  2333. /* sigid as defined by u-blox 9/10, and used here
  2334. * BeiDou: 0 = B1I D1, 1 = B1I D2, 2 = B2I D1, 3 = B2I D2, 7 = B2a
  2335. * Galileo: 0 = E1 C, 1 = E1 B, 3 = E5 aI, 4 = E5 aQ, 5 = E5 bl, 6 = E5 bQ
  2336. * GLONASS: 0 = L1 OF, 2 = L2 OF
  2337. * GPS: 0 = L1C/A, 3 = L2 CL, 4 = L2 CM, 6 = L5 I, 7 = L5 Q
  2338. * IRNSS: ??
  2339. * QZSS: 0 = L1C/A, 4 = L2 CM, 5 = L2 CL
  2340. * SBAS: 0 = L1C/A, ? = L5I
  2341. *
  2342. * sigid as defined by NMEA 4.10, according to Skytrak, NOT used here
  2343. * Galileo:
  2344. * 0 All signals
  2345. * 1 E5a (aI and aQ)
  2346. * 2 E5b (bI and bQ)
  2347. * 3 E5 a+b
  2348. * 4 E6‐A
  2349. * 5 E6‐BC
  2350. * 6 L1‐A
  2351. * 7 L1‐B and L1-C (E1-C and E1-B)
  2352. * GLONASS:
  2353. * 0 All signals
  2354. * 1 G1 C/A (L1 OF)
  2355. * 2 G1P
  2356. * 3 G2 C/A (L2 OF)
  2357. * 4 GLONASS (M) G2P
  2358. * GPS:
  2359. * 0 All signals
  2360. * 1 L1 C/A
  2361. * 2 L1 P(Y)
  2362. * 3 L1C
  2363. * 4 L2 P(Y)
  2364. * 5 L2C‐M
  2365. * 6 L2C‐L
  2366. * 7 L5‐I
  2367. * 8 L5‐Q
  2368. * IRNSS:
  2369. * 4 L5
  2370. * QZSS: not defined
  2371. *
  2372. * Additional sigid as defined by NMEA 4.11, NOT used here
  2373. * BeiDou:
  2374. * According to u-blox
  2375. * 1 = B1 D1, 1 = B1 D2, 5 = B2 a, 11(8) = B2 D1, 11(8) = B2 D2
  2376. * According to Skytrak
  2377. * 0 All signals
  2378. * 1 B1 (b1-d1 AND b1-d2)
  2379. * 2 B2A
  2380. * 3 B2
  2381. * 4 B3
  2382. * 5 B1C
  2383. * QZSS: 1 = L1C/A
  2384. */
  2385. unsigned char sigid;
  2386. signed char freqid; // The GLONASS (Only) frequency, 0 - 13
  2387. unsigned char health; // 0 = unknown, 1 = healthy, 2 = unhealthy
  2388. #define SAT_HEALTH_UNK 0
  2389. #define SAT_HEALTH_OK 1
  2390. #define SAT_HEALTH_BAD 2
  2391. };
  2392. struct attitude_t {
  2393. timespec_t mtime; // time of measurement
  2394. // arbitrary time tag (see UBX-ESF-MEAS), 32 bit unsigned
  2395. unsigned long timeTag;
  2396. /* source message name.
  2397. * Used to disambiguate UBX-ESF-RAW and UBX-ESF-MEAS
  2398. * Also used to mark this struct as used
  2399. */
  2400. char msg[16];
  2401. double acc_len; // unitvector sqrt(x^2 + y^2 +z^2)
  2402. // u-blox, acc_X == 24 bit signed / 1024
  2403. double acc_x; // x-axis acceleration (m/s^2)
  2404. double acc_y; // y-axis acceleration (m/s^2)
  2405. double acc_z; // x-axis acceleration (m/s^2)
  2406. double depth;
  2407. double dip;
  2408. // u-blox, gyro_temp == 24 bit signed / 100
  2409. double gyro_temp; // deg C
  2410. // u-blox, gyro_X == 24 bit signed / 4096
  2411. double gyro_x; // deg/s^2
  2412. double gyro_y; // deg/s^2
  2413. double gyro_z; // deg/s^2
  2414. double heading; // true heading
  2415. double mag_len; // unitvector sqrt(x^2 + y^2 +z^2)
  2416. double mag_x;
  2417. double mag_y;
  2418. double mag_z;
  2419. double pitch; // deg
  2420. double roll; // deg
  2421. double temp; // deg C
  2422. double yaw; // deg
  2423. // compass status -- TrueNorth (and any similar) devices only
  2424. char mag_st;
  2425. char pitch_st;
  2426. char roll_st;
  2427. char yaw_st;
  2428. };
  2429. struct dop_t {
  2430. // Dilution of precision factors
  2431. double xdop, ydop, pdop, hdop, vdop, tdop, gdop;
  2432. };
  2433. struct rawdata_t {
  2434. /* raw measurement data, suitable for RINEX 3 */
  2435. timespec_t mtime; /* time of measurement: sec, nsec
  2436. * Note: GPS time, not UTC time */
  2437. struct meas_t {
  2438. /* gnssid see satellite_t for decode */
  2439. unsigned char gnssid;
  2440. /* svid see RINEX 3 for decode, not satellite_t */
  2441. unsigned char svid;
  2442. /* sigid see satellite_t for decode */
  2443. unsigned char sigid;
  2444. /* SNR. 0 to 100 dB-Hz. u-blox can be 0 to 63. */
  2445. unsigned char snr;
  2446. unsigned char freqid; /* The GLONASS (Only) frequency, 0 - 13 */
  2447. unsigned char lli; /* RINEX Loss of Lock Indicator
  2448. * bit 0 - Lost Lock
  2449. * bit 1 - half-cycle ambiguity/slip possible
  2450. * bit 2 - GALILEO BOC-tracking of MBOC signal
  2451. */
  2452. char obs_code[4]; /* 3 char RINEX observation code */
  2453. /* see RINEX documentation
  2454. * GPS: L1: L1C, L1S, L1L, L1X, L1P, L1W, L1N
  2455. * L2: L2C, L2D, L2S, L2L, L2X, L2P, L2W, L2N
  2456. * L5: L5I, L5Q
  2457. * GLONASS: G1: L1C, L1P
  2458. * G2: L2C, L2P
  2459. * G3: L3I, L3Q, L3X
  2460. * GALILEO: E1: L1B, L1C, L1X
  2461. * E5A: L5I, L5Ql L5X
  2462. * E5B: L7I, L7Q, L7X
  2463. * E5(A+B): L8I, L8Q, L8X
  2464. * E6: L6B, L6C, L6X
  2465. * QZSS: L1: L1C, L1S, L1L, L1X, L1Z
  2466. * L2: L2S, L2L, L2X
  2467. * L5: L5I, L5Q, L5X
  2468. * LEX(6): L6S, L6L, L6X
  2469. * BeiDou: B1: L2I, L2Q, L2X
  2470. * B2: L7I, L7Q, L7X
  2471. * B3: L6I, L6Q, L6X
  2472. * IRNSS: L5: L5A, L5B, L5C, L5X
  2473. * S: L9A, L9B, L9C, L9X
  2474. */
  2475. double codephase; /* meters */
  2476. double carrierphase; /* L1 C/A meters, RINEX L1C */
  2477. double pseudorange; /* L1 C/A meters, RINEX C1C */
  2478. double deltarange; /* L1 C/A meters/sec, RINEX D1C */
  2479. double doppler; /* Hz */
  2480. #define LOCKMAX 64500 /* locktime capped at 64500 */
  2481. unsigned locktime; /* Carrier Phase Locktime in ms.
  2482. * max 64,500 ms */
  2483. double l2c; /* L2 C/A carrier phase meters, RINEX L2C */
  2484. double c2c; /* L2 C/A pseudo-range meters, RINEX C2C */
  2485. unsigned satstat; /* tracking status */
  2486. #define SAT_ACQUIRED 0x01 /* satellite acquired */
  2487. #define SAT_CODE_TRACK 0x02 /* code-tracking loop acquired */
  2488. #define SAT_CARR_TRACK 0x04 /* carrier-tracking loop acquired */
  2489. #define SAT_DATA_SYNC 0x08 /* data-bit synchronization done */
  2490. #define SAT_FRAME_SYNC 0x10 /* frame synchronization done */
  2491. #define SAT_EPHEMERIS 0x20 /* ephemeris collected */
  2492. #define SAT_FIX_USED 0x40 /* used for position fix */
  2493. } meas[MAXCHANNELS];
  2494. };
  2495. struct version_t {
  2496. char release[64]; /* external version */
  2497. char rev[64]; /* internal revision ID */
  2498. int proto_major, proto_minor; /* API major and minor versions */
  2499. char remote[GPS_PATH_MAX]; /* could be from a remote device */
  2500. };
  2501. #define HEXDATA_MAX 512 /* hex encoded command buffer, max */
  2502. struct devconfig_t {
  2503. char path[GPS_PATH_MAX];
  2504. int flags;
  2505. #define SEEN_GPS 0x01
  2506. #define SEEN_RTCM2 0x02
  2507. #define SEEN_RTCM3 0x04
  2508. #define SEEN_AIS 0x08
  2509. char driver[64];
  2510. /* 96 too small for ZED-F9 */
  2511. char subtype[128]; // maybe hardware version
  2512. char subtype1[128]; // maybe software version
  2513. /* a buffer to hold data to output to GPS */
  2514. char hexdata[HEXDATA_MAX];
  2515. timespec_t activated;
  2516. unsigned int baudrate, stopbits; /* RS232 link parameters */
  2517. char parity; /* 'N', 'O', or 'E' */
  2518. timespec_t cycle, mincycle; /* refresh cycle time in seconds */
  2519. int driver_mode; /* is driver in native mode or not? */
  2520. };
  2521. struct gps_policy_t {
  2522. bool watcher; /* is watcher mode on? */
  2523. bool json; /* requesting JSON? */
  2524. bool nmea; /* requesting dumping as NMEA? */
  2525. int raw; /* requesting raw data? */
  2526. bool scaled; /* requesting report scaling? */
  2527. bool timing; /* requesting timing info */
  2528. bool split24; /* requesting split AIS Type 24s */
  2529. bool pps; /* requesting PPS in NMEA/raw modes */
  2530. // loglevel presently unused
  2531. int loglevel; /* requested log level of messages */
  2532. char devpath[GPS_PATH_MAX]; /* specific device to watch */
  2533. // remote presently unused
  2534. char remote[GPS_PATH_MAX]; /* ...if this was passthrough */
  2535. };
  2536. #ifndef TIMEDELTA_DEFINED
  2537. #define TIMEDELTA_DEFINED
  2538. struct timedelta_t {
  2539. timespec_t real;
  2540. timespec_t clock;
  2541. };
  2542. #endif /* TIMEDELTA_DEFINED */
  2543. struct oscillator_t {
  2544. bool running; /* oscillator is running */
  2545. bool reference; /* PPS reference is available */
  2546. bool disciplined; /* oscillator is GPS-disciplined */
  2547. int delta; /* last observed PPS delta */
  2548. };
  2549. /*
  2550. * Someday we may support Windows, under which socket_t is a separate type.
  2551. * In the meantime, having a typedef for this semantic kind is no bad thing,
  2552. * as it makes clearer what some declarations are doing without breaking
  2553. * binary compatibility.
  2554. */
  2555. typedef int socket_t;
  2556. // BAD_SOCKET() needs to flag UNALLOCATED_FD (01) and PLACEHOLDING_FD (-2)
  2557. #define BAD_SOCKET(s) (0 > (s))
  2558. #define INVALIDATE_SOCKET(s) do { s = -1; } while (0)
  2559. /* mode flags for setting streaming policy */
  2560. #define WATCH_ENABLE 0x000001u /* enable streaming */
  2561. #define WATCH_DISABLE 0x000002u /* disable watching */
  2562. #define WATCH_JSON 0x000010u /* JSON output */
  2563. #define WATCH_NMEA 0x000020u /* output in NMEA */
  2564. #define WATCH_RARE 0x000040u /* output of packets in hex */
  2565. #define WATCH_RAW 0x000080u /* output of raw packets */
  2566. #define WATCH_SCALED 0x000100u /* scale output to floats */
  2567. #define WATCH_TIMING 0x000200u /* timing information */
  2568. #define WATCH_DEVICE 0x000800u /* watch specific device */
  2569. #define WATCH_SPLIT24 0x001000u /* split AIS Type 24s */
  2570. #define WATCH_PPS 0x002000u /* enable PPS JSON */
  2571. #define WATCH_NEWSTYLE 0x010000u /* force JSON streaming */
  2572. /*
  2573. * Main structure that includes all previous substructures
  2574. */
  2575. struct gps_data_t {
  2576. gps_mask_t set; /* has field been set since this was last cleared? */
  2577. #define ONLINE_SET (1llu<<1)
  2578. #define TIME_SET (1llu<<2)
  2579. #define TIMERR_SET (1llu<<3)
  2580. #define LATLON_SET (1llu<<4)
  2581. #define ALTITUDE_SET (1llu<<5)
  2582. #define SPEED_SET (1llu<<6)
  2583. #define TRACK_SET (1llu<<7)
  2584. #define CLIMB_SET (1llu<<8)
  2585. #define STATUS_SET (1llu<<9)
  2586. #define MODE_SET (1llu<<10)
  2587. #define DOP_SET (1llu<<11) // not used by clients
  2588. #define HERR_SET (1llu<<12)
  2589. #define VERR_SET (1llu<<13)
  2590. #define ATTITUDE_SET (1llu<<14)
  2591. #define SATELLITE_SET (1llu<<15)
  2592. #define SPEEDERR_SET (1llu<<16)
  2593. #define TRACKERR_SET (1llu<<17)
  2594. #define CLIMBERR_SET (1llu<<18)
  2595. #define DEVICE_SET (1llu<<19)
  2596. #define DEVICELIST_SET (1llu<<20)
  2597. #define DEVICEID_SET (1llu<<21)
  2598. #define RTCM2_SET (1llu<<22)
  2599. #define RTCM3_SET (1llu<<23)
  2600. #define AIS_SET (1llu<<24)
  2601. #define PACKET_SET (1llu<<25)
  2602. #define SUBFRAME_SET (1llu<<26)
  2603. #define GST_SET (1llu<<27)
  2604. #define VERSION_SET (1llu<<28)
  2605. #define POLICY_SET (1llu<<29)
  2606. #define LOGMESSAGE_SET (1llu<<30)
  2607. #define ERROR_SET (1llu<<31)
  2608. #define TOFF_SET (1llu<<32) /* not yet used */
  2609. #define PPS_SET (1llu<<33)
  2610. #define NAVDATA_SET (1llu<<34)
  2611. #define OSCILLATOR_SET (1llu<<35)
  2612. #define ECEF_SET (1llu<<36)
  2613. #define VECEF_SET (1llu<<37)
  2614. #define MAGNETIC_TRACK_SET (1llu<<38)
  2615. #define RAW_SET (1llu<<39)
  2616. #define NED_SET (1llu<<40)
  2617. #define VNED_SET (1llu<<41)
  2618. #define LOG_SET (1llu<<42)
  2619. #define IMU_SET (1llu<<43)
  2620. #define SET_HIGH_BIT 44
  2621. timespec_t online; /* NZ if GPS is on line, 0 if not.
  2622. *
  2623. * Note: gpsd clears this time when sentences
  2624. * fail to show up within the GPS's normal
  2625. * send cycle time. If the host-to-GPS
  2626. * link is lossy enough to drop entire
  2627. * sentences, this field will be
  2628. * prone to false zero values.
  2629. */
  2630. #ifdef USE_QT
  2631. void* gps_fd;
  2632. #else
  2633. /* socket or file descriptor to GPS
  2634. * POSIX says this is an int.
  2635. * use socket_t, which is int, for windows compatibility */
  2636. socket_t gps_fd;
  2637. #endif
  2638. struct gps_fix_t fix; /* accumulated PVT data */
  2639. struct gps_log_t log; // log data
  2640. int leap_seconds; /* Unix secs to UTC (GPS-UTC offset) */
  2641. /* precision of fix -- valid if satellites_used > 0 */
  2642. int satellites_used; /* Number of satellites used in solution */
  2643. struct dop_t dop;
  2644. /* satellite status -- valid when satellites_visible > 0 */
  2645. timespec_t skyview_time; /* skyview time */
  2646. int satellites_visible; /* # of satellites in view */
  2647. struct satellite_t skyview[MAXCHANNELS];
  2648. struct devconfig_t dev; /* device that shipped last update */
  2649. struct gps_policy_t policy; /* our listening policy */
  2650. struct {
  2651. timespec_t time;
  2652. int ndevices;
  2653. struct devconfig_t list[MAXUSERDEVS];
  2654. } devices;
  2655. /* pack things never reported together to reduce structure size */
  2656. #define UNION_SET (AIS_SET|ERROR_SET|GST_SET| \
  2657. LOGMESSAGE_SET|OSCILLATOR_SET|PPS_SET|RAW_SET| \
  2658. RTCM2_SET|RTCM3_SET|SUBFRAME_SET|TOFF_SET|VERSION_SET)
  2659. union {
  2660. /* unusual forms of sensor data that might come up the pipe */
  2661. struct rtcm2_t rtcm2;
  2662. struct rtcm3_t rtcm3;
  2663. struct subframe_t subframe;
  2664. struct ais_t ais;
  2665. struct rawdata_t raw;
  2666. struct gst_t gst;
  2667. struct oscillator_t osc;
  2668. /* "artificial" structures for various protocol responses */
  2669. struct version_t version;
  2670. char error[256];
  2671. };
  2672. /* attitude and imu are similar
  2673. * attitude is synchronous to the GNNS epoch, and cumulative in the epoch
  2674. * imus is async to the epoch, and sent immediately
  2675. *
  2676. */
  2677. struct attitude_t attitude;
  2678. // u-blox 8 seems to need 10 IMU for UBX-ESF-RAW
  2679. struct attitude_t imu[10];
  2680. /* time stuff */
  2681. /* FIXME! next lib rev need to add a place to put PPS precision */
  2682. struct timedelta_t toff;
  2683. struct timedelta_t pps;
  2684. /* quantization error adjustment to PPS. aka "sawtooth" correction */
  2685. long qErr; /* offset in picoseconds (ps) */
  2686. /* time of PPS pulse that qErr applies to */
  2687. timespec_t qErr_time;
  2688. /* Private data - client code must not set this */
  2689. void *privdata;
  2690. };
  2691. extern int gps_open(const char *, const char *,
  2692. struct gps_data_t *);
  2693. extern int gps_close(struct gps_data_t *);
  2694. extern int gps_send(struct gps_data_t *, const char *, ... );
  2695. extern int gps_read(struct gps_data_t *, char *message, int message_len);
  2696. extern int gps_unpack(char *, struct gps_data_t *);
  2697. extern bool gps_waiting(const struct gps_data_t *, int);
  2698. extern int gps_stream(struct gps_data_t *, unsigned int, void *);
  2699. extern int gps_mainloop(struct gps_data_t *, int,
  2700. void (*)(struct gps_data_t *));
  2701. extern const char *gps_data(const struct gps_data_t *);
  2702. extern const char *gps_errstr(const int);
  2703. int json_toff_read(const char *buf, struct gps_data_t *,
  2704. const char **);
  2705. int json_pps_read(const char *buf, struct gps_data_t *,
  2706. const char **);
  2707. int json_oscillator_read(const char *buf, struct gps_data_t *,
  2708. const char **);
  2709. /* dependencies on struct gpsdata_t end here */
  2710. extern void libgps_trace(int errlevel, const char *, ...);
  2711. extern void gps_clear_att(struct attitude_t *);
  2712. extern void gps_clear_dop( struct dop_t *);
  2713. extern void gps_clear_fix(struct gps_fix_t *);
  2714. extern void gps_clear_log(struct gps_log_t *);
  2715. extern void gps_merge_fix(struct gps_fix_t *, gps_mask_t, struct gps_fix_t *);
  2716. extern void gps_enable_debug(int, FILE *);
  2717. extern const char *gps_maskdump(gps_mask_t);
  2718. extern double safe_atof(const char *);
  2719. extern time_t mkgmtime(struct tm *);
  2720. extern timespec_t iso8601_to_timespec(char *);
  2721. extern char *now_to_iso8601(char[], size_t len);
  2722. extern char *timespec_to_iso8601(timespec_t t, char[], size_t len);
  2723. extern char *timespec_to_unix(timespec_t t, char[], size_t len);
  2724. extern double earth_distance(double, double, double, double);
  2725. extern double earth_distance_and_bearings(double, double, double, double,
  2726. double *,
  2727. double *);
  2728. extern double wgs84_separation(double, double);
  2729. extern double mag_var(double, double);
  2730. extern void datum_code_string(int code, char *buffer, size_t len);
  2731. extern short ubx2_to_prn(int gnssId, int svId);
  2732. /* some multipliers for interpreting GPS output */
  2733. /* International Foot to Meters, exact
  2734. * Note: not the same as the USA Survey Foot to meters:
  2735. * approximately: 0.304800609601. exactly: (1200 / 3937)
  2736. * Some states use the International Foot, not the USA Survey Foot */
  2737. #define FEET_TO_METERS 0.3048 // intl feet to meters, exact
  2738. #define METERS_TO_FEET (1 / FEET_TO_METERS) // meters to intl feet, exact
  2739. #define MILES_TO_METERS 1.609344 // Miles to meters, exact
  2740. #define METERS_TO_MILES (1 / MILES_TO_METERS) // Meters to miles, exact
  2741. #define FATHOMS_TO_METERS 1.8288 // Fathoms to meters, exact
  2742. #define METERS_TO_FATHOMS (1 / FATHOMS_TO_METER) // Meters to fathoms, exact
  2743. // gpsd uses the international nautical mile, same as USA nautical mile
  2744. // different from UK nautical mile
  2745. #define KNOTS_TO_MPH (1852 / 1609.344) // Knots to miles per hour, exact
  2746. #define KNOTS_TO_KPH 1.852 // Knots to kilometers per hour, exact
  2747. #define KNOTS_TO_MPS (KNOTS_TO_KPH / 3.6) // Knots to meters per second, exact
  2748. #define MPS_TO_KPH 3.6 // Meters per second to klicks/hr, exact
  2749. #define MPS_TO_MPH (1 / 0.44704) // Meters/second to miles per hour, exact
  2750. #define MPS_TO_KNOTS (3600.0 / 1852.0) // Meters per second to knots, exact
  2751. /* miles and knots are both the international standard versions of the units */
  2752. // angle conversion multipliers
  2753. // IS-GPS-200, and Galileo_OS_SIS_ICD_v2.0.pdf, use pi = 3.1415926535898
  2754. #define GPS_PI 3.1415926535897932384626433832795029
  2755. #define RAD_2_DEG 57.2957795130823208767981548141051703
  2756. #define DEG_2_RAD 0.0174532925199432957692369076848861271
  2757. /* other mathematical constants */
  2758. #define GPS_LN2 0.693147180559945309417232121458176568
  2759. /* WGS84(G1674) degining parameters */
  2760. /* https://en.wikipedia.org/wiki/Geodetic_datum
  2761. * Section #World_Geodetic_System_1984_(WGS_84)
  2762. *
  2763. * http://www.unoosa.org/pdf/icg/2012/template/WGS_84.pdf
  2764. */
  2765. #define WGS84A 6378137.0 /* equatorial radius (semi-major axis) */
  2766. #define WGS84F 298.257223563 /* flattening */
  2767. #define WGS84B 6356752.314245 /* polar radius (semi-minor axis) */
  2768. /* 1st eccentricity squared = (WGS84A ^ 2 + WGS84B ^ 2) / (WGS84A ^ 2)
  2769. * precomputed so C does not recompute every time */
  2770. #define WGS84E 0.006694379990197585 /* 1st eccentricity squared */
  2771. /* 2nd eccentricity squared = ((WGS84A ^ 2 - WGS84B ^ 2) / (WGS84B ^ 2)
  2772. * precomputed so C does not recompute every time */
  2773. #define WGS84E2 0.006739496742333464 /* 2nd eccentricy squared */
  2774. #define CLIGHT 299792458.0 /* speed of light (m/s) */
  2775. /* netlib_connectsock() errno return values */
  2776. #define NL_NOSERVICE -1 // can't get service entry
  2777. #define NL_NOHOST -2 // can't get host entry
  2778. #define NL_NOPROTO -3 // can't get protocol entry
  2779. #define NL_NOSOCK -4 // can't create socket
  2780. #define NL_NOSOCKOPT -5 // error SETSOCKOPT SO_REUSEADDR
  2781. #define NL_NOCONNECT -6 // can't connect to host/socket pair
  2782. #define SHM_NOSHARED -7 // shared-memory segment not available
  2783. #define SHM_NOATTACH -8 // shared-memory attach failed
  2784. #define DBUS_FAILURE -9 // DBUS initialization failure
  2785. #define DEFAULT_GPSD_PORT "2947" /* IANA assignment */
  2786. #define DEFAULT_RTCM_PORT "2101" /* IANA assignment */
  2787. /* special host values for non-socket exports */
  2788. #define GPSD_SHARED_MEMORY "shared memory"
  2789. #define GPSD_DBUS_EXPORT "DBUS export"
  2790. #ifdef __cplusplus
  2791. } /* End of the 'extern "C"' block */
  2792. #endif
  2793. #endif /* _GPSD_GPS_H_ */
  2794. /* gps.h ends here */
  2795. // vim: set expandtab shiftwidth=4