Devuan fork of gpsd
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

driver_rtcm3.c 26 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746
  1. /*****************************************************************************
  2. This is a decoder for RTCM-104 3.x, a serial protocol used for
  3. broadcasting pseudorange corrections from differential-GPS reference
  4. stations. The applicable specification is RTCM 10403.1: RTCM Paper
  5. 177-2006-SC104-STD. This obsolesces the earlier RTCM-104 2.x
  6. specifications. The specification document is proprietary; ordering
  7. instructions are accessible from <http://www.rtcm.org/>
  8. under "Publications".
  9. Unike the RTCM 2.x protocol, RTCM3.x does not use the strange
  10. sliding-bit-window IS-GPS-200 protocol as a transport layer, but is a
  11. self-contained byte-oriented packet protocol. Packet recognition is
  12. handled in the GPSD packet-getter state machine; this code is
  13. concerned with unpacking the packets into well-behaved C structures,
  14. coping with odd field lengths and fields that may overlap byte
  15. boudaries. These report structures live in gps.h.
  16. Note that the unpacking this module does is probably useful only for
  17. RTCM reporting and diagnostic tools. It is not necessary when
  18. passing RTCM corrections to a GPS, which normally should just be
  19. passed an entire correction packet for processing by their internal
  20. firmware.
  21. Decodes of the following types have been verified: 1004, 1005, 1006,
  22. 1008, 1012, 1013, 1029. There is good reason to believe the 1007 code
  23. is correct, as it's identical to 1008 up to where it ends.
  24. The 1033 decode was arrived at by looking at an rtcminspect dump and noting
  25. that it carries an information superset of the 1008. There are additional
  26. Receiver and Firmware fields we're not certain to decode without access
  27. to an RTCM3 standard at revision 4 or later, but the guess in the code
  28. has been observed to correctly analyze a message with a nonempty Receiver
  29. field.
  30. This file is Copyright (c) 2010-2018 by the GPSD project
  31. SPDX-License-Identifier: BSD-2-clause
  32. *****************************************************************************/
  33. #include "gpsd_config.h" /* must be before all includes */
  34. #include <string.h>
  35. #include "gpsd.h"
  36. #include "bits.h"
  37. #ifdef RTCM104V3_ENABLE
  38. /* scaling constants for RTCM3 real number types */
  39. #define GPS_PSEUDORANGE_RESOLUTION 0.02 /* DF011 */
  40. #define PSEUDORANGE_DIFF_RESOLUTION 0.0005 /* DF012,DF042 */
  41. #define CARRIER_NOISE_RATIO_UNITS 0.25 /* DF015, DF045, DF50 */
  42. #define ANTENNA_POSITION_RESOLUTION 0.0001 /* DF025-027 */
  43. #define GLONASS_PSEUDORANGE_RESOLUTION 0.02 /* DF041 */
  44. #define ANTENNA_DEGREE_RESOLUTION 25e-6 /* DF062 */
  45. #define GPS_EPOCH_TIME_RESOLUTION 0.1 /* DF065 */
  46. #define PHASE_CORRECTION_RESOLUTION 0.5 /* DF069-070 */
  47. /* Other magic values */
  48. #define GPS_INVALID_PSEUDORANGE 0x80000 /* DF012, DF018 */
  49. #define GLONASS_INVALID_RANGEINCR 0x2000 /* DF047 */
  50. #define GLONASS_CHANNEL_BASE 7 /* DF040 */
  51. /* Large case statements make GNU indent very confused */
  52. /* *INDENT-OFF* */
  53. /* good source on message types:
  54. * https://software.rtcm-ntrip.org/export/HEAD/ntrip/trunk/BNC/src/bnchelp.html
  55. * Also look in the BNC source
  56. * and look at the tklib source: http://www.rtklib.com/
  57. */
  58. void rtcm3_unpack(const struct gps_context_t *context,
  59. struct rtcm3_t *rtcm, char *buf)
  60. /* break out the raw bits into the scaled report-structure fields */
  61. {
  62. unsigned int n, n2, n3, n4;
  63. int bitcount = 0;
  64. unsigned int i;
  65. signed long temp;
  66. bool unknown = true;;
  67. #define ugrab(width) (bitcount += width, ubits((unsigned char *)buf, \
  68. bitcount-width, width, false))
  69. #define sgrab(width) (bitcount += width, sbits((signed char *)buf, \
  70. bitcount-width, width, false))
  71. #define GPS_PSEUDORANGE(fld, len) \
  72. {temp = (unsigned long)ugrab(len); \
  73. if (temp == GPS_INVALID_PSEUDORANGE) \
  74. fld.pseudorange = 0; \
  75. else \
  76. fld.pseudorange = temp * GPS_PSEUDORANGE_RESOLUTION;}
  77. #define RANGEDIFF(fld, len) \
  78. temp = (long)sgrab(len); \
  79. if (temp == GPS_INVALID_PSEUDORANGE) \
  80. fld.rangediff = 0; \
  81. else \
  82. fld.rangediff = temp * PSEUDORANGE_DIFF_RESOLUTION;
  83. memset(rtcm, 0, sizeof(struct rtcm3_t));
  84. //assert(ugrab(8) == 0xD3);
  85. //assert(ugrab(6) == 0x00);
  86. ugrab(14);
  87. rtcm->length = (unsigned int)ugrab(10);
  88. rtcm->type = (unsigned int)ugrab(12);
  89. GPSD_LOG(LOG_RAW, &context->errout, "RTCM3: type %d payload length %d\n",
  90. rtcm->type, rtcm->length);
  91. switch (rtcm->type) {
  92. case 63:
  93. /* RTCM - 63
  94. * BDS/BeiDou Ephemeris
  95. * length 64
  96. */
  97. break;
  98. case 1001:
  99. /* GPS Basic RTK, L1 Only */
  100. rtcm->rtcmtypes.rtcm3_1001.header.station_id = (unsigned int)ugrab(12);
  101. rtcm->rtcmtypes.rtcm3_1001.header.tow = (time_t)ugrab(30);
  102. rtcm->rtcmtypes.rtcm3_1001.header.sync = (bool)ugrab(1);
  103. rtcm->rtcmtypes.rtcm3_1001.header.satcount = (unsigned short)ugrab(5);
  104. rtcm->rtcmtypes.rtcm3_1001.header.smoothing = (bool)ugrab(1);
  105. rtcm->rtcmtypes.rtcm3_1001.header.interval = (unsigned short)ugrab(3);
  106. #define R1001 rtcm->rtcmtypes.rtcm3_1001.rtk_data[i]
  107. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1001.header.satcount; i++) {
  108. R1001.ident = (unsigned short)ugrab(6);
  109. R1001.L1.indicator = (unsigned char)ugrab(1);
  110. GPS_PSEUDORANGE(R1001.L1, 24);
  111. RANGEDIFF(R1001.L1, 20);
  112. R1001.L1.locktime = (unsigned char)sgrab(7);
  113. }
  114. #undef R1001
  115. unknown = false;
  116. break;
  117. case 1002:
  118. /* GPS Extended RTK, L1 Only */
  119. rtcm->rtcmtypes.rtcm3_1002.header.station_id = (unsigned int)ugrab(12);
  120. rtcm->rtcmtypes.rtcm3_1002.header.tow = (time_t)ugrab(30);
  121. rtcm->rtcmtypes.rtcm3_1002.header.sync = (bool)ugrab(1);
  122. rtcm->rtcmtypes.rtcm3_1002.header.satcount = (unsigned short)ugrab(5);
  123. rtcm->rtcmtypes.rtcm3_1002.header.smoothing = (bool)ugrab(1);
  124. rtcm->rtcmtypes.rtcm3_1002.header.interval = (unsigned short)ugrab(3);
  125. #define R1002 rtcm->rtcmtypes.rtcm3_1002.rtk_data[i]
  126. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1002.header.satcount; i++) {
  127. R1002.ident = (unsigned short)ugrab(6);
  128. R1002.L1.indicator = (unsigned char)ugrab(1);
  129. GPS_PSEUDORANGE(R1002.L1, 24);
  130. RANGEDIFF(R1002.L1, 20);
  131. R1002.L1.locktime = (unsigned char)sgrab(7);
  132. R1002.L1.ambiguity = (unsigned char)ugrab(8);
  133. R1002.L1.CNR = (ugrab(8)) * CARRIER_NOISE_RATIO_UNITS;
  134. }
  135. #undef R1002
  136. unknown = false;
  137. break;
  138. case 1003:
  139. /* GPS Basic RTK, L1 & L2 */
  140. rtcm->rtcmtypes.rtcm3_1003.header.station_id = (unsigned int)ugrab(12);
  141. rtcm->rtcmtypes.rtcm3_1003.header.tow = (time_t)ugrab(30);
  142. rtcm->rtcmtypes.rtcm3_1003.header.sync = (bool)ugrab(1);
  143. rtcm->rtcmtypes.rtcm3_1003.header.satcount = (unsigned short)ugrab(5);
  144. rtcm->rtcmtypes.rtcm3_1003.header.smoothing = (bool)ugrab(1);
  145. rtcm->rtcmtypes.rtcm3_1003.header.interval = (unsigned short)ugrab(3);
  146. #define R1003 rtcm->rtcmtypes.rtcm3_1003.rtk_data[i]
  147. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1003.header.satcount; i++) {
  148. R1003.ident = (unsigned short)ugrab(6);
  149. R1003.L1.indicator =
  150. (unsigned char)ugrab(1);
  151. GPS_PSEUDORANGE(R1003.L1, 24);
  152. RANGEDIFF(R1003.L1, 20);
  153. R1003.L1.locktime = (unsigned char)sgrab(7);
  154. R1003.L2.indicator = (unsigned char)ugrab(2);
  155. GPS_PSEUDORANGE(R1003.L2, 24);
  156. temp = (long)sgrab(20);
  157. if (temp == GPS_INVALID_PSEUDORANGE)
  158. R1003.L2.rangediff = 0;
  159. else
  160. R1003.L2.rangediff = temp * PSEUDORANGE_DIFF_RESOLUTION;
  161. R1003.L2.locktime = (unsigned char)sgrab(7);
  162. }
  163. #undef R1003
  164. unknown = false;
  165. break;
  166. case 1004:
  167. /* GPS Extended RTK, L1 & L2 */
  168. rtcm->rtcmtypes.rtcm3_1004.header.station_id = (unsigned int)ugrab(12);
  169. rtcm->rtcmtypes.rtcm3_1004.header.tow = (time_t)ugrab(30);
  170. rtcm->rtcmtypes.rtcm3_1004.header.sync = (bool)ugrab(1);
  171. rtcm->rtcmtypes.rtcm3_1004.header.satcount = (unsigned short)ugrab(5);
  172. rtcm->rtcmtypes.rtcm3_1004.header.smoothing = (bool)ugrab(1);
  173. rtcm->rtcmtypes.rtcm3_1004.header.interval = (unsigned short)ugrab(3);
  174. #define R1004 rtcm->rtcmtypes.rtcm3_1004.rtk_data[i]
  175. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1004.header.satcount; i++) {
  176. R1004.ident = (unsigned short)ugrab(6);
  177. R1004.L1.indicator = (bool)ugrab(1);
  178. GPS_PSEUDORANGE(R1004.L1, 24);
  179. RANGEDIFF(R1004.L1, 20);
  180. R1004.L1.locktime = (unsigned char)sgrab(7);
  181. R1004.L1.ambiguity = (unsigned char)ugrab(8);
  182. R1004.L1.CNR = ugrab(8) * CARRIER_NOISE_RATIO_UNITS;
  183. R1004.L2.indicator = (unsigned char)ugrab(2);
  184. GPS_PSEUDORANGE(R1004.L2, 14);
  185. RANGEDIFF(R1004.L2, 20);
  186. R1004.L2.locktime = (unsigned char)sgrab(7);
  187. R1004.L2.CNR = ugrab(8) * CARRIER_NOISE_RATIO_UNITS;
  188. }
  189. #undef R1004
  190. unknown = false;
  191. break;
  192. case 1005:
  193. /* Stationary Antenna Reference Point, No Height Information */
  194. #define R1005 rtcm->rtcmtypes.rtcm3_1005
  195. R1005.station_id = (unsigned short)ugrab(12);
  196. ugrab(6); /* reserved */
  197. R1005.system = ugrab(3);
  198. R1005.reference_station = (bool)ugrab(1);
  199. R1005.ecef_x = sgrab(38) * ANTENNA_POSITION_RESOLUTION;
  200. R1005.single_receiver = ugrab(1);
  201. ugrab(1);
  202. R1005.ecef_y = sgrab(38) * ANTENNA_POSITION_RESOLUTION;
  203. ugrab(2);
  204. R1005.ecef_z = sgrab(38) * ANTENNA_POSITION_RESOLUTION;
  205. #undef R1005
  206. unknown = false;
  207. break;
  208. case 1006:
  209. /* Stationary Antenna Reference Point, with Height Information */
  210. #define R1006 rtcm->rtcmtypes.rtcm3_1006
  211. R1006.station_id = (unsigned short)ugrab(12);
  212. (void)ugrab(6); /* reserved */
  213. R1006.system = ugrab(3);
  214. R1006.reference_station = (bool)ugrab(1);
  215. R1006.ecef_x = sgrab(38) * ANTENNA_POSITION_RESOLUTION;
  216. R1006.single_receiver = ugrab(1);
  217. ugrab(1);
  218. R1006.ecef_y = sgrab(38) * ANTENNA_POSITION_RESOLUTION;
  219. ugrab(2);
  220. R1006.ecef_z = sgrab(38) * ANTENNA_POSITION_RESOLUTION;
  221. R1006.height = ugrab(16) * ANTENNA_POSITION_RESOLUTION;
  222. #undef R1006
  223. unknown = false;
  224. break;
  225. case 1007:
  226. /* Antenna Descriptor */
  227. rtcm->rtcmtypes.rtcm3_1007.station_id = (unsigned short)ugrab(12);
  228. n = (unsigned long)ugrab(8);
  229. (void)memcpy(rtcm->rtcmtypes.rtcm3_1007.descriptor, buf + 7, n);
  230. rtcm->rtcmtypes.rtcm3_1007.descriptor[n] = '\0';
  231. bitcount += 8 * n;
  232. rtcm->rtcmtypes.rtcm3_1007.setup_id = ugrab(8);
  233. unknown = false;
  234. break;
  235. case 1008:
  236. /* Antenna Descriptor & Serial Number */
  237. rtcm->rtcmtypes.rtcm3_1008.station_id = (unsigned short)ugrab(12);
  238. n = (unsigned long)ugrab(8);
  239. (void)memcpy(rtcm->rtcmtypes.rtcm3_1008.descriptor, buf + 7, n);
  240. rtcm->rtcmtypes.rtcm3_1008.descriptor[n] = '\0';
  241. bitcount += 8 * n;
  242. rtcm->rtcmtypes.rtcm3_1008.setup_id = ugrab(8);
  243. n2 = (unsigned long)ugrab(8);
  244. (void)memcpy(rtcm->rtcmtypes.rtcm3_1008.serial, buf + 9 + n, n2);
  245. rtcm->rtcmtypes.rtcm3_1008.serial[n2] = '\0';
  246. //bitcount += 8 * n2;
  247. unknown = false;
  248. break;
  249. case 1009:
  250. /* GLONASS Basic RTK, L1 Only */
  251. rtcm->rtcmtypes.rtcm3_1009.header.station_id =
  252. (unsigned short)ugrab(12);
  253. rtcm->rtcmtypes.rtcm3_1009.header.tow = (time_t)ugrab(27);
  254. rtcm->rtcmtypes.rtcm3_1009.header.sync = (bool)ugrab(1);
  255. rtcm->rtcmtypes.rtcm3_1009.header.satcount = (unsigned short)ugrab(5);
  256. rtcm->rtcmtypes.rtcm3_1009.header.smoothing = (bool)ugrab(1);
  257. rtcm->rtcmtypes.rtcm3_1009.header.interval = (unsigned short)ugrab(3);
  258. #define R1009 rtcm->rtcmtypes.rtcm3_1009.rtk_data[i]
  259. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1009.header.satcount; i++) {
  260. R1009.ident = (unsigned short)ugrab(6);
  261. R1009.L1.indicator = (bool)ugrab(1);
  262. R1009.L1.channel = (short)ugrab(5) - GLONASS_CHANNEL_BASE;
  263. R1009.L1.pseudorange = ugrab(25) * GLONASS_PSEUDORANGE_RESOLUTION;
  264. RANGEDIFF(R1009.L1, 20);
  265. R1009.L1.locktime = (unsigned char)sgrab(7);
  266. }
  267. #undef R1009
  268. unknown = false;
  269. break;
  270. case 1010:
  271. /* GLONASS Extended RTK, L1 Only */
  272. rtcm->rtcmtypes.rtcm3_1010.header.station_id =
  273. (unsigned short)ugrab(12);
  274. rtcm->rtcmtypes.rtcm3_1010.header.tow = (time_t)ugrab(27);
  275. rtcm->rtcmtypes.rtcm3_1010.header.sync = (bool)ugrab(1);
  276. rtcm->rtcmtypes.rtcm3_1010.header.satcount = (unsigned short)ugrab(5);
  277. rtcm->rtcmtypes.rtcm3_1010.header.smoothing = (bool)ugrab(1);
  278. rtcm->rtcmtypes.rtcm3_1010.header.interval = (unsigned short)ugrab(3);
  279. #define R1010 rtcm->rtcmtypes.rtcm3_1010.rtk_data[i]
  280. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1010.header.satcount; i++) {
  281. R1010.ident = (unsigned short)ugrab(6);
  282. R1010.L1.indicator = (bool)ugrab(1);
  283. R1010.L1.channel = (short)ugrab(5) - GLONASS_CHANNEL_BASE;
  284. R1010.L1.pseudorange = ugrab(25) * GLONASS_PSEUDORANGE_RESOLUTION;
  285. RANGEDIFF(R1010.L1, 20);
  286. R1010.L1.locktime = (unsigned char)sgrab(7);
  287. R1010.L1.ambiguity = (unsigned char)ugrab(7);
  288. R1010.L1.CNR = ugrab(8) * CARRIER_NOISE_RATIO_UNITS;
  289. }
  290. #undef R1010
  291. unknown = false;
  292. break;
  293. case 1011:
  294. /* GLONASS Basic RTK, L1 & L2 */
  295. rtcm->rtcmtypes.rtcm3_1011.header.station_id =
  296. (unsigned short)ugrab(12);
  297. rtcm->rtcmtypes.rtcm3_1011.header.tow = (time_t)ugrab(27);
  298. rtcm->rtcmtypes.rtcm3_1011.header.sync = (bool)ugrab(1);
  299. rtcm->rtcmtypes.rtcm3_1011.header.satcount = (unsigned short)ugrab(5);
  300. rtcm->rtcmtypes.rtcm3_1011.header.smoothing = (bool)ugrab(1);
  301. rtcm->rtcmtypes.rtcm3_1011.header.interval = (unsigned short)ugrab(3);
  302. #define R1011 rtcm->rtcmtypes.rtcm3_1011.rtk_data[i]
  303. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1011.header.satcount; i++) {
  304. R1011.ident = (unsigned short)ugrab(6);
  305. R1011.L1.indicator = (bool)ugrab(1);
  306. R1011.L1.channel = (short)ugrab(5) - GLONASS_CHANNEL_BASE;
  307. R1011.L1.pseudorange = ugrab(25) * GLONASS_PSEUDORANGE_RESOLUTION;
  308. RANGEDIFF(R1011.L1, 20);
  309. R1011.L1.locktime = (unsigned char)sgrab(7);
  310. R1011.L1.ambiguity = (unsigned char)ugrab(7);
  311. R1011.L1.CNR = ugrab(8) * CARRIER_NOISE_RATIO_UNITS;
  312. R1011.L2.indicator = (bool)ugrab(1);
  313. R1011.L2.channel = (short)ugrab(5) - GLONASS_CHANNEL_BASE;
  314. R1011.L2.pseudorange = ugrab(25) * GLONASS_PSEUDORANGE_RESOLUTION;
  315. RANGEDIFF(R1011.L2, 20);
  316. R1011.L2.locktime = (unsigned char)sgrab(7);
  317. R1011.L2.ambiguity = (unsigned char)ugrab(7);
  318. R1011.L2.CNR = ugrab(8) * CARRIER_NOISE_RATIO_UNITS;
  319. }
  320. #undef R1011
  321. unknown = false;
  322. break;
  323. case 1012:
  324. /* GLONASS Extended RTK, L1 & L2 */
  325. rtcm->rtcmtypes.rtcm3_1012.header.station_id =
  326. (unsigned short)ugrab(12);
  327. rtcm->rtcmtypes.rtcm3_1012.header.tow = (time_t)ugrab(27);
  328. rtcm->rtcmtypes.rtcm3_1012.header.sync = (bool)ugrab(1);
  329. rtcm->rtcmtypes.rtcm3_1012.header.satcount = (unsigned short)ugrab(5);
  330. rtcm->rtcmtypes.rtcm3_1012.header.smoothing = (bool)ugrab(1);
  331. rtcm->rtcmtypes.rtcm3_1012.header.interval = (unsigned short)ugrab(3);
  332. #define R1012 rtcm->rtcmtypes.rtcm3_1012.rtk_data[i]
  333. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1012.header.satcount; i++) {
  334. unsigned int rangeincr;
  335. R1012.ident = (unsigned short)ugrab(6);
  336. R1012.L1.indicator = (bool)ugrab(1);
  337. R1012.L1.channel = (short)ugrab(5) - GLONASS_CHANNEL_BASE;
  338. R1012.L1.pseudorange = ugrab(25) * GLONASS_PSEUDORANGE_RESOLUTION;
  339. RANGEDIFF(R1012.L1, 20);
  340. R1012.L1.locktime = (unsigned char)ugrab(7);
  341. R1012.L1.ambiguity = (unsigned char)ugrab(7);
  342. R1012.L1.CNR = (unsigned char)ugrab(8) * CARRIER_NOISE_RATIO_UNITS;
  343. R1012.L2.indicator = (bool)ugrab(2);
  344. rangeincr = ugrab(14);
  345. if (rangeincr == GLONASS_INVALID_RANGEINCR)
  346. R1012.L2.pseudorange = 0;
  347. else
  348. R1012.L2.pseudorange = (rangeincr *
  349. GLONASS_PSEUDORANGE_RESOLUTION);
  350. RANGEDIFF(R1012.L2, 20);
  351. R1012.L2.locktime = (unsigned char)sgrab(7);
  352. R1012.L2.CNR = (unsigned char)ugrab(8) * CARRIER_NOISE_RATIO_UNITS;
  353. }
  354. #undef R1012
  355. unknown = false;
  356. break;
  357. case 1013:
  358. /* System Parameters */
  359. rtcm->rtcmtypes.rtcm3_1013.station_id = (unsigned short)ugrab(12);
  360. rtcm->rtcmtypes.rtcm3_1013.mjd = (unsigned short)ugrab(16);
  361. rtcm->rtcmtypes.rtcm3_1013.sod = (unsigned short)ugrab(17);
  362. rtcm->rtcmtypes.rtcm3_1013.ncount = (unsigned long)ugrab(5);
  363. rtcm->rtcmtypes.rtcm3_1013.leapsecs = (unsigned char)ugrab(8);
  364. #define R1013 rtcm->rtcmtypes.rtcm3_1013.announcements[i]
  365. for (i = 0; i < rtcm->rtcmtypes.rtcm3_1013.ncount; i++) {
  366. R1013.id = (unsigned short)ugrab(12);
  367. R1013.sync = (bool)ugrab(1);
  368. R1013.interval = (unsigned short)ugrab(16);
  369. }
  370. #undef R1013
  371. unknown = false;
  372. break;
  373. case 1014:
  374. /* Network Auxiliary Station Data
  375. * coordinate difference between one Aux station and the master station
  376. */
  377. rtcm->rtcmtypes.rtcm3_1014.network_id = (int)ugrab(8);
  378. rtcm->rtcmtypes.rtcm3_1014.subnetwork_id = (int)ugrab(4);
  379. rtcm->rtcmtypes.rtcm3_1014.stationcount = (char)ugrab(5);
  380. rtcm->rtcmtypes.rtcm3_1014.master_id = (int)ugrab(12);
  381. rtcm->rtcmtypes.rtcm3_1014.aux_id = (int)ugrab(12);
  382. rtcm->rtcmtypes.rtcm3_1014.d_lat =
  383. (unsigned short)ugrab(20) * ANTENNA_DEGREE_RESOLUTION;
  384. rtcm->rtcmtypes.rtcm3_1014.d_lon =
  385. (unsigned short)ugrab(21) * ANTENNA_DEGREE_RESOLUTION;
  386. rtcm->rtcmtypes.rtcm3_1014.d_alt = (unsigned short)ugrab(23) / 1000;
  387. unknown = false;
  388. break;
  389. case 1015:
  390. /* RTCM 3.1
  391. * GPS Ionospheric Correction Differences for all satellites
  392. * between the master station and one auxiliary station
  393. */
  394. break;
  395. case 1016:
  396. /* RTCM 3.1
  397. * GPS Geometric Correction Differences for all satellites between
  398. * the master station and one auxiliary station.
  399. */
  400. break;
  401. case 1017:
  402. /* RTCM 3.1
  403. * GPS Combined Geometric and Ionospheric Correction Differences
  404. * for all satellites between one Aux station and the master station
  405. * (same content as both types 1015 and 1016 together, but less size)
  406. */
  407. break;
  408. case 1018:
  409. /* RTCM 3.1
  410. * Reserved for alternative Ionospheric Correction Difference Message
  411. */
  412. break;
  413. case 1019:
  414. /* RTCM 3.1 - 1020
  415. * GPS Ephemeris
  416. * length 19
  417. */
  418. /* TODO: rtklib has C code for this one. */
  419. break;
  420. case 1020:
  421. /* RTCM 3.1 - 1020
  422. * GLONASS Ephemeris
  423. * length 45
  424. */
  425. /* TODO: rtklib has C code for this one. */
  426. break;
  427. case 1021:
  428. /* RTCM 3.1
  429. * Helmert / Abridged Molodenski transformation parameters
  430. */
  431. break;
  432. case 1022:
  433. /* RTCM 3.1
  434. * Molodenski-Badekas transformation parameters
  435. */
  436. break;
  437. case 1023:
  438. /* RTCM 3.1
  439. * Transformation residual message, ellipsoidal grid representation
  440. */
  441. break;
  442. case 1024:
  443. /* RTCM 3.1
  444. * Transformation residual message, plane grid representation
  445. */
  446. break;
  447. case 1025:
  448. /* RTCM 3.1
  449. * Projection parameters, types other than LCC2SP, OM
  450. */
  451. break;
  452. case 1026:
  453. /* RTCM 3.1
  454. * Projection parameters, type LCC2SP (Lambert Conic Conformal)
  455. */
  456. break;
  457. case 1027:
  458. /* RTCM 3.1
  459. * Projection parameters, type OM (Oblique Mercator)
  460. */
  461. break;
  462. case 1028:
  463. /* RTCM 3.1
  464. * Reserved for global to plate fixed transformation
  465. */
  466. break;
  467. case 1029:
  468. /* Text in UTF8 format
  469. *(max. 127 multibyte characters and max. 255 bytes)
  470. */
  471. rtcm->rtcmtypes.rtcm3_1029.station_id = (unsigned short)ugrab(12);
  472. rtcm->rtcmtypes.rtcm3_1029.mjd = (unsigned short)ugrab(16);
  473. rtcm->rtcmtypes.rtcm3_1029.sod = (unsigned short)ugrab(17);
  474. rtcm->rtcmtypes.rtcm3_1029.len = (unsigned long)ugrab(7);
  475. rtcm->rtcmtypes.rtcm3_1029.unicode_units = (size_t)ugrab(8);
  476. (void)memcpy(rtcm->rtcmtypes.rtcm3_1029.text,
  477. buf + 12, rtcm->rtcmtypes.rtcm3_1029.unicode_units);
  478. unknown = false;
  479. break;
  480. case 1030:
  481. /* RTCM 3.1
  482. * GPS network-RTK residuals message
  483. */
  484. break;
  485. case 1031:
  486. /* RTCM 3.1
  487. * GLONASS network-RTK residuals message
  488. */
  489. break;
  490. case 1032:
  491. /* RTCM 3.1
  492. * Physical reference station position message
  493. */
  494. break;
  495. case 1033: /* see note in header */
  496. /* Receiver and Antenna Descriptor
  497. * Type1033 is a combined Message Types 1007 and 1008
  498. * and hence contains antenna descriptor and serial number
  499. * as well as receiver descriptor and serial number.
  500. */
  501. /* TODO: rtklib has C code for this one. */
  502. rtcm->rtcmtypes.rtcm3_1033.station_id = (unsigned short)ugrab(12);
  503. n = (unsigned long)ugrab(8);
  504. (void)memcpy(rtcm->rtcmtypes.rtcm3_1033.descriptor, buf + 7, n);
  505. rtcm->rtcmtypes.rtcm3_1033.descriptor[n] = '\0';
  506. bitcount += 8 * n;
  507. rtcm->rtcmtypes.rtcm3_1033.setup_id = ugrab(8);
  508. n2 = (unsigned long)ugrab(8);
  509. (void)memcpy(rtcm->rtcmtypes.rtcm3_1033.serial, buf + 9 + n, n2);
  510. rtcm->rtcmtypes.rtcm3_1033.serial[n2] = '\0';
  511. bitcount += 8 * n2;
  512. n3 = (unsigned long)ugrab(8);
  513. (void)memcpy(rtcm->rtcmtypes.rtcm3_1033.receiver, buf + 10+n+n2, n3);
  514. rtcm->rtcmtypes.rtcm3_1033.receiver[n3] = '\0';
  515. bitcount += 8 * n3;
  516. n4 = (unsigned long)ugrab(8);
  517. (void)memcpy(rtcm->rtcmtypes.rtcm3_1033.firmware, buf + 11+n+n2+n3, n3);
  518. rtcm->rtcmtypes.rtcm3_1033.firmware[n4] = '\0';
  519. //bitcount += 8 * n4;
  520. // TODO: next is receiver serial number
  521. unknown = false;
  522. break;
  523. case 1043:
  524. /* RTCM 3.x - 1043
  525. * SBAS Ephemeris
  526. * length 29
  527. */
  528. break;
  529. case 1044:
  530. /* RTCM 3.x - 1044
  531. * QZSS ephemeris
  532. * length 61
  533. */
  534. /* TODO: rtklib has C code for this one. */
  535. break;
  536. case 1045:
  537. /* RTCM 3.x - 1045
  538. * Galileo Ephemeris FNAV data
  539. * length 62
  540. */
  541. /* TODO: rtklib has C code for this one. */
  542. break;
  543. case 1046:
  544. /* RTCM 3.x - 1046
  545. * Galileo Ephemeris INAV data
  546. * length 63
  547. */
  548. /* TODO: rtklib has C code for this one. */
  549. break;
  550. case 1074:
  551. /* RTCM 3.x
  552. * GPS Multi Signal Message 4
  553. */
  554. break;
  555. case 1075:
  556. /* RTCM 3.x
  557. * GPS Multi Signal Message 5
  558. */
  559. break;
  560. case 1077:
  561. /* RTCM 3.x - 1077
  562. * GPS Multi Signal Message 7
  563. * Full GPS pseudo-ranges, carrier phases, Doppler and
  564. * signal strength (high resolution)
  565. * length 438
  566. */
  567. /* TODO: rtklib has C code for this one. */
  568. break;
  569. case 1084:
  570. /* RTCM 3.x
  571. * GLONASS Multi Signal Message 4
  572. */
  573. break;
  574. case 1085:
  575. /* RTCM 3.x
  576. * GLONASS Multi Signal Message 5
  577. */
  578. break;
  579. case 1087:
  580. /* RTCM 3.x - 1087
  581. * GLONASS Multi Signal Message 7
  582. * Full GLONASS pseudo-ranges, carrier phases, Doppler and
  583. * signal strength (high resolution)
  584. * length 417 or 427
  585. */
  586. /* TODO: rtklib has C code for this one. */
  587. break;
  588. case 1094:
  589. /* RTCM 3.x
  590. * Galileo Multi Signal Message 4
  591. */
  592. break;
  593. case 1095:
  594. /* RTCM 3.x
  595. * Galileo Multi Signal Message 5
  596. */
  597. break;
  598. case 1097:
  599. /* RTCM 3.x - 1097
  600. * Galileo Multi Signal Message 7
  601. * Full Galileo pseudo-ranges, carrier phases, Doppler and
  602. * signal strength (high resolution)
  603. * length 96
  604. */
  605. /* TODO: rtklib has C code for this one. */
  606. break;
  607. case 1107:
  608. /* RTCM 3.x - 1107
  609. * 'Multiple Signal Message
  610. * Full SBAS pseudo-ranges, carrier phases, Doppler and
  611. * signal strength (high resolution)
  612. * length 96
  613. */
  614. /* TODO: rtklib has C code for this one. */
  615. break;
  616. case 1114:
  617. /* RTCM 3.x
  618. * QZSS Multi Signal Message
  619. */
  620. break;
  621. case 1124:
  622. /* RTCM 3.x
  623. * BeiDou Multi Signal Message 4
  624. */
  625. break;
  626. case 1125:
  627. /* RTCM 3.x
  628. * BeiDou Multi Signal Message 5
  629. */
  630. break;
  631. case 1127:
  632. /* RTCM 3.x
  633. * BeiDou Multi Signal Message 7
  634. */
  635. break;
  636. case 1230:
  637. /* RTCM 3.x
  638. * GLONASS L1 and L2 code-phase biases.
  639. */
  640. break;
  641. case 4072:
  642. /* RTCM 3.x
  643. * 4072.0 Reference station PVT (u-blox proprietary)
  644. * 4072.1 Additional reference station information (u-blox proprietary)
  645. */
  646. break;
  647. default:
  648. break;
  649. }
  650. #undef RANGEDIFF
  651. #undef GPS_PSEUDORANGE
  652. #undef sgrab
  653. #undef ugrab
  654. if ( unknown ) {
  655. /*
  656. * Leader bytes, message length, and checksum won't be copied.
  657. * The first 12 bits of the copied payload will be the type field.
  658. */
  659. memcpy(rtcm->rtcmtypes.data, buf+3, rtcm->length);
  660. GPSD_LOG(LOG_PROG, &context->errout,
  661. "RTCM3: unknown type %d, length %d\n",
  662. rtcm->type, rtcm->length);
  663. }
  664. }
  665. /* *INDENT-ON* */
  666. #endif /* RTCM104V3_ENABLE */
  667. // vim: set expandtab shiftwidth=4