49#define LLI_BOCTRK 0x04
53static const double CLIGHT = 299792458.0;
54static const double FREQ1 = 1.57542E9;
55static const double FREQ2 = 1.22760E9;
56static const double FREQ5 = 1.17645E9;
57static const double FREQ6 = 1.27875E9;
58static const double FREQ7 = 1.20714E9;
59static const double FREQ8 = 1.191795E9;
60static const double FREQ9 = 2.492028E9;
71static const double D2R = 3.1415926535897932 / 180.0;
72static const double R2D = 180.0 / 3.1415926535897932;
73static const double SC2RAD = 3.1415926535897932;
76#define SSR_VENDOR_L6 0
77#define SSR_VENDOR_RTCM 1
84#define PRUNIT_GPS 299792.458
85#define PRUNIT_GLO 599584.916
86#define RANGE_MS (CLIGHT * 0.001)
90#define P2_10 0.0009765625
91#define P2_11 4.882812500000000E-04
92#define P2_19 1.907348632812500E-06
93#define P2_20 9.536743164062500E-07
94#define P2_24 5.960464477539063E-08
95#define P2_28 3.725290298461914E-09
96#define P2_29 1.862645149230957E-09
97#define P2_30 9.313225746154785E-10
98#define P2_31 4.656612873077393E-10
99#define P2_32 2.328306436538696E-10
100#define P2_33 1.164153218269348E-10
101#define P2_34 5.820766091346740E-11
102#define P2_40 9.094947017729280E-13
103#define P2_41 4.547473508864641E-13
104#define P2_43 1.136868377216160E-13
105#define P2_46 1.421085471520200E-14
106#define P2_50 8.881784197001252E-16
107#define P2_55 2.775557561562891E-17
108#define P2_59 1.734723475976810E-18
109#define P2_66 1.355252715606880E-20
129 "",
"1C",
"1P",
"1W",
"",
"",
"",
"2C",
"2P",
"2W",
"",
"",
130 "",
"",
"2S",
"2L",
"2X",
"",
"",
"",
"",
"5I",
"5Q",
"5X",
131 "",
"",
"",
"",
"",
"1S",
"1L",
"1X"
135 "",
"1C",
"1P",
"",
"",
"",
"",
"2C",
"2P",
"",
"",
"",
"",
"",
"",
"",
136 "",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""};
139 "",
"1C",
"1A",
"1B",
"1X",
"1Z",
"",
"6C",
"6A",
"6B",
"6X",
"6Z",
"",
"7I",
"7Q",
"7X",
140 "",
"8I",
"8Q",
"8X",
"",
"5I",
"5Q",
"5X",
"",
"",
"",
"",
"",
"",
"",
""};
143 "",
"1C",
"",
"",
"",
"",
"",
"",
"6S",
"6L",
"6X",
"",
"",
"",
"2S",
"2L",
144 "2X",
"",
"",
"",
"",
"5I",
"5Q",
"5X",
"",
"",
"",
"",
"",
"1S",
"1L",
"1X"};
147 "",
"1C",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
148 "",
"",
"",
"",
"",
"5I",
"5Q",
"5X",
"",
"",
"",
"",
"",
"",
"",
""};
151 "",
"2I",
"2Q",
"2X",
"",
"",
"",
"6I",
"6Q",
"6X",
"",
"",
"",
"7I",
"7Q",
"7X",
152 "",
"",
"",
"",
"",
"5D",
"5P",
"5X",
"7D",
"7P",
"7Z",
"",
"",
"1D",
"1P",
"1X"};
155 "",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
"",
156 "",
"",
"",
"",
"",
"5A",
"",
"",
"",
"",
"",
"",
"",
"",
"",
""};
172static const double ssrudint[16] = {1, 2, 5, 10, 15, 30, 60, 120, 240, 300, 600, 900, 1800, 3600, 7200, 10800};
174static double getbitg(
const uint8_t* buff,
int pos,
int len) {
175 double value =
getbitu(buff, pos + 1, len - 1);
176 return getbitu(buff, pos, 1) ? -value : value;
184 if (
rtcm->time.time == 0) {
188 if (tow < tow_p - 302400.0) {
190 }
else if (tow > tow_p + 302400.0) {
202 return week + (w - week + 512) / 1024 * 1024;
210 if (
rtcm->time.time == 0) {
215 tod_p = fmod(tow, 86400.0);
217 if (tod < tod_p - 43200.0) {
219 }
else if (tod > tod_p + 43200.0) {
227 if (
rtcm->cp[sat - 1][idx] == 0.0) {
229 }
else if (cp < rtcm->cp[sat - 1][idx] - 750.0) {
231 }
else if (cp >
rtcm->cp[sat - 1][idx] + 750.0) {
234 rtcm->cp[sat - 1][idx] = cp;
239 int lli = (!lock && !
rtcm->lock[sat - 1][idx]) || lock < rtcm->lock[sat - 1][idx];
240 rtcm->lock[sat - 1][idx] = (uint16_t)lock;
244static uint16_t
snratio(
double snr) {
return (uint16_t)(snr <= 0.0 || 100.0 <= snr ? 0.0 : snr /
SNR_UNIT + 0.5); }
249 for (i = 0; i < obs->
n; i++) {
261 for (j = 0; j < NFREQ + NEXOBS; j++) {
263 obs->
data[i].
D[j] = 0.0;
275 if ((p = strstr(
rtcm->opt,
"-STA=")) && sscanf(p,
"-STA=%d", &
id) == 1) {
281 if (
rtcm->staid == 0 ||
rtcm->obsflag) {
283 }
else if (staid !=
rtcm->staid) {
285 trace(NULL, 2,
"rtcm3 %d staid invalid id=%d %d\n", type, staid,
rtcm->staid);
297 int i = 24, staid, nsat, type;
302 if (i + 52 <=
rtcm->len * 8) {
311 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
322 trace(NULL, 4,
"decode_head1001: time=%s nsat=%d sync=%d\n", tstr, nsat, *sync);
325 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
326 sprintf(msg,
" staid=%4d %s nsat=%2d sync=%d", staid, tstr, nsat, *sync);
336 rtcm->obsflag = !sync;
341 double pr1, cnr1, tt, cp1, freq =
FREQ1;
342 int i = 24 + 64, j, index, nsat, sync, prn, code, sat, ppr1, lock1, amb, sys;
348 for (j = 0; j < nsat &&
rtcm->obs.n <
MAXOBS && i + 74 <=
rtcm->len * 8; j++) {
369 if (!(sat =
satno(sys, prn))) {
370 trace(NULL, 2,
"rtcm3 1002 satellite number error: prn=%d\n", prn);
374 if (
rtcm->obsflag || fabs(tt) > 1E-9) {
381 rtcm->obs.data[index].P[0] = pr1;
383 if (ppr1 != (
int)0xFFF80000) {
385 rtcm->obs.data[index].L[0] = pr1 * freq /
CLIGHT + cp1;
388 rtcm->obs.data[index].SNR[0] =
snratio(cnr1 * 0.25);
399 rtcm->obsflag = !sync;
405 double pr1, cnr1, cnr2, tt, cp1, cp2, freq[2] = {
FREQ1,
FREQ2};
406 int i = 24 + 64, j, index, nsat, sync, prn, sat, code1, code2, pr21, ppr1, ppr2;
407 int lock1, lock2, amb, sys;
413 for (j = 0; j < nsat &&
rtcm->obs.n <
MAXOBS && i + 125 <=
rtcm->len * 8; j++) {
444 if (!(sat =
satno(sys, prn))) {
445 trace(NULL, 2,
"rtcm3 1004 satellite number error: sys=%d prn=%d\n", sys, prn);
449 if (
rtcm->obsflag || fabs(tt) > 1E-9) {
456 rtcm->obs.data[index].P[0] = pr1;
458 if (ppr1 != (
int)0xFFF80000) {
460 rtcm->obs.data[index].L[0] = pr1 * freq[0] /
CLIGHT + cp1;
463 rtcm->obs.data[index].SNR[0] =
snratio(cnr1 * 0.25);
466 if (pr21 != (
int)0xFFFFE000) {
467 rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02;
469 if (ppr2 != (
int)0xFFF80000) {
471 rtcm->obs.data[index].L[1] = pr1 * freq[1] /
CLIGHT + cp2;
474 rtcm->obs.data[index].SNR[1] =
snratio(cnr2 * 0.25);
475 rtcm->obs.data[index].code[1] = L2codes[code2];
477 rtcm->obsflag = !sync;
482 return (
double)
getbits(buff, pos, 32) * 64.0 +
getbitu(buff, pos + 32, 6);
486 double rr[3], re[3], pos[3];
488 int i = 24 + 12, j, staid, itrf;
490 if (i + 140 ==
rtcm->len * 8) {
501 trace(NULL, 2,
"rtcm3 1005 length error: len=%d\n",
rtcm->len);
505 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
506 for (j = 0; j < 3; j++) {
507 re[j] = rr[j] * 0.0001;
510 sprintf(msg,
" staid=%4d pos=%.8f %.8f %.3f", staid, pos[0] *
R2D, pos[1] *
R2D, pos[2]);
517 sprintf(
rtcm->sta.name,
"%04d", staid);
518 rtcm->sta.deltype = 0;
519 for (j = 0; j < 3; j++) {
520 rtcm->sta.pos[j] = rr[j] * 0.0001;
521 rtcm->sta.del[j] = 0.0;
524 rtcm->sta.itrf = itrf;
529 double rr[3], re[3], pos[3], anth;
531 int i = 24 + 12, j, staid, itrf;
533 if (i + 156 <=
rtcm->len * 8) {
546 trace(NULL, 2,
"rtcm3 1006 length error: len=%d\n",
rtcm->len);
550 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
551 for (j = 0; j < 3; j++) {
552 re[j] = rr[j] * 0.0001;
555 sprintf(msg,
" staid=%4d pos=%.8f %.8f %.3f anth=%.3f", staid, pos[0] *
R2D, pos[1] *
R2D, pos[2],
563 sprintf(
rtcm->sta.name,
"%04d", staid);
564 rtcm->sta.deltype = 1;
565 for (j = 0; j < 3; j++) {
566 rtcm->sta.pos[j] = rr[j] * 0.0001;
567 rtcm->sta.del[j] = 0.0;
569 rtcm->sta.hgt = anth * 0.0001;
570 rtcm->sta.itrf = itrf;
577 int i = 24 + 12, j, staid, n, setup;
581 if (i + 28 + 8 * n <= rtcm->len * 8) {
584 for (j = 0; j < n && j < 31; j++) {
590 trace(NULL, 2,
"rtcm3 1007 length error: len=%d\n",
rtcm->len);
594 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
595 sprintf(msg,
" staid=%4d", staid);
602 sprintf(
rtcm->sta.name,
"%04d", staid);
603 strncpy(
rtcm->sta.antdes, des, n);
604 rtcm->sta.antdes[n] =
'\0';
605 rtcm->sta.antsetup = setup;
606 rtcm->sta.antsno[0] =
'\0';
611 char des[32] =
"", sno[32] =
"";
613 int i = 24 + 12, j, staid, n, m, setup;
618 if (i + 36 + 8 * (n + m) <=
rtcm->len * 8) {
621 for (j = 0; j < n && j < 31; j++) {
627 for (j = 0; j < m && j < 31; j++) {
632 trace(NULL, 2,
"rtcm3 1008 length error: len=%d\n",
rtcm->len);
636 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
637 sprintf(msg,
" staid=%4d", staid);
644 sprintf(
rtcm->sta.name,
"%04d", staid);
645 strncpy(
rtcm->sta.antdes, des, n);
646 rtcm->sta.antdes[n] =
'\0';
647 rtcm->sta.antsetup = setup;
648 strncpy(
rtcm->sta.antsno, sno, m);
649 rtcm->sta.antsno[m] =
'\0';
656 int i = 24, staid, nsat, type;
661 if (i + 49 <=
rtcm->len * 8) {
670 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
681 trace(NULL, 4,
"decode_head1009: time=%s nsat=%d sync=%d\n", tstr, nsat, *sync);
684 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
685 sprintf(msg,
" staid=%4d %s nsat=%2d sync=%d", staid, tstr, nsat, *sync);
695 rtcm->obsflag = !sync;
700 double pr1, cnr1, tt, cp1, freq1;
701 int i = 24 + 61, j, index, nsat, sync, prn, sat, code, fcn, ppr1, lock1, amb, sys =
SYS_GLO;
707 for (j = 0; j < nsat &&
rtcm->obs.n <
MAXOBS && i + 79 <=
rtcm->len * 8; j++) {
724 if (!(sat =
satno(sys, prn))) {
725 trace(NULL, 2,
"rtcm3 1010 satellite number error: prn=%d\n", prn);
728 if (!
rtcm->nav.glo_fcn[prn - 1]) {
729 rtcm->nav.glo_fcn[prn - 1] = fcn - 7 + 8;
732 if (
rtcm->obsflag || fabs(tt) > 1E-9) {
739 rtcm->obs.data[index].P[0] = pr1;
741 if (ppr1 != (
int)0xFFF80000) {
744 rtcm->obs.data[index].L[0] = pr1 * freq1 /
CLIGHT + cp1;
747 rtcm->obs.data[index].SNR[0] =
snratio(cnr1 * 0.25);
758 rtcm->obsflag = !sync;
763 double pr1, cnr1, cnr2, tt, cp1, cp2, freq1, freq2;
764 int i = 24 + 61, j, index, nsat, sync, prn, sat, fcn, code1, code2, pr21, ppr1, ppr2;
765 int lock1, lock2, amb, sys =
SYS_GLO;
771 for (j = 0; j < nsat &&
rtcm->obs.n <
MAXOBS && i + 130 <=
rtcm->len * 8; j++) {
798 if (!(sat =
satno(sys, prn))) {
799 trace(NULL, 2,
"rtcm3 1012 satellite number error: sys=%d prn=%d\n", sys, prn);
802 if (!
rtcm->nav.glo_fcn[prn - 1]) {
803 rtcm->nav.glo_fcn[prn - 1] = fcn - 7 + 8;
806 if (
rtcm->obsflag || fabs(tt) > 1E-9) {
813 rtcm->obs.data[index].P[0] = pr1;
815 if (ppr1 != (
int)0xFFF80000) {
818 rtcm->obs.data[index].L[0] = pr1 * freq1 /
CLIGHT + cp1;
821 rtcm->obs.data[index].SNR[0] =
snratio(cnr1 * 0.25);
824 if (pr21 != (
int)0xFFFFE000) {
825 rtcm->obs.data[index].P[1] = pr1 + pr21 * 0.02;
827 if (ppr2 != (
int)0xFFF80000) {
830 rtcm->obs.data[index].L[1] = pr1 * freq2 /
CLIGHT + cp2;
833 rtcm->obs.data[index].SNR[1] =
snratio(cnr2 * 0.25);
836 rtcm->obsflag = !sync;
844 double toc, sqrtA, tt;
846 int i = 24 + 12, prn, sat, week, sys =
SYS_GPS;
848 if (i + 476 <=
rtcm->len * 8) {
909 trace(NULL, 2,
"rtcm3 1019 length error: len=%d\n",
rtcm->len);
916 trace(NULL, 4,
"decode_type1019: prn=%d iode=%d toe=%.0f\n", prn, eph.
iode, eph.
toes);
919 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
920 sprintf(msg,
" prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.
iode, eph.
iodc, week,
923 if (!(sat =
satno(sys, prn))) {
924 trace(NULL, 2,
"rtcm3 1019 satellite number error: prn=%d\n", prn);
930 if (
rtcm->time.time == 0) {
934 if (tt < -302400.0) {
936 }
else if (tt >= 302400.0) {
942 eph.
A = sqrtA * sqrtA;
943 if (!strstr(
rtcm->opt,
"-EPHALL")) {
944 if (eph.
iode ==
rtcm->nav.eph[sat - 1].iode) {
948 rtcm->nav.eph[sat - 1] = eph;
956 double tk_h, tk_m, tk_s, toe, tow, tod, tof;
958 int i = 24 + 12, prn, sat, week, tb, Bn, Cn, Cn_a, P1, P2, P3, P4, P, M, ln, sys =
SYS_GLO;
960 if (i + 348 <=
rtcm->len * 8) {
1021 trace(NULL, 2,
"rtcm3 1020 length error: len=%d\n",
rtcm->len);
1024 if (!(sat =
satno(sys, prn))) {
1025 trace(NULL, 2,
"rtcm3 1020 satellite number error: prn=%d\n", prn);
1028 trace(NULL, 4,
"decode_type1020: prn=%d tk=%02.0f:%02.0f:%02.0f\n", prn, tk_h, tk_m, tk_s);
1030 if (
rtcm->outtype) {
1031 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1032 sprintf(msg,
" prn=%2d tk=%02.0f:%02.0f:%02.0f frq=%2d Bn=%d tb=%d", prn, tk_h, tk_m, tk_s, geph.
frq, Bn, tb);
1035 geph.
svh = (ln << 3) + (Cn_a << 2) + (Cn << 1) + Bn;
1036 geph.
flags = (M << 7) + (P4 << 6) + (P3 << 5) + (P2 << 4) + (P1 << 2) + P;
1037 geph.
iode = tb & 0x7F;
1038 if (
rtcm->time.time == 0) {
1042 tod = fmod(tow, 86400.0);
1044 tof = tk_h * 3600.0 + tk_m * 60.0 + tk_s - 10800.0;
1045 if (tof < tod - 43200.0) {
1047 }
else if (tof > tod + 43200.0) {
1051 toe = tb * 900.0 - 10800.0;
1052 if (toe < tod - 43200.0) {
1054 }
else if (toe > tod + 43200.0) {
1059 if (!strstr(
rtcm->opt,
"-EPHALL")) {
1060 if (fabs(
timediff(geph.
toe,
rtcm->nav.geph[prn - 1].toe)) < 1.0 && geph.
svh ==
rtcm->nav.geph[prn - 1].svh) {
1064 rtcm->nav.geph[prn - 1] = geph;
1071 trace(NULL, 2,
"rtcm3 1021: not supported message\n");
1076 trace(NULL, 2,
"rtcm3 1022: not supported message\n");
1081 trace(NULL, 2,
"rtcm3 1023: not supported message\n");
1086 trace(NULL, 2,
"rtcm3 1024: not supported message\n");
1091 trace(NULL, 2,
"rtcm3 1025: not supported message\n");
1096 trace(NULL, 2,
"rtcm3 1026: not supported message\n");
1101 trace(NULL, 2,
"rtcm3 1027: not supported message\n");
1107 int i = 24 + 12, j, staid, mjd, tod, nchar, cunit;
1109 if (i + 60 <=
rtcm->len * 8) {
1121 trace(NULL, 2,
"rtcm3 1029 length error: len=%d\n",
rtcm->len);
1124 if (i + nchar * 8 >
rtcm->len * 8) {
1125 trace(NULL, 2,
"rtcm3 1029 length error: len=%d nchar=%d\n",
rtcm->len, nchar);
1128 for (j = 0; j < nchar && j < 126; j++) {
1132 rtcm->msg[j] =
'\0';
1134 if (
rtcm->outtype) {
1135 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1136 sprintf(msg,
" staid=%4d text=%s", staid,
rtcm->msg);
1142 trace(NULL, 2,
"rtcm3 1030: not supported message\n");
1147 trace(NULL, 2,
"rtcm3 1031: not supported message\n");
1152 trace(NULL, 2,
"rtcm3 1032: not supported message\n");
1157 char des[32] =
"", sno[32] =
"", rec[32] =
"", ver[32] =
"", rsn[32] =
"";
1159 int i = 24 + 12, j, staid, n, m, n1, n2, n3, setup;
1163 n1 =
getbitu(
rtcm->buff, i + 36 + 8 * (n + m), 8);
1164 n2 =
getbitu(
rtcm->buff, i + 44 + 8 * (n + m + n1), 8);
1165 n3 =
getbitu(
rtcm->buff, i + 52 + 8 * (n + m + n1 + n2), 8);
1167 if (i + 60 + 8 * (n + m + n1 + n2 + n3) <=
rtcm->len * 8) {
1170 for (j = 0; j < n && j < 31; j++) {
1176 for (j = 0; j < m && j < 31; j++) {
1181 for (j = 0; j < n1 && j < 31; j++) {
1186 for (j = 0; j < n2 && j < 31; j++) {
1191 for (j = 0; j < n3 && j < 31; j++) {
1196 trace(NULL, 2,
"rtcm3 1033 length error: len=%d\n",
rtcm->len);
1199 if (
rtcm->outtype) {
1200 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1201 sprintf(msg,
" staid=%4d", staid);
1208 sprintf(
rtcm->sta.name,
"%04d", staid);
1209 strncpy(
rtcm->sta.antdes, des, n);
1210 rtcm->sta.antdes[n] =
'\0';
1211 rtcm->sta.antsetup = setup;
1212 strncpy(
rtcm->sta.antsno, sno, m);
1213 rtcm->sta.antsno[m] =
'\0';
1214 strncpy(
rtcm->sta.rectype, rec, n1);
1215 rtcm->sta.rectype[n1] =
'\0';
1216 strncpy(
rtcm->sta.recver, ver, n2);
1217 rtcm->sta.recver[n2] =
'\0';
1218 strncpy(
rtcm->sta.recsno, rsn, n3);
1219 rtcm->sta.recsno[n3] =
'\0';
1221 trace(NULL, 3,
"rtcm3 1033: ant=%s:%s rec=%s:%s:%s\n", des, sno, rec, ver, rsn);
1226 trace(NULL, 2,
"rtcm3 1034: not supported message\n");
1231 trace(NULL, 2,
"rtcm3 1035: not supported message\n");
1236 trace(NULL, 2,
"rtcm3 1037: not supported message\n");
1241 trace(NULL, 2,
"rtcm3 1038: not supported message\n");
1246 trace(NULL, 2,
"rtcm3 1039: not supported message\n");
1252 double toc, sqrtA, tt;
1254 int i = 24 + 12, prn, sat, week, sys =
SYS_IRN;
1256 if (i + 482 - 12 <=
rtcm->len * 8) {
1309 trace(NULL, 2,
"rtcm3 1041 length error: len=%d\n",
rtcm->len);
1312 trace(NULL, 4,
"decode_type1041: prn=%d iode=%d toe=%.0f\n", prn, eph.
iode, eph.
toes);
1314 if (
rtcm->outtype) {
1315 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1316 sprintf(msg,
" prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.
iode, week, eph.
toes, toc,
1319 if (!(sat =
satno(sys, prn))) {
1320 trace(NULL, 2,
"rtcm3 1041 satellite number error: prn=%d\n", prn);
1326 if (
rtcm->time.time == 0) {
1330 if (tt < -302400.0) {
1332 }
else if (tt >= 302400.0) {
1338 eph.
A = sqrtA * sqrtA;
1340 if (!strstr(
rtcm->opt,
"-EPHALL")) {
1341 if (eph.
iode ==
rtcm->nav.eph[sat - 1].iode) {
1345 rtcm->nav.eph[sat - 1] = eph;
1353 double toc, sqrtA, tt;
1355 int i = 24 + 12, prn, sat, week, sys =
SYS_QZS;
1357 if (i + 473 <=
rtcm->len * 8) {
1416 trace(NULL, 2,
"rtcm3 1044 length error: len=%d\n",
rtcm->len);
1419 trace(NULL, 4,
"decode_type1044: prn=%d iode=%d toe=%.0f\n", prn, eph.
iode, eph.
toes);
1421 if (
rtcm->outtype) {
1422 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1423 sprintf(msg,
" prn=%3d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.
iode, eph.
iodc, week,
1426 if (!(sat =
satno(sys, prn))) {
1427 trace(NULL, 2,
"rtcm3 1044 satellite number error: prn=%d\n", prn);
1433 if (
rtcm->time.time == 0) {
1437 if (tt < -302400.0) {
1439 }
else if (tt >= 302400.0) {
1445 eph.
A = sqrtA * sqrtA;
1447 if (!strstr(
rtcm->opt,
"-EPHALL")) {
1448 if (eph.
iode ==
rtcm->nav.eph[sat - 1].iode && eph.
iodc ==
rtcm->nav.eph[sat - 1].iodc) {
1452 rtcm->nav.eph[sat - 1] = eph;
1460 double toc, sqrtA, tt;
1462 int i = 24 + 12, prn, sat, week, e5a_hs, e5a_dvs, rsv, sys =
SYS_GAL;
1464 if (strstr(
rtcm->opt,
"-GALINAV")) {
1468 if (i + 484 <=
rtcm->len * 8) {
1525 trace(NULL, 2,
"rtcm3 1045 length error: len=%d\n",
rtcm->len);
1528 trace(NULL, 4,
"decode_type1045: prn=%d iode=%d toe=%.0f\n", prn, eph.
iode, eph.
toes);
1530 if (
rtcm->outtype) {
1531 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1532 sprintf(msg,
" prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d dvs=%d", prn, eph.
iode, week, eph.
toes, toc,
1535 if (!(sat =
satno(sys, prn))) {
1536 trace(NULL, 2,
"rtcm3 1045 satellite number error: prn=%d\n", prn);
1539 if (strstr(
rtcm->opt,
"-GALINAV")) {
1544 eph.
week = week + 1024;
1545 if (
rtcm->time.time == 0) {
1549 if (tt < -302400.0) {
1551 }
else if (tt >= 302400.0) {
1557 eph.
A = sqrtA * sqrtA;
1558 eph.
svh = (e5a_hs << 4) + (e5a_dvs << 3);
1559 eph.
code = (1 << 1) + (1 << 8);
1561 if (!strstr(
rtcm->opt,
"-EPHALL")) {
1574 double toc, sqrtA, tt;
1576 int i = 24 + 12, prn, sat, week, e5b_hs, e5b_dvs, e1_hs, e1_dvs, sys =
SYS_GAL;
1578 if (strstr(
rtcm->opt,
"-GALFNAV")) {
1582 if (i + 492 <=
rtcm->len * 8) {
1644 trace(NULL, 2,
"rtcm3 1046 length error: len=%d\n",
rtcm->len);
1647 trace(NULL, 4,
"decode_type1046: prn=%d iode=%d toe=%.0f\n", prn, eph.
iode, eph.
toes);
1649 if (
rtcm->outtype) {
1650 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1651 sprintf(msg,
" prn=%2d iode=%3d week=%d toe=%6.0f toc=%6.0f hs=%d %d dvs=%d %d", prn, eph.
iode, week, eph.
toes,
1652 toc, e5b_hs, e1_hs, e5b_dvs, e1_dvs);
1654 if (!(sat =
satno(sys, prn))) {
1655 trace(NULL, 2,
"rtcm3 1046 satellite number error: prn=%d\n", prn);
1658 if (strstr(
rtcm->opt,
"-GALFNAV")) {
1663 eph.
week = week + 1024;
1664 if (
rtcm->time.time == 0) {
1668 if (tt < -302400.0) {
1670 }
else if (tt >= 302400.0) {
1676 eph.
A = sqrtA * sqrtA;
1677 eph.
svh = (e5b_hs << 7) + (e5b_dvs << 6) + (e1_hs << 1) + (e1_dvs << 0);
1678 eph.
code = (1 << 0) + (1 << 2) + (1 << 9);
1680 if (!strstr(
rtcm->opt,
"-EPHALL")) {
1681 if (eph.
iode ==
rtcm->nav.eph[sat - 1].iode) {
1685 rtcm->nav.eph[sat - 1] = eph;
1693 double toc, sqrtA, tt;
1695 int i = 24 + 12, prn, sat, week, sys =
SYS_CMP;
1697 if (i + 499 <=
rtcm->len * 8) {
1755 trace(NULL, 2,
"rtcm3 1042 length error: len=%d\n",
rtcm->len);
1758 trace(NULL, 4,
"decode_type1042: prn=%d iode=%d toe=%.0f\n", prn, eph.
iode, eph.
toes);
1760 if (
rtcm->outtype) {
1761 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1762 sprintf(msg,
" prn=%2d iode=%3d iodc=%3d week=%d toe=%6.0f toc=%6.0f svh=%02X", prn, eph.
iode, eph.
iodc, week,
1765 if (!(sat =
satno(sys, prn))) {
1766 trace(NULL, 2,
"rtcm3 1042 satellite number error: prn=%d\n", prn);
1770 eph.
type = (prn >= 6 && prn <= 58) ? 0 : 1;
1772 if (
rtcm->time.time == 0) {
1776 if (tt < -302400.0) {
1778 }
else if (tt >= 302400.0) {
1784 eph.
A = sqrtA * sqrtA;
1785 if (!strstr(
rtcm->opt,
"-EPHALL")) {
1787 eph.
iodc ==
rtcm->nav.eph[sat - 1].iodc) {
1791 rtcm->nav.eph[sat - 1] = eph;
1823 char *msg, tstr[64];
1824 int i = 24 + 12, nsat, udi, provid = 0, solid = 0, ns;
1827 ns = (sys ==
SYS_QZS) ? 4 : 6;
1828 if (i + ((sys ==
SYS_GLO) ? 53 : 50 + ns) >
rtcm->len * 8) {
1833 if (i + 3 + 8 + 50 + ns >
rtcm->len * 8) {
1862 "decode_ssr1_head: time=%s sys=%d subtype=%d nsat=%d sync=%d iod=%d"
1863 " provid=%d solid=%d\n",
1864 tstr, sys, subtype, nsat, *sync, *iod, provid, solid);
1866 if (
rtcm->outtype) {
1867 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1868 sprintf(msg,
" %s nsat=%2d iod=%2d udi=%2d sync=%d", tstr, nsat, *iod, udi, *sync);
1875 char *msg, tstr[64];
1876 int i = 24 + 12, nsat, udi, provid = 0, solid = 0, ns;
1879 ns = (sys ==
SYS_QZS) ? 4 : 6;
1880 if (i + ((sys ==
SYS_GLO) ? 52 : 49 + ns) >
rtcm->len * 8) {
1885 if (i + 3 + 8 + 49 + ns >
rtcm->len * 8) {
1906 "decode_ssr2_head: time=%s sys=%d subtype=%d nsat=%d sync=%d iod=%d"
1907 " provid=%d solid=%d\n",
1908 tstr, sys, subtype, nsat, *sync, *iod, provid, solid);
1910 if (
rtcm->outtype) {
1911 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
1912 sprintf(msg,
" %s nsat=%2d iod=%2d udi=%2d sync=%d", tstr, nsat, *iod, udi, *sync);
1919 double udint, deph[3], ddeph[3];
1920 int i, j, k, type, sync, iod, nsat, prn, sat, iode, iodcrc = 0, refd = 0, np, ni, nj, offp;
1925 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
1966 return sync ? 0 : 10;
1978 for (j = 0; j < nsat && i + 121 + np + ni + nj <=
rtcm->len * 8; j++) {
2001 if (!(sat =
satno(sys, prn))) {
2002 trace(NULL, 2,
"rtcm3 %d satellite number error: prn=%d\n", type, prn);
2006 rtcm->ssr[sat - 1].t0[0] =
rtcm->time;
2007 rtcm->ssr[sat - 1].udi[0] = udint;
2008 rtcm->ssr[sat - 1].iod[0] = iod;
2009 rtcm->ssr[sat - 1].iode = iode;
2010 rtcm->ssr[sat - 1].iodcrc = iodcrc;
2011 rtcm->ssr[sat - 1].refd = refd;
2013 for (k = 0; k < 3; k++) {
2014 rtcm->ssr[sat - 1].deph[k] = deph[k];
2015 rtcm->ssr[sat - 1].ddeph[k] = ddeph[k];
2017 rtcm->ssr[sat - 1].update = 1;
2019 return sync ? 0 : 10;
2023 double udint, dclk[3];
2024 int i, j, k, type, sync, iod, nsat, prn, sat, np, offp;
2029 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
2058 return sync ? 0 : 10;
2068 for (j = 0; j < nsat && i + 70 + np <=
rtcm->len * 8; j++) {
2078 if (!(sat =
satno(sys, prn))) {
2079 trace(NULL, 2,
"rtcm3 %d satellite number error: prn=%d\n", type, prn);
2083 rtcm->ssr[sat - 1].t0[1] =
rtcm->time;
2084 rtcm->ssr[sat - 1].udi[1] = udint;
2085 rtcm->ssr[sat - 1].iod[1] = iod;
2087 for (k = 0; k < 3; k++) {
2088 rtcm->ssr[sat - 1].dclk[k] = dclk[k];
2090 rtcm->ssr[sat - 1].update = 1;
2092 return sync ? 0 : 10;
2096 const uint8_t* sigs;
2097 double udint, bias, cbias[
MAXCODE];
2098 int i, j, k, type, mode, sync, iod, nsat, prn, sat, nbias, np, offp;
2104 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
2139 return sync ? 0 : 10;
2149 for (j = 0; j < nsat && i + 5 + np <=
rtcm->len * 8; j++) {
2155 for (k = 0; k <
MAXCODE; k++) {
2159 for (k = 0; k < nbias && i + 19 <=
rtcm->len * 8; k++) {
2165 cbias[sigs[mode] - 1] = (float)bias;
2166 vcbias[sigs[mode] - 1] = 1;
2168 trace(NULL, 2,
"rtcm3 %d not supported mode: mode=%d\n", type, mode);
2171 if (!(sat =
satno(sys, prn))) {
2172 trace(NULL, 2,
"rtcm3 %d satellite number error: prn=%d\n", type, prn);
2176 rtcm->ssr[sat - 1].t0[4] =
rtcm->time;
2177 rtcm->ssr[sat - 1].udi[4] = udint;
2178 rtcm->ssr[sat - 1].iod[4] = iod;
2180 for (k = 0; k <
MAXCODE; k++) {
2181 rtcm->ssr[sat - 1].cbias[k] = (float)cbias[k];
2182 rtcm->ssr[sat - 1].vcbias[k] = vcbias[k];
2184 rtcm->ssr[sat - 1].update = 1;
2186 return sync ? 0 : 10;
2190 double udint, deph[3], ddeph[3], dclk[3];
2191 int i, j, k, type, nsat, sync, iod, prn, sat, iode, iodcrc = 0, refd = 0, np, ni, nj, offp;
2196 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
2237 return sync ? 0 : 10;
2249 for (j = 0; j < nsat && i + 191 + np + ni + nj <=
rtcm->len * 8; j++) {
2276 if (!(sat =
satno(sys, prn))) {
2277 trace(NULL, 2,
"rtcm3 %d satellite number error: prn=%d\n", type, prn);
2281 rtcm->ssr[sat - 1].t0[0] =
rtcm->ssr[sat - 1].t0[1] =
rtcm->time;
2282 rtcm->ssr[sat - 1].udi[0] =
rtcm->ssr[sat - 1].udi[1] = udint;
2283 rtcm->ssr[sat - 1].iod[0] =
rtcm->ssr[sat - 1].iod[1] = iod;
2284 rtcm->ssr[sat - 1].iode = iode;
2285 rtcm->ssr[sat - 1].iodcrc = iodcrc;
2286 rtcm->ssr[sat - 1].refd = refd;
2288 for (k = 0; k < 3; k++) {
2289 rtcm->ssr[sat - 1].deph[k] = deph[k];
2290 rtcm->ssr[sat - 1].ddeph[k] = ddeph[k];
2291 rtcm->ssr[sat - 1].dclk[k] = dclk[k];
2293 rtcm->ssr[sat - 1].update = 1;
2295 return sync ? 0 : 10;
2300 int i, j, type, nsat, sync, iod, prn, sat, ura, np, offp;
2305 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
2334 return sync ? 0 : 10;
2344 for (j = 0; j < nsat && i + 6 + np <=
rtcm->len * 8; j++) {
2350 if (!(sat =
satno(sys, prn))) {
2351 trace(NULL, 2,
"rtcm3 %d satellite number error: prn=%d\n", type, prn);
2355 rtcm->ssr[sat - 1].t0[3] =
rtcm->time;
2356 rtcm->ssr[sat - 1].udi[3] = udint;
2357 rtcm->ssr[sat - 1].iod[3] = iod;
2358 rtcm->ssr[sat - 1].ura = ura;
2359 rtcm->ssr[sat - 1].update = 1;
2361 return sync ? 0 : 10;
2365 double udint, hrclk;
2366 int i, j, type, nsat, sync, iod, prn, sat, np, offp;
2371 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
2400 return sync ? 0 : 10;
2410 for (j = 0; j < nsat && i + 22 + np <=
rtcm->len * 8; j++) {
2416 if (!(sat =
satno(sys, prn))) {
2417 trace(NULL, 2,
"rtcm3 %d satellite number error: prn=%d\n", type, prn);
2421 rtcm->ssr[sat - 1].t0[2] =
rtcm->time;
2422 rtcm->ssr[sat - 1].udi[2] = udint;
2423 rtcm->ssr[sat - 1].iod[2] = iod;
2424 rtcm->ssr[sat - 1].hrclk = hrclk;
2425 rtcm->ssr[sat - 1].update = 1;
2427 return sync ? 0 : 10;
2432 char *msg, tstr[64];
2433 int i = 24 + 12, nsat, udi, provid = 0, solid = 0, ns;
2436 ns = (sys ==
SYS_QZS) ? 4 : 6;
2437 if (i + ((sys ==
SYS_GLO) ? 54 : 51 + ns) >
rtcm->len * 8) {
2442 if (i + 3 + 8 + 51 + ns >
rtcm->len * 8) {
2467 "decode_ssr7_head: time=%s sys=%d subtype=%d nsat=%d sync=%d iod=%d"
2468 " provid=%d solid=%d\n",
2469 tstr, sys, subtype, nsat, *sync, *iod, provid, solid);
2471 if (
rtcm->outtype) {
2472 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
2473 sprintf(msg,
" %s nsat=%2d iod=%2d udi=%2d sync=%d", tstr, nsat, *iod, udi, *sync);
2480 const uint8_t* sigs;
2482 int i, j, k, type, mode, sync, iod, nsat, prn, sat, nbias, np, mw, offp, sii, swl;
2483 int dispe, sdc, yaw_ang, yaw_rate;
2489 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
2519 return sync ? 0 : 10;
2529 for (j = 0; j < nsat && i + 5 + 17 + np <=
rtcm->len * 8; j++) {
2539 for (k = 0; k <
MAXCODE; k++) {
2540 pbias[k] = stdpb[k] = 0.0;
2541 discnt[k] = vpbias[k] = 0;
2543 for (k = 0; k < nbias && i + ((subtype == 0) ? 49 : 32) <=
rtcm->len * 8; k++) {
2559 pbias[sigs[mode] - 1] = bias * 0.0001;
2560 stdpb[sigs[mode] - 1] = std * 0.0001;
2561 discnt[sigs[mode] - 1] = sdc;
2562 vpbias[sigs[mode] - 1] = 1;
2564 trace(NULL, 2,
"rtcm3 %d not supported mode: mode=%d\n", type, mode);
2567 if (!(sat =
satno(sys, prn))) {
2568 trace(NULL, 2,
"rtcm3 %d satellite number error: prn=%d\n", type, prn);
2572 rtcm->ssr[sat - 1].t0[5] =
rtcm->time;
2573 rtcm->ssr[sat - 1].udi[5] = udint;
2574 rtcm->ssr[sat - 1].iod[5] = iod;
2575 rtcm->ssr[sat - 1].yaw_ang = yaw_ang / 256.0 * 180.0;
2576 rtcm->ssr[sat - 1].yaw_rate = yaw_rate / 8192.0 * 180.0;
2578 for (k = 0; k <
MAXCODE; k++) {
2579 rtcm->ssr[sat - 1].pbias[k] = pbias[k];
2580 rtcm->ssr[sat - 1].stdpb[k] = (float)stdpb[k];
2581 rtcm->ssr[sat - 1].vpbias[k] = vpbias[k];
2582 rtcm->ssr[sat - 1].discnt[k] = discnt[k];
2585 return sync ? 0 : 10;
2588static void sigindex(
int sys,
const uint8_t* code,
int n,
const char* opt,
int* idx) {
2589 int i, nex, pri, pri_h[8] = {0}, index[8] = {0}, ex[32] = {0};
2592 for (i = 0; i < n; i++) {
2597 if (idx[i] >= NFREQ) {
2605 if (pri > pri_h[idx[i]]) {
2606 if (index[idx[i]]) {
2607 ex[index[idx[i]] - 1] = 1;
2609 pri_h[idx[i]] = pri;
2610 index[idx[i]] = i + 1;
2616 for (i = nex = 0; i < n; i++) {
2619 }
else if (nex < NEXOBS) {
2620 idx[i] = NFREQ + nex++;
2622 trace(NULL, 2,
"rtcm msm: no space in obs data sys=%d code=%d\n", sys, code[i]);
2626 trace(NULL,2,
"sig pos: sys=%d code=%d ex=%d idx=%d\n",sys,code[i],ex[i],idx[i]);
2632 const double* rr,
const double* rrf,
const double* cnr,
const int* lock,
const int* ex,
2634 const char* sig[32];
2637 char *msm_type =
"", *q = NULL;
2638 int i, j, k, type, prn, sat, fcn, index = 0, idx[32];
2644 msm_type = q =
rtcm->msmtype[0];
2647 msm_type = q =
rtcm->msmtype[1];
2650 msm_type = q =
rtcm->msmtype[2];
2653 msm_type = q =
rtcm->msmtype[3];
2656 msm_type = q =
rtcm->msmtype[4];
2659 msm_type = q =
rtcm->msmtype[5];
2662 msm_type = q =
rtcm->msmtype[6];
2666 for (i = 0; i < h->
nsig; i++) {
2699 q += sprintf(q,
"L%s%s", sig[i], i < h->nsig - 1 ?
"," :
"");
2703 q += sprintf(q,
"(%d)%s", h->
sigs[i], i < h->nsig - 1 ?
"," :
"");
2706 trace(NULL, 2,
"rtcm3 %d: unknown signal id=%2d\n", type, h->
sigs[i]);
2709 trace(NULL, 3,
"rtcm3 %d: signals=%s\n", type, msm_type);
2714 for (i = j = 0; i < h->
nsat; i++) {
2722 if ((sat =
satno(sys, prn))) {
2724 if (
rtcm->obsflag || fabs(tt) > 1E-9) {
2729 trace(NULL, 2,
"rtcm3 %d satellite error: prn=%d\n", type, prn);
2734 if (ex && ex[i] <= 13) {
2736 if (!
rtcm->nav.glo_fcn[prn - 1]) {
2737 rtcm->nav.glo_fcn[prn - 1] = fcn + 8;
2739 }
else if (
rtcm->nav.geph[prn - 1].sat == sat) {
2740 fcn =
rtcm->nav.geph[prn - 1].frq;
2741 }
else if (
rtcm->nav.glo_fcn[prn - 1] > 0) {
2742 fcn =
rtcm->nav.glo_fcn[prn - 1] - 8;
2745 for (k = 0; k < h->
nsig; k++) {
2750 if (sat && index >= 0 && idx[k] >= 0) {
2751 freq = fcn < -7 ? 0.0 :
code2freq(sys, code[k], fcn);
2754 if (r[i] != 0.0 && pr[j] > -1E12) {
2755 rtcm->obs.data[index].P[idx[k]] = r[i] + pr[j];
2758 if (r[i] != 0.0 && cp[j] > -1E12) {
2759 rtcm->obs.data[index].L[idx[k]] = (r[i] + cp[j]) * freq /
CLIGHT;
2762 if (rr && rrf && rrf[j] > -1E12) {
2763 rtcm->obs.data[index].D[idx[k]] = (float)(-(rr[i] + rrf[j]) * freq /
CLIGHT);
2765 rtcm->obs.data[index].LLI[idx[k]] =
lossoflock(
rtcm, sat, idx[k], lock[j]) + (half[j] ? 3 : 0);
2766 rtcm->obs.data[index].SNR[idx[k]] = (uint16_t)(cnr[j] /
SNR_UNIT + 0.5);
2767 rtcm->obs.data[index].code[idx[k]] = code[k];
2777 char *msg, tstr[64];
2778 int i = 24, j, dow, mask, staid, type, ncell = 0;
2784 if (i + 157 <=
rtcm->len * 8) {
2818 for (j = 1; j <= 64; j++) {
2825 for (j = 1; j <= 32; j++) {
2833 trace(NULL, 2,
"rtcm3 %d length error: len=%d\n", type,
rtcm->len);
2842 trace(NULL, 2,
"rtcm3 %d number of sats and sigs error: nsat=%d nsig=%d\n", type, h->
nsat, h->
nsig);
2846 trace(NULL, 2,
"rtcm3 %d length error: len=%d nsat=%d nsig=%d\n", type,
rtcm->len, h->
nsat, h->
nsig);
2849 for (j = 0; j < h->
nsat * h->
nsig; j++) {
2859 trace(NULL, 4,
"decode_head_msm: time=%s sys=%d staid=%d nsat=%d nsig=%d sync=%d iod=%d ncell=%d\n", tstr, sys,
2860 staid, h->
nsat, h->
nsig, *sync, *iod, ncell);
2862 if (
rtcm->outtype) {
2863 msg =
rtcm->msgtype + strlen(
rtcm->msgtype);
2864 sprintf(msg,
" staid=%4d %s nsat=%2d nsig=%2d iod=%2d ncell=%2d sync=%d", staid, tstr, h->
nsat, h->
nsig, *iod,
2876 rtcm->obsflag = !sync;
2877 return sync ? 0 : 1;
2882 double r[64], pr[64], cp[64], cnr[64];
2883 int i, j, type, sync, iod, ncell, rng, rng_m, prv, cpv, lock[64], half[64];
2892 if (i + h.
nsat * 18 + ncell * 48 >
rtcm->len * 8) {
2893 trace(NULL, 2,
"rtcm3 %d length error: nsat=%d ncell=%d len=%d\n", type, h.
nsat, ncell,
rtcm->len);
2896 for (j = 0; j < h.
nsat; j++) {
2899 for (j = 0; j < ncell; j++) {
2900 pr[j] = cp[j] = -1E16;
2904 for (j = 0; j < h.
nsat; j++) {
2911 for (j = 0; j < h.
nsat; j++) {
2919 for (j = 0; j < ncell; j++) {
2922 if (prv != -16384) {
2926 for (j = 0; j < ncell; j++) {
2929 if (cpv != -2097152) {
2933 for (j = 0; j < ncell; j++) {
2937 for (j = 0; j < ncell; j++) {
2941 for (j = 0; j < ncell; j++) {
2946 save_msm_obs(
rtcm, sys, &h, r, pr, cp, NULL, NULL, cnr, lock, NULL, half);
2948 rtcm->obsflag = !sync;
2949 return sync ? 0 : 1;
2954 double r[64], rr[64], pr[64], cp[64], rrf[64], cnr[64];
2955 int i, j, type, sync, iod, ncell, rng, rng_m, rate, prv, cpv, rrv, lock[64];
2956 int ex[64], half[64];
2965 if (i + h.
nsat * 36 + ncell * 63 >
rtcm->len * 8) {
2966 trace(NULL, 2,
"rtcm3 %d length error: nsat=%d ncell=%d len=%d\n", type, h.
nsat, ncell,
rtcm->len);
2969 for (j = 0; j < h.
nsat; j++) {
2973 for (j = 0; j < ncell; j++) {
2974 pr[j] = cp[j] = rrf[j] = -1E16;
2978 for (j = 0; j < h.
nsat; j++) {
2985 for (j = 0; j < h.
nsat; j++) {
2989 for (j = 0; j < h.
nsat; j++) {
2996 for (j = 0; j < h.
nsat; j++) {
2999 if (rate != -8192) {
3004 for (j = 0; j < ncell; j++) {
3007 if (prv != -16384) {
3011 for (j = 0; j < ncell; j++) {
3014 if (cpv != -2097152) {
3018 for (j = 0; j < ncell; j++) {
3022 for (j = 0; j < ncell; j++) {
3026 for (j = 0; j < ncell; j++) {
3030 for (j = 0; j < ncell; j++) {
3033 if (rrv != -16384) {
3034 rrf[j] = rrv * 0.0001;
3038 save_msm_obs(
rtcm, sys, &h, r, pr, cp, rr, rrf, cnr, lock, ex, half);
3040 rtcm->obsflag = !sync;
3041 return sync ? 0 : 1;
3046 double r[64], pr[64], cp[64], cnr[64];
3047 int i, j, type, sync, iod, ncell, rng, rng_m, prv, cpv, lock[64], half[64];
3056 if (i + h.
nsat * 18 + ncell * 65 >
rtcm->len * 8) {
3057 trace(NULL, 2,
"rtcm3 %d length error: nsat=%d ncell=%d len=%d\n", type, h.
nsat, ncell,
rtcm->len);
3060 for (j = 0; j < h.
nsat; j++) {
3063 for (j = 0; j < ncell; j++) {
3064 pr[j] = cp[j] = -1E16;
3068 for (j = 0; j < h.
nsat; j++) {
3075 for (j = 0; j < h.
nsat; j++) {
3083 for (j = 0; j < ncell; j++) {
3086 if (prv != -524288) {
3090 for (j = 0; j < ncell; j++) {
3093 if (cpv != -8388608) {
3097 for (j = 0; j < ncell; j++) {
3101 for (j = 0; j < ncell; j++) {
3105 for (j = 0; j < ncell; j++) {
3110 save_msm_obs(
rtcm, sys, &h, r, pr, cp, NULL, NULL, cnr, lock, NULL, half);
3112 rtcm->obsflag = !sync;
3113 return sync ? 0 : 1;
3118 double r[64], rr[64], pr[64], cp[64], rrf[64], cnr[64];
3119 int i, j, type, sync, iod, ncell, rng, rng_m, rate, prv, cpv, rrv, lock[64];
3120 int ex[64], half[64];
3129 if (i + h.
nsat * 36 + ncell * 80 >
rtcm->len * 8) {
3130 trace(NULL, 2,
"rtcm3 %d length error: nsat=%d ncell=%d len=%d\n", type, h.
nsat, ncell,
rtcm->len);
3133 for (j = 0; j < h.
nsat; j++) {
3137 for (j = 0; j < ncell; j++) {
3138 pr[j] = cp[j] = rrf[j] = -1E16;
3142 for (j = 0; j < h.
nsat; j++) {
3149 for (j = 0; j < h.
nsat; j++) {
3153 for (j = 0; j < h.
nsat; j++) {
3160 for (j = 0; j < h.
nsat; j++) {
3163 if (rate != -8192) {
3168 for (j = 0; j < ncell; j++) {
3171 if (prv != -524288) {
3175 for (j = 0; j < ncell; j++) {
3178 if (cpv != -8388608) {
3182 for (j = 0; j < ncell; j++) {
3186 for (j = 0; j < ncell; j++) {
3190 for (j = 0; j < ncell; j++) {
3194 for (j = 0; j < ncell; j++) {
3197 if (rrv != -16384) {
3198 rrf[j] = rrv * 0.0001;
3202 save_msm_obs(
rtcm, sys, &h, r, pr, cp, rr, rrf, cnr, lock, ex, half);
3204 rtcm->obsflag = !sync;
3205 return sync ? 0 : 1;
3209 int i = 24 + 12, j, staid, align, mask, bias;
3211 if (i + 20 >=
rtcm->len * 8) {
3212 trace(NULL, 2,
"rtcm3 1230: length error len=%d\n",
rtcm->len);
3222 if (
rtcm->outtype) {
3223 sprintf(
rtcm->msgtype + strlen(
rtcm->msgtype),
" staid=%4d align=%d mask=0x%X", staid, align, mask);
3230 rtcm->sta.glo_cp_align = align;
3231 for (j = 0; j < 4; j++) {
3232 rtcm->sta.glo_cp_bias[j] = 0.0;
3234 for (j = 0; j < 4 && i + 16 <=
rtcm->len * 8; j++) {
3235 if (!(mask & (1 << (3 - j)))) {
3240 if (bias != -32768) {
3241 rtcm->sta.glo_cp_bias[j] = bias * 0.02;
3248 int i = 24 + 12, subtype;
3253 if (
rtcm->outtype) {
3254 sprintf(
rtcm->msgtype + strlen(
rtcm->msgtype),
" subtype=%d", subtype);
3256 trace(NULL, 2,
"rtcm3 4073: unsupported message subtype=%d\n", subtype);
3261 int i = 24 + 12, ver, subtype;
3263 if (i + 3 + 8 >=
rtcm->len * 8) {
3264 trace(NULL, 2,
"rtcm3 4076: length error len=%d\n",
rtcm->len);
3272 if (
rtcm->outtype) {
3273 sprintf(
rtcm->msgtype + strlen(
rtcm->msgtype),
" ver=%d subtype=%3d", ver, subtype);
3361 trace(NULL, 2,
"rtcm3 4076: unsupported message subtype=%d\n", subtype);
3367 int i = 24 + 12, tow, errbits, prn, type, alert;
3368 uint8_t tmpbuff[1200];
3370 if (1776 !=
rtcm->len * 8) {
3371 trace(NULL, 2,
"rtcm3 4050: length error len=%d\n",
rtcm->len);
3387 trace(NULL, 3,
"rtcm3 4050: tow=%d errbits=%d prn=%d type=%d alert=%d\n", tow, errbits, prn, type, alert);
3389 memcpy(tmpbuff,
rtcm->buff,
sizeof(tmpbuff));
3391 memset(
rtcm->buff, 0x00,
sizeof(
rtcm->buff));
3393 rtcm->buff[0] = 0x1A;
3394 rtcm->buff[1] = 0xCF;
3395 rtcm->buff[2] = 0xFC;
3396 rtcm->buff[3] = 0x1D;
3397 memcpy(
rtcm->buff + 4, tmpbuff + 8,
sizeof(uint8_t) * 217);
3404 int ret = 0, type =
getbitu(
rtcm->buff, 24, 12), week;
3406 trace(NULL, 3,
"decode_rtcm3: len=%3d type=%d\n",
rtcm->len, type);
3408 if (
rtcm->outtype) {
3409 sprintf(
rtcm->msgtype,
"RTCM %4d (%4d):", type,
rtcm->len);
3412 if (strstr(
rtcm->opt,
"-RT_INP")) {
3860 if (1001 <= type && type <= 1299) {
3861 rtcm->nmsg3[type - 1000]++;
3862 }
else if (4070 <= type && type <= 4099) {
3863 rtcm->nmsg3[type - 3770]++;
MRTKLIB Atmosphere Module — Ionospheric and tropospheric models.
uint8_t obs2code(const char *obs)
uint32_t getbitu(const uint8_t *buff, int pos, int len)
Extract unsigned bits from byte data.
int32_t getbits(const uint8_t *buff, int pos, int len)
Extract signed bits from byte data.
MRTKLIB Bits Module — Binary bit operations and CRC functions.
static const double ssrudint[16]
void ecef2pos(const double *r, double *pos)
Transform ECEF position to geodetic position.
MRTKLIB Coordinates Module — Coordinate transformations and geometry.
MRTKLIB Broadcast Ephemeris Module — Satellite orbit/clock types and Kepler/GLONASS/SBAS orbit comput...
double code2freq(int sys, uint8_t code, int fcn)
int satno(int sys, int prn)
Convert satellite system+prn/slot number to satellite number.
int getcodepri(int sys, uint8_t code, const char *opt)
Get code priority for multiple codes in a frequency.
int code2freq_idx(int sys, uint8_t code)
Convert system and obs code to frequency index (obsdef-based).
MRTKLIB Observation Module — Observation data types and utility functions.
static int decode_type1029(rtcm_t *rtcm)
static int decode_type1033(rtcm_t *rtcm)
static int decode_ssr6(rtcm_t *rtcm, int sys, int subtype)
static uint16_t snratio(double snr)
static int decode_msm6(rtcm_t *rtcm, int sys)
static int decode_type1021(rtcm_t *rtcm)
const uint8_t ssr_sig_qzs[32]
static int decode_ssr1_head(rtcm_t *rtcm, int sys, int subtype, int *sync, int *iod, double *udint, int *refd, int *hsize)
static int decode_type1031(rtcm_t *rtcm)
static int decode_type4076(rtcm_t *rtcm)
static double getbitg(const uint8_t *buff, int pos, int len)
static void adjweek(rtcm_t *rtcm, double tow)
static void sigindex(int sys, const uint8_t *code, int n, const char *opt, int *idx)
static int decode_type1030(rtcm_t *rtcm)
int decode_qzss_l6emsg(rtcm_t *rtcm)
static int decode_type1045(rtcm_t *rtcm)
static int decode_ssr4(rtcm_t *rtcm, int sys, int subtype)
static int decode_type1038(rtcm_t *rtcm)
static int decode_type4073(rtcm_t *rtcm)
static int decode_type1008(rtcm_t *rtcm)
static int adjbdtweek(int week)
static int decode_ssr7_head(rtcm_t *rtcm, int sys, int subtype, int *sync, int *iod, double *udint, int *dispe, int *mw, int *hsize)
static int decode_ssr_epoch(rtcm_t *rtcm, int sys, int subtype)
static int test_staid(rtcm_t *rtcm, int staid)
static int decode_ssr7(rtcm_t *rtcm, int sys, int subtype)
static int decode_type1044(rtcm_t *rtcm)
static int decode_msm5(rtcm_t *rtcm, int sys)
static int decode_type1032(rtcm_t *rtcm)
const uint8_t ssr_sig_gps[32]
const uint8_t ssr_sig_gal[32]
static int decode_msm_head(rtcm_t *rtcm, int sys, int *sync, int *iod, msm_h_t *h, int *hsize)
static int decode_type4050(rtcm_t *rtcm)
const char * msm_sig_glo[32]
const uint8_t ssr_sig_glo[32]
static int decode_type1004(rtcm_t *rtcm)
const uint8_t ssr_sig_sbs[32]
static int decode_type1023(rtcm_t *rtcm)
static int decode_type1019(rtcm_t *rtcm)
static int decode_type1230(rtcm_t *rtcm)
static int decode_type1025(rtcm_t *rtcm)
static double getbits_38(const uint8_t *buff, int pos)
static int decode_type1037(rtcm_t *rtcm)
static int decode_msm0(rtcm_t *rtcm, int sys)
static void adjday_glot(rtcm_t *rtcm, double tod)
const char * msm_sig_gps[32]
static int decode_type1012(rtcm_t *rtcm)
static int decode_type1020(rtcm_t *rtcm)
const uint8_t ssr_sig_cmp[32]
static int decode_type1007(rtcm_t *rtcm)
static int decode_type1009(rtcm_t *rtcm)
const char * msm_sig_irn[32]
int decode_rtcm3(rtcm_t *rtcm)
Decode RTCM ver.3 message (called from rtcm.c).
static int lossoflock(rtcm_t *rtcm, int sat, int idx, int lock)
static int decode_ssr2(rtcm_t *rtcm, int sys, int subtype)
static int decode_type1003(rtcm_t *rtcm)
const char * msm_sig_gal[32]
static int decode_type1046(rtcm_t *rtcm)
static double adjcp(rtcm_t *rtcm, int sat, int idx, double cp)
static int decode_type1035(rtcm_t *rtcm)
static int decode_head1009(rtcm_t *rtcm, int *sync)
static int decode_type1010(rtcm_t *rtcm)
static int decode_msm4(rtcm_t *rtcm, int sys)
static int decode_msm7(rtcm_t *rtcm, int sys)
static int decode_type1005(rtcm_t *rtcm)
static int decode_ssr1(rtcm_t *rtcm, int sys, int subtype)
static int decode_type1006(rtcm_t *rtcm)
static int decode_type1027(rtcm_t *rtcm)
static int obsindex(obs_t *obs, gtime_t time, int sat)
static int decode_type1002(rtcm_t *rtcm)
static int decode_type1024(rtcm_t *rtcm)
static int decode_type1026(rtcm_t *rtcm)
static int decode_ssr3(rtcm_t *rtcm, int sys, int subtype)
static void save_msm_obs(rtcm_t *rtcm, int sys, msm_h_t *h, const double *r, const double *pr, const double *cp, const double *rr, const double *rrf, const double *cnr, const int *lock, const int *ex, const int *half)
const char * msm_sig_sbs[32]
static int decode_type1013(rtcm_t *rtcm)
static int decode_type1039(rtcm_t *rtcm)
static int decode_type1001(rtcm_t *rtcm)
static int decode_ssr2_head(rtcm_t *rtcm, int sys, int subtype, int *sync, int *iod, double *udint, int *hsize)
static int decode_type1042(rtcm_t *rtcm)
static int decode_type1011(rtcm_t *rtcm)
static int decode_head1001(rtcm_t *rtcm, int *sync)
const char * msm_sig_qzs[32]
static int decode_type1041(rtcm_t *rtcm)
static int decode_ssr5(rtcm_t *rtcm, int sys, int subtype)
static int decode_type1034(rtcm_t *rtcm)
static int decode_type1022(rtcm_t *rtcm)
const char * msm_sig_cmp[32]
int decode_lcliono(rtcm_t *rtcm, int type)
Decode local ionospheric delay correction grid RTCM message.
int decode_lcltrop(rtcm_t *rtcm, int type)
Decode local tropospheric delay correction grid RTCM message.
MRTKLIB RTCM Module — RTCM message types and functions.
MRTKLIB System Module — OS/filesystem utility functions.
gtime_t bdt2time(int week, double sec)
Convert BeiDou time week/tow to gtime_t.
gtime_t gpst2time(int week, double sec)
Convert GPS week/tow to gtime_t.
gtime_t gpst2bdt(gtime_t t)
Convert GPS time to BeiDou time.
void time2str(gtime_t t, char *s, int n)
Convert gtime_t struct to string.
gtime_t gpst2utc(gtime_t t)
Convert GPS time to UTC considering leap seconds.
double timediff(gtime_t t1, gtime_t t2)
Compute time difference (t1 - t2).
double time2gpst(gtime_t t, int *week)
Convert gtime_t to GPS week/tow.
double time2bdt(gtime_t t, int *week)
Convert gtime_t to BeiDou time week/tow.
int adjgpsweek(int week)
Adjust GPS week number using CPU time.
gtime_t timeadd(gtime_t t, double sec)
Add seconds to gtime_t.
gtime_t bdt2gpst(gtime_t t)
Convert BeiDou time to GPS time.
gtime_t utc2gpst(gtime_t t)
Convert UTC to GPS time considering leap seconds.
gtime_t timeget(void)
Get current time in UTC.
void trace(mrtk_ctx_t *ctx, int level, const char *format,...)
Output trace message.
MRTKLIB Trace Module — debug trace and logging functions.
GPS/GAL/QZS/BDS/IRN broadcast ephemeris type.
GLONASS broadcast ephemeris type.
GNSS time representation.
Observation data collection.
RTCM control struct type.