34#define PI 3.1415926535897932
35#define D2R (PI / 180.0)
36#define R2D (180.0 / PI)
37#define CLIGHT 299792458.0
38#define SC2RAD 3.1415926535898
57#define FREQ1 1.57542E9
58#define FREQ2 1.22760E9
59#define FREQ5 1.17645E9
60#define FREQ6 1.27875E9
61#define FREQ7 1.20714E9
62#define FREQ8 1.191795E9
63#define FREQ9 2.492028E9
64#define FREQ1_GLO 1.60200E9
65#define DFRQ1_GLO 0.56250E6
66#define FREQ2_GLO 1.24600E9
67#define DFRQ2_GLO 0.43750E6
68#define FREQ3_GLO 1.202025E9
69#define FREQ1a_GLO 1.600995E9
70#define FREQ2a_GLO 1.248060E9
71#define FREQ1_CMP 1.561098E9
81#define P2_11 4.882812500000000E-04
82#define P2_15 3.051757812500000E-05
83#define P2_17 7.629394531250000E-06
84#define P2_19 1.907348632812500E-06
85#define P2_20 9.536743164062500E-07
86#define P2_21 4.768371582031250E-07
87#define P2_23 1.192092895507810E-07
88#define P2_24 5.960464477539063E-08
89#define P2_27 7.450580596923828E-09
90#define P2_29 1.862645149230957E-09
91#define P2_30 9.313225746154785E-10
92#define P2_31 4.656612873077393E-10
93#define P2_32 2.328306436538696E-10
94#define P2_33 1.164153218269348E-10
95#define P2_34 5.820766091346740E-11
96#define P2_35 2.910383045673370E-11
97#define P2_38 3.637978807091710E-12
98#define P2_40 9.094947017729280E-13
99#define P2_43 1.136868377216160E-13
100#define P2_46 1.421085471520200E-14
101#define P2_50 8.881784197001252E-16
102#define P2_55 2.775557561562891E-17
103#define P2_59 1.734723475976810E-18
116#define U1(p) (*((uint8_t*)(p)))
117static uint16_t
U2(uint8_t* p) {
122static uint32_t
U4(uint8_t* p) {
127static double R8(uint8_t* p) {
134static int chksum(
const uint8_t* buff,
int len) {
138 for (i = 0; i < len - 2; i++) {
141 return (sum >> 8) == buff[len - 1] && (sum & 0xFF) == buff[len - 2];
152 if (sec < tow - 302400.0) {
154 }
else if (sec > tow + 302400.0) {
163 uint8_t* p = raw->
buff + 4;
165 trace(NULL, 4,
"decode_ss2llh: len=%d\n", raw->
len);
167 if (raw->
len != 77) {
168 trace(NULL, 2,
"ss2 id#20 length error: len=%d\n", raw->
len);
182 uint8_t* p = raw->
buff + 4;
184 trace(NULL, 4,
"decode_ss2ecef: len=%d\n", raw->
len);
186 if (raw->
len != 85) {
187 trace(NULL, 2,
"ss2 id#21 length error: len=%d\n", raw->
len);
195 const double freqif = 1.405396825E6, tslew = 1.75E-7;
196 double tow, slew, code, icp, d;
197 int i, j, n, prn, sat, nobs;
198 uint8_t* p = raw->
buff + 4;
201 trace(NULL, 4,
"decode_ss2meas: len=%d\n", raw->
len);
204 if (17 + nobs * 11 != raw->
len) {
205 trace(NULL, 2,
"ss2 id#23 message length error: len=%d\n", raw->
len);
208 tow = floor(
R8(p + 3) * 1000.0 + 0.5) / 1000.0;
210 trace(NULL, 2,
"ss2 id#23 message time adjustment error\n");
214 slew = *(
char*)(p)*tslew;
216 raw->
icpc += 4.5803 - freqif * slew -
FREQ1 * (slew - 1E-6);
218 for (i = n = 0, p += 11; i < nobs && n <
MAXOBS; i++, p += 11) {
219 prn = (p[0] & 0x1F) + 1;
221 trace(NULL, 2,
"ss2 id#23 satellite number error: prn=%d\n", prn);
226 code = (tow - floor(tow)) - (
double)(
U4(p + 2)) / 2095104000.0;
227 raw->
obs.
data[n].
P[0] =
CLIGHT * (code + (code < 0.0 ? 1.0 : 0.0));
228 icp = (double)(
U4(p + 6) >> 2) / 1024.0 + raw->
off[sat - 1];
229 if (fabs(icp - raw->
icpp[sat - 1]) > 524288.0) {
230 d = icp > raw->
icpp[sat - 1] ? -1048576.0 : 1048576.0;
231 raw->
off[sat - 1] += d;
234 raw->
icpp[sat - 1] = icp;
239 raw->
obs.
data[n].
LLI[0] = (int)((uint8_t)sc - (uint8_t)raw->
lockt[sat - 1][0]) > 0;
242 raw->
lockt[sat - 1][0] = sc;
244 for (j = 1; j < NFREQ; j++) {
259 uint8_t *p = raw->
buff + 4, buff[90] = {0};
262 trace(NULL, 4,
"decode_ss2eph: len=%d\n", raw->
len);
264 if (raw->
len != 79) {
265 trace(NULL, 2,
"ss2 id#22 length error: len=%d\n", raw->
len);
268 prn = (
U4(p) & 0x1F) + 1;
270 trace(NULL, 2,
"ss2 id#22 satellite number error: prn=%d\n", prn);
274 trace(NULL, 2,
"ss2 id#22 week number unknown error\n");
278 for (i = 0; i < 3; i++) {
279 buff[30 * i + 3] = (uint8_t)(tow >> 9);
280 buff[30 * i + 4] = (uint8_t)(tow >> 1);
281 buff[30 * i + 5] = (uint8_t)(((tow & 1) << 7) + ((i + 1) << 2));
282 for (j = 0; j < 24; j++) {
283 buff[30 * i + 6 + j] = p[1 + 24 * i + j];
287 trace(NULL, 2,
"ss2 id#22 subframe error: prn=%d\n", prn);
290 if (!strstr(raw->
opt,
"-EPHALL")) {
297 raw->
nav.
eph[sat - 1] = eph;
306 uint8_t* p = raw->
buff + 4;
308 trace(NULL, 4,
"decode_ss2sbas: len=%d\n", raw->
len);
310 if (raw->
len != 54) {
311 trace(NULL, 2,
"ss2 id#67 length error: len=%d\n", raw->
len);
316 trace(NULL, 3,
"ss2 id#67 prn error: prn=%d\n", prn);
323 for (i = 0; i < 29; i++) {
330 uint8_t* p = raw->
buff;
331 int type =
U1(p + 1);
333 trace(NULL, 3,
"decode_ss2: type=%2d\n", type);
336 trace(NULL, 2,
"ss2 message checksum error: type=%d len=%d\n", type, raw->
len);
340 sprintf(raw->
msgtype,
"SS2 %2d (%4d):", type, raw->
len);
361 return buff[0] ==
SS2SOH && (buff[1] ^ buff[2]) == 0xFF;
374 trace(NULL, 5,
"input_ss2: data=%02x\n", data);
377 if (raw->
nbyte == 0) {
386 if (raw->
nbyte == 4) {
388 trace(NULL, 2,
"ss2 length error: len=%d\n", raw->
len);
410 trace(NULL, 4,
"input_ss2f:\n");
413 if (raw->
nbyte == 0) {
415 if ((data = fgetc(fp)) == EOF) {
426 if (fread(raw->
buff + 3, 1, 1, fp) < 1) {
432 trace(NULL, 2,
"ss2 length error: len=%d\n", raw->
len);
436 if (fread(raw->
buff + 4, 1, raw->
len - 4, fp) < (
size_t)(raw->
len - 4)) {
MRTKLIB Bits Module — Binary bit operations and CRC functions.
MRTKLIB Broadcast Ephemeris Module — Satellite orbit/clock types and Kepler/GLONASS/SBAS orbit comput...
MRTKLIB Matrix Module — Matrix/vector operations and estimation.
int satno(int sys, int prn)
Convert satellite system+prn/slot number to satellite number.
MRTKLIB Navigation Module — Navigation data types and satellite/nav utility functions.
MRTKLIB Observation Module — Observation data types and utility functions.
static int sync_ss2(uint8_t *buff, uint8_t data)
static int decode_ss2eph(raw_t *raw)
static int decode_ss2meas(raw_t *raw)
int input_ss2f(raw_t *raw, FILE *fp)
static int decode_ss2(raw_t *raw)
int input_ss2(raw_t *raw, uint8_t data)
static int decode_ss2ecef(raw_t *raw)
static int chksum(const uint8_t *buff, int len)
static int adjweek(raw_t *raw, double sec)
static int decode_ss2llh(raw_t *raw)
static int decode_ss2sbas(raw_t *raw)
int decode_frame(const uint8_t *buff, eph_t *eph, alm_t *alm, double *ion, double *utc)
MRTKLIB Receiver Raw Data Module — Receiver raw data types and decoder functions for various GNSS rec...
MRTKLIB RTCM Module — RTCM message types and functions.
MRTKLIB System Module — OS/filesystem utility functions.
gtime_t epoch2time(const double *ep)
Convert calendar day/time to gtime_t struct.
gtime_t gpst2time(int week, double sec)
Convert GPS week/tow to gtime_t.
double time2gpst(gtime_t t, int *week)
Convert gtime_t to GPS week/tow.
gtime_t utc2gpst(gtime_t t)
Convert UTC to GPS time considering leap seconds.
MRTKLIB Time Module — GNSS time types and conversion functions.
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.
GNSS time representation.
Receiver raw data control type.
double lockt[MAXSAT][5+5]