2017-05-12 06:55:59 +00:00
|
|
|
/*!
|
|
|
|
* \file rtklib_rtcm.cc
|
|
|
|
* \brief RTCM functions
|
|
|
|
* \authors <ul>
|
|
|
|
* <li> 2007-2013, T. Takasu
|
|
|
|
* <li> 2017, Javier Arribas
|
|
|
|
* <li> 2017, Carles Fernandez
|
|
|
|
* </ul>
|
|
|
|
*
|
|
|
|
* This is a derived work from RTKLIB http://www.rtklib.com/
|
|
|
|
* The original source code at https://github.com/tomojitakasu/RTKLIB is
|
|
|
|
* released under the BSD 2-clause license with an additional exclusive clause
|
|
|
|
* that does not apply here. This additional clause is reproduced below:
|
|
|
|
*
|
|
|
|
* " The software package includes some companion executive binaries or shared
|
|
|
|
* libraries necessary to execute APs on Windows. These licenses succeed to the
|
|
|
|
* original ones of these software. "
|
|
|
|
*
|
|
|
|
* Neither the executive binaries nor the shared libraries are required by, used
|
|
|
|
* or included in GNSS-SDR.
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
2017-05-12 06:55:59 +00:00
|
|
|
* Copyright (C) 2007-2013, T. Takasu
|
|
|
|
* Copyright (C) 2017, Javier Arribas
|
|
|
|
* Copyright (C) 2017, Carles Fernandez
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
2020-02-08 00:20:02 +00:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2017-05-12 06:55:59 +00:00
|
|
|
*
|
|
|
|
*
|
2020-07-28 14:57:15 +00:00
|
|
|
* -----------------------------------------------------------------------------
|
|
|
|
*/
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
#include "rtklib_rtcm.h"
|
|
|
|
#include "rtklib_rtkcmn.h"
|
|
|
|
|
2019-08-18 20:16:13 +00:00
|
|
|
// extern int encode_rtcm3(rtcm_t *rtcm, int type, int sync);
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
|
|
|
|
/* initialize rtcm control -----------------------------------------------------
|
|
|
|
* initialize rtcm control struct and reallocate memory for observation and
|
|
|
|
* ephemeris buffer in rtcm control struct
|
|
|
|
* args : rtcm_t *raw IO rtcm control struct
|
|
|
|
* return : status (1:ok,0:memory allocation error)
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
int init_rtcm(rtcm_t *rtcm)
|
|
|
|
{
|
2017-05-13 18:25:38 +00:00
|
|
|
gtime_t time0 = {0, 0.0};
|
|
|
|
obsd_t data0 = {{0, 0.0}, 0, 0, {0}, {0}, {0}, {0.0}, {0.0}, {0.0}};
|
2018-03-03 01:03:39 +00:00
|
|
|
eph_t eph0 = {0, -1, -1, 0, 0, 0, 0, 0, {0, 0.0}, {0, 0.0}, {0, 0.0},
|
|
|
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
|
2018-03-08 17:05:22 +00:00
|
|
|
0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, {0.0}, {0.0}, 0.0, 0.0};
|
2018-03-03 01:03:39 +00:00
|
|
|
geph_t geph0 = {0, -1, 0, 0, 0, 0, {0, 0.0}, {0, 0.0}, {0.0}, {0.0}, {0.0},
|
|
|
|
0.0, 0.0, 0.0};
|
|
|
|
ssr_t ssr0 = {{{0, 0.0}}, {0.0}, {0}, 0, 0, 0, 0, {0.0}, {0.0}, {0.0}, 0.0, {0.0}, {0.0}, {0.0}, 0.0, 0.0, '0'};
|
2019-08-12 22:19:31 +00:00
|
|
|
int i;
|
|
|
|
int j;
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
trace(3, "init_rtcm:\n");
|
|
|
|
|
|
|
|
rtcm->staid = rtcm->stah = rtcm->seqno = rtcm->outtype = 0;
|
|
|
|
rtcm->time = rtcm->time_s = time0;
|
|
|
|
rtcm->sta.name[0] = rtcm->sta.marker[0] = '\0';
|
|
|
|
rtcm->sta.antdes[0] = rtcm->sta.antsno[0] = '\0';
|
|
|
|
rtcm->sta.rectype[0] = rtcm->sta.recver[0] = rtcm->sta.recsno[0] = '\0';
|
|
|
|
rtcm->sta.antsetup = rtcm->sta.itrf = rtcm->sta.deltype = 0;
|
2018-03-03 01:03:39 +00:00
|
|
|
for (i = 0; i < 3; i++)
|
2017-05-12 06:55:59 +00:00
|
|
|
{
|
|
|
|
rtcm->sta.pos[i] = rtcm->sta.del[i] = 0.0;
|
|
|
|
}
|
|
|
|
rtcm->sta.hgt = 0.0;
|
2018-12-03 09:05:47 +00:00
|
|
|
rtcm->dgps = nullptr;
|
2018-03-03 01:03:39 +00:00
|
|
|
for (i = 0; i < MAXSAT; i++)
|
2017-05-12 06:55:59 +00:00
|
|
|
{
|
|
|
|
rtcm->ssr[i] = ssr0;
|
|
|
|
}
|
|
|
|
rtcm->msg[0] = rtcm->msgtype[0] = rtcm->opt[0] = '\0';
|
2019-02-11 20:13:02 +00:00
|
|
|
for (i = 0; i < 6; i++)
|
|
|
|
{
|
|
|
|
rtcm->msmtype[i][0] = '\0';
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
rtcm->obsflag = rtcm->ephsat = 0;
|
2018-03-03 01:03:39 +00:00
|
|
|
for (i = 0; i < MAXSAT; i++)
|
2019-02-11 20:13:02 +00:00
|
|
|
{
|
|
|
|
for (j = 0; j < NFREQ + NEXOBS; j++)
|
|
|
|
{
|
|
|
|
rtcm->cp[i][j] = 0.0;
|
|
|
|
rtcm->lock[i][j] = rtcm->loss[i][j] = 0;
|
|
|
|
rtcm->lltime[i][j] = time0;
|
|
|
|
}
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
rtcm->nbyte = rtcm->nbit = rtcm->len = 0;
|
|
|
|
rtcm->word = 0;
|
2019-02-11 20:13:02 +00:00
|
|
|
for (i = 0; i < 100; i++)
|
|
|
|
{
|
|
|
|
rtcm->nmsg2[i] = 0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 300; i++)
|
|
|
|
{
|
|
|
|
rtcm->nmsg3[i] = 0;
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
|
2018-12-03 09:05:47 +00:00
|
|
|
rtcm->obs.data = nullptr;
|
|
|
|
rtcm->nav.eph = nullptr;
|
|
|
|
rtcm->nav.geph = nullptr;
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
/* reallocate memory for observation and ephemris buffer */
|
2018-12-08 17:49:31 +00:00
|
|
|
if (!(rtcm->obs.data = static_cast<obsd_t *>(malloc(sizeof(obsd_t) * MAXOBS))) ||
|
|
|
|
!(rtcm->nav.eph = static_cast<eph_t *>(malloc(sizeof(eph_t) * MAXSAT))) ||
|
|
|
|
!(rtcm->nav.geph = static_cast<geph_t *>(malloc(sizeof(geph_t) * MAXPRNGLO))))
|
2017-05-12 06:55:59 +00:00
|
|
|
{
|
|
|
|
free_rtcm(rtcm);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
rtcm->obs.n = 0;
|
|
|
|
rtcm->nav.n = MAXSAT;
|
|
|
|
rtcm->nav.ng = MAXPRNGLO;
|
2019-02-11 20:13:02 +00:00
|
|
|
for (i = 0; i < MAXOBS; i++)
|
|
|
|
{
|
|
|
|
rtcm->obs.data[i] = data0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAXSAT; i++)
|
|
|
|
{
|
|
|
|
rtcm->nav.eph[i] = eph0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < MAXPRNGLO; i++)
|
|
|
|
{
|
|
|
|
rtcm->nav.geph[i] = geph0;
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* free rtcm control ----------------------------------------------------------
|
|
|
|
* free observation and ephemris buffer in rtcm control struct
|
|
|
|
* args : rtcm_t *raw IO rtcm control struct
|
|
|
|
* return : none
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
void free_rtcm(rtcm_t *rtcm)
|
|
|
|
{
|
|
|
|
trace(3, "free_rtcm:\n");
|
|
|
|
|
|
|
|
/* free memory for observation and ephemeris buffer */
|
2018-03-03 01:03:39 +00:00
|
|
|
free(rtcm->obs.data);
|
2018-12-03 09:05:47 +00:00
|
|
|
rtcm->obs.data = nullptr;
|
2018-03-03 01:03:39 +00:00
|
|
|
rtcm->obs.n = 0;
|
|
|
|
free(rtcm->nav.eph);
|
2018-12-03 09:05:47 +00:00
|
|
|
rtcm->nav.eph = nullptr;
|
2018-03-03 01:03:39 +00:00
|
|
|
rtcm->nav.n = 0;
|
|
|
|
free(rtcm->nav.geph);
|
2018-12-03 09:05:47 +00:00
|
|
|
rtcm->nav.geph = nullptr;
|
2018-03-03 01:03:39 +00:00
|
|
|
rtcm->nav.ng = 0;
|
2017-05-12 06:55:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* input rtcm 2 message from stream --------------------------------------------
|
|
|
|
* fetch next rtcm 2 message and input a message from byte stream
|
|
|
|
* args : rtcm_t *rtcm IO rtcm control struct
|
|
|
|
* unsigned char data I stream data (1 byte)
|
|
|
|
* return : status (-1: error message, 0: no message, 1: input observation data,
|
|
|
|
* 2: input ephemeris, 5: input station pos/ant parameters,
|
|
|
|
* 6: input time parameter, 7: input dgps corrections,
|
|
|
|
* 9: input special message)
|
|
|
|
* notes : before firstly calling the function, time in rtcm control struct has
|
|
|
|
* to be set to the approximate time within 1/2 hour in order to resolve
|
|
|
|
* ambiguity of time in rtcm messages.
|
|
|
|
* supported msgs RTCM ver.2: 1,3,9,14,16,17,18,19,22
|
|
|
|
* refer [1] for RTCM ver.2
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
int input_rtcm2(rtcm_t *rtcm, unsigned char data)
|
|
|
|
{
|
|
|
|
unsigned char preamb;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
trace(5, "input_rtcm2: data=%02x\n", data);
|
|
|
|
|
2019-02-11 20:13:02 +00:00
|
|
|
if ((data & 0xC0) != 0x40)
|
|
|
|
{
|
|
|
|
return 0; /* ignore if upper 2bit != 01 */
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
for (i = 0; i < 6; i++, data >>= 1)
|
|
|
|
{ /* decode 6-of-8 form */
|
|
|
|
rtcm->word = (rtcm->word << 1) + (data & 1);
|
|
|
|
|
|
|
|
/* synchronize frame */
|
|
|
|
if (rtcm->nbyte == 0)
|
|
|
|
{
|
2018-12-08 17:49:31 +00:00
|
|
|
preamb = static_cast<unsigned char>(rtcm->word >> 22);
|
2019-02-11 20:13:02 +00:00
|
|
|
if (rtcm->word & 0x40000000)
|
|
|
|
{
|
|
|
|
preamb ^= 0xFF; /* decode preamble */
|
|
|
|
}
|
|
|
|
if (preamb != RTCM2PREAMB)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
/* check parity */
|
2019-02-11 20:13:02 +00:00
|
|
|
if (!decode_word(rtcm->word, rtcm->buff))
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
rtcm->nbyte = 3;
|
|
|
|
rtcm->nbit = 0;
|
2017-05-12 06:55:59 +00:00
|
|
|
continue;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
if (++rtcm->nbit < 30)
|
2019-02-11 20:13:02 +00:00
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2018-12-03 21:08:19 +00:00
|
|
|
|
|
|
|
rtcm->nbit = 0;
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
/* check parity */
|
2018-03-03 01:03:39 +00:00
|
|
|
if (!decode_word(rtcm->word, rtcm->buff + rtcm->nbyte))
|
2017-05-12 06:55:59 +00:00
|
|
|
{
|
|
|
|
trace(2, "rtcm2 partity error: i=%d word=%08x\n", i, rtcm->word);
|
2018-03-03 01:03:39 +00:00
|
|
|
rtcm->nbyte = 0;
|
|
|
|
rtcm->word &= 0x3;
|
2017-05-12 06:55:59 +00:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
rtcm->nbyte += 3;
|
2019-02-11 20:13:02 +00:00
|
|
|
if (rtcm->nbyte == 6)
|
|
|
|
{
|
|
|
|
rtcm->len = (rtcm->buff[5] >> 3) * 3 + 6;
|
|
|
|
}
|
|
|
|
if (rtcm->nbyte < rtcm->len)
|
|
|
|
{
|
|
|
|
continue;
|
|
|
|
}
|
2018-03-03 01:03:39 +00:00
|
|
|
rtcm->nbyte = 0;
|
|
|
|
rtcm->word &= 0x3;
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
/* decode rtcm2 message */
|
|
|
|
return decode_rtcm2(rtcm);
|
2018-03-03 01:03:39 +00:00
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* input rtcm 3 message from stream --------------------------------------------
|
|
|
|
* fetch next rtcm 3 message and input a message from byte stream
|
|
|
|
* args : rtcm_t *rtcm IO rtcm control struct
|
|
|
|
* unsigned char data I stream data (1 byte)
|
|
|
|
* return : status (-1: error message, 0: no message, 1: input observation data,
|
|
|
|
* 2: input ephemeris, 5: input station pos/ant parameters,
|
|
|
|
* 10: input ssr messages)
|
|
|
|
* notes : before firstly calling the function, time in rtcm control struct has
|
|
|
|
* to be set to the approximate time within 1/2 week in order to resolve
|
|
|
|
* ambiguity of time in rtcm messages.
|
|
|
|
*
|
|
|
|
* to specify input options, set rtcm->opt to the following option
|
|
|
|
* strings separated by spaces.
|
|
|
|
*
|
|
|
|
* -EPHALL : input all ephemerides
|
|
|
|
* -STA=nnn : input only message with STAID=nnn
|
|
|
|
* -GLss : select signal ss for GPS MSM (ss=1C,1P,...)
|
|
|
|
* -RLss : select signal ss for GLO MSM (ss=1C,1P,...)
|
|
|
|
* -ELss : select signal ss for GAL MSM (ss=1C,1B,...)
|
|
|
|
* -JLss : select signal ss for QZS MSM (ss=1C,2C,...)
|
|
|
|
* -CLss : select signal ss for BDS MSM (ss=2I,7I,...)
|
|
|
|
*
|
|
|
|
* supported RTCM 3 messages
|
|
|
|
* (ref [2][3][4][5][6][7][8][9][10][11][12][13][14][15])
|
|
|
|
*
|
|
|
|
* TYPE GPS GLOASS GALILEO QZSS BEIDOU SBAS
|
|
|
|
* ----------------------------------------------------------------------
|
|
|
|
* OBS C-L1 : 1001~ 1009~ - - - -
|
|
|
|
* F-L1 : 1002 1010 - - - -
|
|
|
|
* C-L12 : 1003~ 1011~ - - - -
|
|
|
|
* F-L12 : 1004 1012 - - - -
|
|
|
|
*
|
|
|
|
* NAV : 1019 1020 1045* 1044* 1047* -
|
|
|
|
* - - 1046* - - -
|
|
|
|
*
|
|
|
|
* MSM 1 : 1071~ 1081~ 1091~ 1111*~ 1121*~ 1101*~
|
|
|
|
* 2 : 1072~ 1082~ 1092~ 1112*~ 1122*~ 1102*~
|
|
|
|
* 3 : 1073~ 1083~ 1093~ 1113*~ 1123*~ 1103*~
|
|
|
|
* 4 : 1074 1084 1094 1114* 1124* 1104*
|
|
|
|
* 5 : 1075 1085 1095 1115* 1125* 1105*
|
|
|
|
* 6 : 1076 1086 1096 1116* 1126* 1106*
|
|
|
|
* 7 : 1077 1087 1097 1117* 1127* 1107*
|
|
|
|
*
|
|
|
|
* SSR OBT : 1057 1063 1240* 1246* 1258* -
|
|
|
|
* CLK : 1058 1064 1241* 1247* 1259* -
|
|
|
|
* BIAS : 1059 1065 1242* 1248* 1260* -
|
|
|
|
* OBTCLK: 1060 1066 1243* 1249* 1261* -
|
|
|
|
* URA : 1061 1067 1244* 1250* 1262* -
|
|
|
|
* HRCLK : 1062 1068 1245* 1251* 1263* -
|
|
|
|
*
|
|
|
|
* ANT INFO : 1005 1006 1007 1008 1033
|
|
|
|
* ----------------------------------------------------------------------
|
|
|
|
* (* draft, ~ only encode)
|
|
|
|
*
|
|
|
|
* for MSM observation data with multiple signals for a frequency,
|
|
|
|
* a signal is selected according to internal priority. to select
|
|
|
|
* a specified signal, use the input options.
|
|
|
|
*
|
|
|
|
* rtcm3 message format:
|
|
|
|
* +----------+--------+-----------+--------------------+----------+
|
|
|
|
* | preamble | 000000 | length | data message | parity |
|
|
|
|
* +----------+--------+-----------+--------------------+----------+
|
|
|
|
* |<-- 8 --->|<- 6 -->|<-- 10 --->|<--- length x 8 --->|<-- 24 -->|
|
|
|
|
*
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
int input_rtcm3(rtcm_t *rtcm, unsigned char data)
|
|
|
|
{
|
|
|
|
trace(5, "input_rtcm3: data=%02x\n", data);
|
|
|
|
|
|
|
|
/* synchronize frame */
|
|
|
|
if (rtcm->nbyte == 0)
|
|
|
|
{
|
2019-02-11 20:13:02 +00:00
|
|
|
if (data != RTCM3PREAMB)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
rtcm->buff[rtcm->nbyte++] = data;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
rtcm->buff[rtcm->nbyte++] = data;
|
|
|
|
|
|
|
|
if (rtcm->nbyte == 3)
|
|
|
|
{
|
2018-03-03 01:03:39 +00:00
|
|
|
rtcm->len = getbitu(rtcm->buff, 14, 10) + 3; /* length without parity */
|
2017-05-12 06:55:59 +00:00
|
|
|
}
|
2019-02-11 20:13:02 +00:00
|
|
|
if (rtcm->nbyte < 3 || rtcm->nbyte < rtcm->len + 3)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
rtcm->nbyte = 0;
|
|
|
|
|
|
|
|
/* check parity */
|
2018-03-03 01:03:39 +00:00
|
|
|
if (rtk_crc24q(rtcm->buff, rtcm->len) != getbitu(rtcm->buff, rtcm->len * 8, 24))
|
2017-05-12 06:55:59 +00:00
|
|
|
{
|
|
|
|
trace(2, "rtcm3 parity error: len=%d\n", rtcm->len);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* decode rtcm3 message */
|
|
|
|
return decode_rtcm3(rtcm);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* input rtcm 2 message from file ----------------------------------------------
|
2018-03-25 17:47:28 +00:00
|
|
|
* fetch next rtcm 2 message and input a message from file
|
2017-05-12 06:55:59 +00:00
|
|
|
* args : rtcm_t *rtcm IO rtcm control struct
|
|
|
|
* FILE *fp I file pointer
|
|
|
|
* return : status (-2: end of file, -1...10: same as above)
|
|
|
|
* notes : same as above
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
int input_rtcm2f(rtcm_t *rtcm, FILE *fp)
|
|
|
|
{
|
2019-08-12 22:19:31 +00:00
|
|
|
int i;
|
|
|
|
int data = 0;
|
|
|
|
int ret;
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
trace(4, "input_rtcm2f: data=%02x\n", data);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
for (i = 0; i < 4096; i++)
|
2017-05-12 06:55:59 +00:00
|
|
|
{
|
2019-02-11 20:13:02 +00:00
|
|
|
if ((data = fgetc(fp)) == EOF)
|
|
|
|
{
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
if ((ret = input_rtcm2(rtcm, static_cast<unsigned char>(data))))
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
}
|
|
|
|
return 0; /* return at every 4k bytes */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* input rtcm 3 message from file ----------------------------------------------
|
2018-03-25 17:47:28 +00:00
|
|
|
* fetch next rtcm 3 message and input a message from file
|
2017-05-12 06:55:59 +00:00
|
|
|
* args : rtcm_t *rtcm IO rtcm control struct
|
|
|
|
* FILE *fp I file pointer
|
|
|
|
* return : status (-2: end of file, -1...10: same as above)
|
|
|
|
* notes : same as above
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
int input_rtcm3f(rtcm_t *rtcm, FILE *fp)
|
|
|
|
{
|
2019-08-12 22:19:31 +00:00
|
|
|
int i;
|
|
|
|
int data = 0;
|
|
|
|
int ret;
|
2017-05-12 06:55:59 +00:00
|
|
|
|
|
|
|
trace(4, "input_rtcm3f: data=%02x\n", data);
|
|
|
|
|
2018-03-03 01:03:39 +00:00
|
|
|
for (i = 0; i < 4096; i++)
|
2017-05-12 06:55:59 +00:00
|
|
|
{
|
2019-02-11 20:13:02 +00:00
|
|
|
if ((data = fgetc(fp)) == EOF)
|
|
|
|
{
|
|
|
|
return -2;
|
|
|
|
}
|
|
|
|
if ((ret = input_rtcm3(rtcm, static_cast<unsigned char>(data))))
|
|
|
|
{
|
|
|
|
return ret;
|
|
|
|
}
|
2017-05-12 06:55:59 +00:00
|
|
|
}
|
|
|
|
return 0; /* return at every 4k bytes */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* generate rtcm 2 message -----------------------------------------------------
|
|
|
|
* generate rtcm 2 message
|
|
|
|
* args : rtcm_t *rtcm IO rtcm control struct
|
|
|
|
* int type I message type
|
|
|
|
* int sync I sync flag (1:another message follows)
|
|
|
|
* return : status (1:ok,0:error)
|
|
|
|
*-----------------------------------------------------------------------------*/
|
|
|
|
int gen_rtcm2(rtcm_t *rtcm, int type, int sync)
|
|
|
|
{
|
|
|
|
trace(4, "gen_rtcm2: type=%d sync=%d\n", type, sync);
|
|
|
|
|
|
|
|
rtcm->nbit = rtcm->len = rtcm->nbyte = 0;
|
|
|
|
|
|
|
|
/* not yet implemented */
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2019-08-18 20:16:13 +00:00
|
|
|
// /* generate rtcm 3 message -----------------------------------------------------
|
2017-05-12 06:55:59 +00:00
|
|
|
// * generate rtcm 3 message
|
|
|
|
// * args : rtcm_t *rtcm IO rtcm control struct
|
|
|
|
// * int type I message type
|
|
|
|
// * int sync I sync flag (1:another message follows)
|
|
|
|
// * return : status (1:ok,0:error)
|
|
|
|
// *-----------------------------------------------------------------------------*/
|
2019-08-18 20:16:13 +00:00
|
|
|
// int gen_rtcm3(rtcm_t *rtcm, int type, int sync)
|
|
|
|
// {
|
2017-05-12 06:55:59 +00:00
|
|
|
// unsigned int crc;
|
|
|
|
// int i = 0;
|
|
|
|
//
|
|
|
|
// trace(4, "gen_rtcm3: type=%d sync=%d\n", type, sync);
|
|
|
|
//
|
|
|
|
// rtcm->nbit = rtcm->len = rtcm->nbyte = 0;
|
|
|
|
//
|
|
|
|
// /* set preamble and reserved */
|
|
|
|
// setbitu(rtcm->buff, i, 8, RTCM3PREAMB); i += 8;
|
|
|
|
// setbitu(rtcm->buff, i, 6, 0 ); i += 6;
|
|
|
|
// setbitu(rtcm->buff, i, 10, 0 ); i += 10;
|
|
|
|
//
|
|
|
|
// /* encode rtcm 3 message body */
|
|
|
|
// if (!encode_rtcm3(rtcm, type, sync)) return 0;
|
|
|
|
//
|
|
|
|
// /* padding to align 8 bit boundary */
|
|
|
|
// for (i = rtcm->nbit;i%8;i++)
|
|
|
|
// {
|
|
|
|
// setbitu(rtcm->buff, i, 1, 0);
|
|
|
|
// }
|
|
|
|
// /* message length (header+data) (bytes) */
|
|
|
|
// if ((rtcm->len = i/8) >= 3+1024)
|
|
|
|
// {
|
|
|
|
// trace(2, "generate rtcm 3 message length error len=%d\n", rtcm->len-3);
|
|
|
|
// rtcm->nbit = rtcm->len = 0;
|
|
|
|
// return 0;
|
|
|
|
// }
|
|
|
|
// /* message length without header and parity */
|
|
|
|
// setbitu(rtcm->buff, 14, 10, rtcm->len-3);
|
|
|
|
//
|
|
|
|
// /* crc-24q */
|
|
|
|
// crc = rtk_crc24q(rtcm->buff, rtcm->len);
|
|
|
|
// setbitu(rtcm->buff, i, 24, crc);
|
|
|
|
//
|
|
|
|
// /* length total (bytes) */
|
|
|
|
// rtcm->nbyte = rtcm->len+3;
|
|
|
|
//
|
|
|
|
// return 1;
|
2019-08-18 20:16:13 +00:00
|
|
|
// }
|