[27] | 1 | /*
|
---|
| 2 | Converter for RTCM3 data to RINEX.
|
---|
[2487] | 3 | $Id: rtcm3torinex.c 4535 2012-08-16 13:24:51Z stoecker $
|
---|
[4417] | 4 | Copyright (C) 2005-2012 by Dirk Stöcker <stoecker@alberding.eu>
|
---|
[27] | 5 |
|
---|
[268] | 6 | This software is a complete NTRIP-RTCM3 to RINEX converter as well as
|
---|
| 7 | a module of the BNC tool for multiformat conversion. Contact Dirk
|
---|
[744] | 8 | Stöcker for suggestions and bug reports related to the RTCM3 to RINEX
|
---|
[268] | 9 | conversion problems and the author of BNC for all the other problems.
|
---|
| 10 |
|
---|
[27] | 11 | This program is free software; you can redistribute it and/or modify
|
---|
| 12 | it under the terms of the GNU General Public License as published by
|
---|
| 13 | the Free Software Foundation; either version 2 of the License, or
|
---|
| 14 | (at your option) any later version.
|
---|
| 15 |
|
---|
| 16 | This program is distributed in the hope that it will be useful,
|
---|
| 17 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 18 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 19 | GNU General Public License for more details.
|
---|
| 20 |
|
---|
| 21 | You should have received a copy of the GNU General Public License
|
---|
| 22 | along with this program; if not, write to the Free Software
|
---|
| 23 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
| 24 | or read http://www.gnu.org/licenses/gpl.txt
|
---|
| 25 | */
|
---|
| 26 |
|
---|
| 27 | #include <ctype.h>
|
---|
| 28 | #include <errno.h>
|
---|
| 29 | #include <math.h>
|
---|
| 30 | #include <signal.h>
|
---|
[318] | 31 | #include <stdarg.h>
|
---|
[27] | 32 | #include <stdio.h>
|
---|
| 33 | #include <stdlib.h>
|
---|
| 34 | #include <string.h>
|
---|
| 35 | #include <sys/types.h>
|
---|
| 36 | #include <time.h>
|
---|
| 37 | #include <unistd.h>
|
---|
| 38 |
|
---|
[268] | 39 | #ifndef NO_RTCM3_MAIN
|
---|
| 40 | #include <getopt.h>
|
---|
| 41 | #include <netdb.h>
|
---|
| 42 | #include <netinet/in.h>
|
---|
| 43 | #include <sys/socket.h>
|
---|
| 44 | #endif
|
---|
[27] | 45 |
|
---|
[269] | 46 | #ifndef sparc
|
---|
| 47 | #include <stdint.h>
|
---|
| 48 | #endif
|
---|
| 49 |
|
---|
[2346] | 50 | #ifndef isinf
|
---|
| 51 | #define isinf(x) 0
|
---|
| 52 | #endif
|
---|
| 53 |
|
---|
[268] | 54 | #include "rtcm3torinex.h"
|
---|
[27] | 55 |
|
---|
| 56 | /* CVS revision and version */
|
---|
[2487] | 57 | static char revisionstr[] = "$Revision: 4535 $";
|
---|
[27] | 58 |
|
---|
[439] | 59 | #ifndef COMPILEDATE
|
---|
| 60 | #define COMPILEDATE " built " __DATE__
|
---|
| 61 | #endif
|
---|
| 62 |
|
---|
[27] | 63 | static uint32_t CRC24(long size, const unsigned char *buf)
|
---|
| 64 | {
|
---|
| 65 | uint32_t crc = 0;
|
---|
| 66 | int i;
|
---|
| 67 |
|
---|
| 68 | while(size--)
|
---|
| 69 | {
|
---|
| 70 | crc ^= (*buf++) << (16);
|
---|
| 71 | for(i = 0; i < 8; i++)
|
---|
| 72 | {
|
---|
| 73 | crc <<= 1;
|
---|
| 74 | if(crc & 0x1000000)
|
---|
| 75 | crc ^= 0x01864cfb;
|
---|
| 76 | }
|
---|
| 77 | }
|
---|
| 78 | return crc;
|
---|
| 79 | }
|
---|
| 80 |
|
---|
| 81 | static int GetMessage(struct RTCM3ParserData *handle)
|
---|
| 82 | {
|
---|
| 83 | unsigned char *m, *e;
|
---|
| 84 | int i;
|
---|
| 85 |
|
---|
| 86 | m = handle->Message+handle->SkipBytes;
|
---|
| 87 | e = handle->Message+handle->MessageSize;
|
---|
| 88 | handle->NeedBytes = handle->SkipBytes = 0;
|
---|
| 89 | while(e-m >= 3)
|
---|
| 90 | {
|
---|
| 91 | if(m[0] == 0xD3)
|
---|
| 92 | {
|
---|
| 93 | handle->size = ((m[1]&3)<<8)|m[2];
|
---|
| 94 | if(e-m >= handle->size+6)
|
---|
| 95 | {
|
---|
| 96 | if((uint32_t)((m[3+handle->size]<<16)|(m[3+handle->size+1]<<8)
|
---|
| 97 | |(m[3+handle->size+2])) == CRC24(handle->size+3, m))
|
---|
| 98 | {
|
---|
| 99 | handle->SkipBytes = handle->size;
|
---|
| 100 | break;
|
---|
| 101 | }
|
---|
| 102 | else
|
---|
| 103 | ++m;
|
---|
| 104 | }
|
---|
| 105 | else
|
---|
| 106 | {
|
---|
| 107 | handle->NeedBytes = handle->size+6;
|
---|
| 108 | break;
|
---|
| 109 | }
|
---|
| 110 | }
|
---|
| 111 | else
|
---|
| 112 | ++m;
|
---|
| 113 | }
|
---|
| 114 | if(e-m < 3)
|
---|
| 115 | handle->NeedBytes = 3;
|
---|
[744] | 116 |
|
---|
[27] | 117 | /* copy buffer to front */
|
---|
| 118 | i = m - handle->Message;
|
---|
| 119 | if(i && m < e)
|
---|
[318] | 120 | memmove(handle->Message, m, (size_t)(handle->MessageSize-i));
|
---|
[27] | 121 | handle->MessageSize -= i;
|
---|
| 122 |
|
---|
| 123 | return !handle->NeedBytes;
|
---|
| 124 | }
|
---|
| 125 |
|
---|
| 126 | #define LOADBITS(a) \
|
---|
| 127 | { \
|
---|
| 128 | while((a) > numbits) \
|
---|
| 129 | { \
|
---|
| 130 | if(!size--) break; \
|
---|
| 131 | bitfield = (bitfield<<8)|*(data++); \
|
---|
| 132 | numbits += 8; \
|
---|
| 133 | } \
|
---|
| 134 | }
|
---|
| 135 |
|
---|
| 136 | /* extract bits from data stream
|
---|
| 137 | b = variable to store result, a = number of bits */
|
---|
[2860] | 138 | #define GETBITS64(b, a) \
|
---|
| 139 | { \
|
---|
| 140 | if(((a) > 56) && ((a)-56) > numbits) \
|
---|
| 141 | { \
|
---|
| 142 | uint64_t x; \
|
---|
| 143 | GETBITS(x, 56) \
|
---|
| 144 | LOADBITS((a)-56) \
|
---|
| 145 | b = ((x<<((a)-56)) | (bitfield<<(sizeof(bitfield)*8-numbits)) \
|
---|
| 146 | >>(sizeof(bitfield)*8-((a)-56))); \
|
---|
| 147 | numbits -= ((a)-56); \
|
---|
| 148 | } \
|
---|
| 149 | else \
|
---|
| 150 | { \
|
---|
| 151 | GETBITS(b, a) \
|
---|
| 152 | } \
|
---|
| 153 | }
|
---|
| 154 |
|
---|
| 155 | /* extract bits from data stream
|
---|
| 156 | b = variable to store result, a = number of bits */
|
---|
[27] | 157 | #define GETBITS(b, a) \
|
---|
| 158 | { \
|
---|
| 159 | LOADBITS(a) \
|
---|
| 160 | b = (bitfield<<(64-numbits))>>(64-(a)); \
|
---|
| 161 | numbits -= (a); \
|
---|
| 162 | }
|
---|
| 163 |
|
---|
[2756] | 164 | /* extract bits from data stream
|
---|
| 165 | b = variable to store result, a = number of bits */
|
---|
| 166 | #define GETBITSFACTOR(b, a, c) \
|
---|
| 167 | { \
|
---|
| 168 | LOADBITS(a) \
|
---|
| 169 | b = ((bitfield<<(sizeof(bitfield)*8-numbits))>>(sizeof(bitfield)*8-(a)))*(c); \
|
---|
| 170 | numbits -= (a); \
|
---|
| 171 | }
|
---|
| 172 |
|
---|
[502] | 173 | /* extract floating value from data stream
|
---|
| 174 | b = variable to store result, a = number of bits */
|
---|
| 175 | #define GETFLOAT(b, a, c) \
|
---|
| 176 | { \
|
---|
| 177 | LOADBITS(a) \
|
---|
| 178 | b = ((double)((bitfield<<(64-numbits))>>(64-(a))))*(c); \
|
---|
| 179 | numbits -= (a); \
|
---|
| 180 | }
|
---|
| 181 |
|
---|
| 182 | /* extract signed floating value from data stream
|
---|
| 183 | b = variable to store result, a = number of bits */
|
---|
| 184 | #define GETFLOATSIGN(b, a, c) \
|
---|
| 185 | { \
|
---|
| 186 | LOADBITS(a) \
|
---|
| 187 | b = ((double)(((int64_t)(bitfield<<(64-numbits)))>>(64-(a))))*(c); \
|
---|
| 188 | numbits -= (a); \
|
---|
| 189 | }
|
---|
| 190 |
|
---|
[27] | 191 | /* extract bits from data stream
|
---|
| 192 | b = variable to store result, a = number of bits */
|
---|
| 193 | #define GETBITSSIGN(b, a) \
|
---|
| 194 | { \
|
---|
| 195 | LOADBITS(a) \
|
---|
| 196 | b = ((int64_t)(bitfield<<(64-numbits)))>>(64-(a)); \
|
---|
| 197 | numbits -= (a); \
|
---|
| 198 | }
|
---|
| 199 |
|
---|
[502] | 200 | #define GETFLOATSIGNM(b, a, c) \
|
---|
| 201 | { int l; \
|
---|
| 202 | LOADBITS(a) \
|
---|
| 203 | l = (bitfield<<(64-numbits))>>(64-1); \
|
---|
| 204 | b = ((double)(((bitfield<<(64-(numbits-1))))>>(64-(a-1))))*(c); \
|
---|
| 205 | numbits -= (a); \
|
---|
| 206 | if(l) b *= -1.0; \
|
---|
| 207 | }
|
---|
| 208 |
|
---|
[27] | 209 | #define SKIPBITS(b) { LOADBITS(b) numbits -= (b); }
|
---|
| 210 |
|
---|
[1237] | 211 | /* extract byte-aligned byte from data stream,
|
---|
| 212 | b = variable to store size, s = variable to store string pointer */
|
---|
| 213 | #define GETSTRING(b, s) \
|
---|
| 214 | { \
|
---|
| 215 | b = *(data++); \
|
---|
| 216 | s = (char *) data; \
|
---|
| 217 | data += b; \
|
---|
| 218 | size -= b+1; \
|
---|
| 219 | }
|
---|
| 220 |
|
---|
[270] | 221 | struct leapseconds { /* specify the day of leap second */
|
---|
| 222 | int day; /* this is the day, where 23:59:59 exists 2 times */
|
---|
| 223 | int month; /* not the next day! */
|
---|
| 224 | int year;
|
---|
| 225 | int taicount;
|
---|
[744] | 226 | };
|
---|
[270] | 227 | static const int months[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
|
---|
| 228 | static const struct leapseconds leap[] = {
|
---|
[4367] | 229 | /*{31, 12, 1971, 10},*/
|
---|
| 230 | /*{30, 06, 1972, 11},*/
|
---|
[270] | 231 | /*{31, 12, 1972, 12},*/
|
---|
| 232 | /*{31, 12, 1973, 13},*/
|
---|
| 233 | /*{31, 12, 1974, 14},*/
|
---|
| 234 | /*{31, 12, 1975, 15},*/
|
---|
| 235 | /*{31, 12, 1976, 16},*/
|
---|
| 236 | /*{31, 12, 1977, 17},*/
|
---|
| 237 | /*{31, 12, 1978, 18},*/
|
---|
| 238 | /*{31, 12, 1979, 19},*/
|
---|
| 239 | {30, 06, 1981,20},
|
---|
| 240 | {30, 06, 1982,21},
|
---|
| 241 | {30, 06, 1983,22},
|
---|
| 242 | {30, 06, 1985,23},
|
---|
| 243 | {31, 12, 1987,24},
|
---|
| 244 | {31, 12, 1989,25},
|
---|
| 245 | {31, 12, 1990,26},
|
---|
| 246 | {30, 06, 1992,27},
|
---|
| 247 | {30, 06, 1993,28},
|
---|
| 248 | {30, 06, 1994,29},
|
---|
| 249 | {31, 12, 1995,30},
|
---|
| 250 | {30, 06, 1997,31},
|
---|
| 251 | {31, 12, 1998,32},
|
---|
| 252 | {31, 12, 2005,33},
|
---|
[959] | 253 | {31, 12, 2008,34},
|
---|
[4365] | 254 | {30, 06, 2012,35},
|
---|
[270] | 255 | {0,0,0,0} /* end marker */
|
---|
| 256 | };
|
---|
[4370] | 257 | #define LEAPSECONDS 16 /* only needed for approx. time */
|
---|
[270] | 258 | #define GPSLEAPSTART 19 /* 19 leap seconds existed at 6.1.1980 */
|
---|
| 259 |
|
---|
| 260 | static int longyear(int year, int month)
|
---|
| 261 | {
|
---|
| 262 | if(!(year % 4) && (!(year % 400) || (year % 100)))
|
---|
| 263 | {
|
---|
| 264 | if(!month || month == 2)
|
---|
| 265 | return 1;
|
---|
| 266 | }
|
---|
| 267 | return 0;
|
---|
| 268 | }
|
---|
| 269 |
|
---|
[2346] | 270 | int gnumleap(int year, int month, int day)
|
---|
[270] | 271 | {
|
---|
| 272 | int ls = 0;
|
---|
| 273 | const struct leapseconds *l;
|
---|
| 274 |
|
---|
| 275 | for(l = leap; l->taicount && year >= l->year; ++l)
|
---|
| 276 | {
|
---|
[1824] | 277 | if(year > l->year || month > l->month || (month == l->month && day > l->day))
|
---|
[270] | 278 | ls = l->taicount - GPSLEAPSTART;
|
---|
| 279 | }
|
---|
| 280 | return ls;
|
---|
| 281 | }
|
---|
| 282 |
|
---|
[2346] | 283 | /* Convert Moscow time into UTC (fixnumleap == 1) or GPS (fixnumleap == 0) */
|
---|
| 284 | void updatetime(int *week, int *secOfWeek, int mSecOfWeek, int fixnumleap)
|
---|
[270] | 285 | {
|
---|
[502] | 286 | int y,m,d,k,l, nul;
|
---|
[2346] | 287 | unsigned int j = *week*(7*24*60*60) + *secOfWeek + 5*24*60*60+3*60*60;
|
---|
[270] | 288 | int glo_daynumber = 0, glo_timeofday;
|
---|
| 289 | for(y = 1980; j >= (unsigned int)(k = (l = (365+longyear(y,0)))*24*60*60)
|
---|
| 290 | + gnumleap(y+1,1,1); ++y)
|
---|
| 291 | {
|
---|
| 292 | j -= k; glo_daynumber += l;
|
---|
| 293 | }
|
---|
| 294 | for(m = 1; j >= (unsigned int)(k = (l = months[m]+longyear(y, m))*24*60*60)
|
---|
| 295 | + gnumleap(y, m+1, 1); ++m)
|
---|
| 296 | {
|
---|
| 297 | j -= k; glo_daynumber += l;
|
---|
| 298 | }
|
---|
| 299 | for(d = 1; j >= 24UL*60UL*60UL + gnumleap(y, m, d+1); ++d)
|
---|
| 300 | j -= 24*60*60;
|
---|
| 301 | glo_daynumber -= 16*365+4-d;
|
---|
[502] | 302 | nul = gnumleap(y, m, d);
|
---|
| 303 | glo_timeofday = j-nul;
|
---|
[270] | 304 |
|
---|
[3270] | 305 | // original version
|
---|
| 306 | // if(mSecOfWeek < 5*60*1000 && glo_timeofday > 23*60*60)
|
---|
| 307 | // *secOfWeek += 24*60*60;
|
---|
| 308 | // else if(glo_timeofday < 5*60 && mSecOfWeek > 23*60*60*1000)
|
---|
| 309 | // *secOfWeek -= 24*60*60;
|
---|
| 310 |
|
---|
| 311 | // new version
|
---|
| 312 | if(mSecOfWeek < 4*60*60*1000 && glo_timeofday > 20*60*60)
|
---|
[2346] | 313 | *secOfWeek += 24*60*60;
|
---|
[3270] | 314 | else if(glo_timeofday < 4*60*60 && mSecOfWeek > 20*60*60*1000)
|
---|
[2346] | 315 | *secOfWeek -= 24*60*60;
|
---|
[3270] | 316 |
|
---|
[2346] | 317 | *secOfWeek += mSecOfWeek/1000-glo_timeofday;
|
---|
[502] | 318 | if(fixnumleap)
|
---|
[2346] | 319 | *secOfWeek -= nul;
|
---|
| 320 | if(*secOfWeek < 0) {*secOfWeek += 24*60*60*7; --*week; }
|
---|
| 321 | if(*secOfWeek >= 24*60*60*7) {*secOfWeek -= 24*60*60*7; ++*week; }
|
---|
[270] | 322 | }
|
---|
| 323 |
|
---|
[268] | 324 | int RTCM3Parser(struct RTCM3ParserData *handle)
|
---|
[27] | 325 | {
|
---|
| 326 | int ret=0;
|
---|
| 327 |
|
---|
[1237] | 328 | #ifdef NO_RTCM3_MAIN
|
---|
| 329 | if(GetMessage(handle)) /* don't repeat */
|
---|
| 330 | #else
|
---|
[27] | 331 | while(!ret && GetMessage(handle))
|
---|
[1237] | 332 | #endif /* NO_RTCM3_MAIN */
|
---|
[27] | 333 | {
|
---|
| 334 | /* using 64 bit integer types, as it is much easier than handling
|
---|
| 335 | the long datatypes in 32 bit */
|
---|
| 336 | uint64_t numbits = 0, bitfield = 0;
|
---|
| 337 | int size = handle->size, type;
|
---|
[270] | 338 | int syncf, old = 0;
|
---|
[27] | 339 | unsigned char *data = handle->Message+3;
|
---|
| 340 |
|
---|
| 341 | GETBITS(type,12)
|
---|
[1097] | 342 | #ifdef NO_RTCM3_MAIN
|
---|
[1237] | 343 | handle->blocktype = type;
|
---|
[1092] | 344 | #endif /* NO_RTCM3_MAIN */
|
---|
[27] | 345 | switch(type)
|
---|
| 346 | {
|
---|
[1237] | 347 | #ifdef NO_RTCM3_MAIN
|
---|
| 348 | default:
|
---|
| 349 | ret = type;
|
---|
| 350 | break;
|
---|
| 351 | case 1005: case 1006:
|
---|
| 352 | {
|
---|
| 353 | SKIPBITS(22)
|
---|
| 354 | GETBITSSIGN(handle->antX, 38)
|
---|
| 355 | SKIPBITS(2)
|
---|
| 356 | GETBITSSIGN(handle->antY, 38)
|
---|
| 357 | SKIPBITS(2)
|
---|
| 358 | GETBITSSIGN(handle->antZ, 38)
|
---|
| 359 | if(type == 1006)
|
---|
| 360 | GETBITS(handle->antH, 16)
|
---|
| 361 | ret = type;
|
---|
| 362 | }
|
---|
| 363 | break;
|
---|
| 364 | case 1007: case 1008: case 1033:
|
---|
| 365 | {
|
---|
| 366 | char *antenna;
|
---|
| 367 | int antnum;
|
---|
| 368 |
|
---|
| 369 | SKIPBITS(12)
|
---|
| 370 | GETSTRING(antnum,antenna)
|
---|
| 371 | memcpy(handle->antenna, antenna, antnum);
|
---|
| 372 | handle->antenna[antnum] = 0;
|
---|
| 373 | ret = type;
|
---|
| 374 | }
|
---|
| 375 | break;
|
---|
[2501] | 376 | case 1013:
|
---|
| 377 | {
|
---|
| 378 | SKIPBITS(12);
|
---|
| 379 | GETBITS(handle->modjulday, 16);
|
---|
| 380 | GETBITS(handle->secofday, 17);
|
---|
| 381 | SKIPBITS(5);
|
---|
| 382 | GETBITS(handle->leapsec, 8);
|
---|
| 383 | ret = 1013;
|
---|
| 384 | }
|
---|
| 385 | break;
|
---|
[1237] | 386 | #endif /* NO_RTCM3_MAIN */
|
---|
[502] | 387 | case 1019:
|
---|
| 388 | {
|
---|
| 389 | struct gpsephemeris *ge;
|
---|
[2764] | 390 | int sv, i;
|
---|
[502] | 391 |
|
---|
| 392 | ge = &handle->ephemerisGPS;
|
---|
| 393 | memset(ge, 0, sizeof(*ge));
|
---|
| 394 |
|
---|
| 395 | GETBITS(sv, 6)
|
---|
| 396 | ge->satellite = (sv < 40 ? sv : sv+80);
|
---|
| 397 | GETBITS(ge->GPSweek, 10)
|
---|
| 398 | ge->GPSweek += 1024;
|
---|
| 399 | GETBITS(ge->URAindex, 4)
|
---|
| 400 | GETBITS(sv, 2)
|
---|
| 401 | if(sv & 1)
|
---|
| 402 | ge->flags |= GPSEPHF_L2PCODE;
|
---|
| 403 | if(sv & 2)
|
---|
| 404 | ge->flags |= GPSEPHF_L2CACODE;
|
---|
[1092] | 405 | GETFLOATSIGN(ge->IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[502] | 406 | GETBITS(ge->IODE, 8)
|
---|
| 407 | GETBITS(ge->TOC, 16)
|
---|
| 408 | ge->TOC <<= 4;
|
---|
| 409 | GETFLOATSIGN(ge->clock_driftrate, 8, 1.0/(double)(1<<30)/(double)(1<<25))
|
---|
| 410 | GETFLOATSIGN(ge->clock_drift, 16, 1.0/(double)(1<<30)/(double)(1<<13))
|
---|
| 411 | GETFLOATSIGN(ge->clock_bias, 22, 1.0/(double)(1<<30)/(double)(1<<1))
|
---|
| 412 | GETBITS(ge->IODC, 10)
|
---|
| 413 | GETFLOATSIGN(ge->Crs, 16, 1.0/(double)(1<<5))
|
---|
[1092] | 414 | GETFLOATSIGN(ge->Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 415 | GETFLOATSIGN(ge->M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[502] | 416 | GETFLOATSIGN(ge->Cuc, 16, 1.0/(double)(1<<29))
|
---|
| 417 | GETFLOAT(ge->e, 32, 1.0/(double)(1<<30)/(double)(1<<3))
|
---|
| 418 | GETFLOATSIGN(ge->Cus, 16, 1.0/(double)(1<<29))
|
---|
| 419 | GETFLOAT(ge->sqrt_A, 32, 1.0/(double)(1<<19))
|
---|
| 420 | GETBITS(ge->TOE, 16)
|
---|
| 421 | ge->TOE <<= 4;
|
---|
| 422 |
|
---|
| 423 | GETFLOATSIGN(ge->Cic, 16, 1.0/(double)(1<<29))
|
---|
[1092] | 424 | GETFLOATSIGN(ge->OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[502] | 425 | GETFLOATSIGN(ge->Cis, 16, 1.0/(double)(1<<29))
|
---|
[1092] | 426 | GETFLOATSIGN(ge->i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
[502] | 427 | GETFLOATSIGN(ge->Crc, 16, 1.0/(double)(1<<5))
|
---|
[1092] | 428 | GETFLOATSIGN(ge->omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 429 | GETFLOATSIGN(ge->OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
[502] | 430 | GETFLOATSIGN(ge->TGD, 8, 1.0/(double)(1<<30)/(double)(1<<1))
|
---|
| 431 | GETBITS(ge->SVhealth, 6)
|
---|
| 432 | GETBITS(sv, 1)
|
---|
| 433 | if(sv)
|
---|
| 434 | ge->flags |= GPSEPHF_L2PCODEDATA;
|
---|
| 435 |
|
---|
[2764] | 436 | i = ((int)ge->GPSweek - (int)handle->GPSWeek)*7*24*60*60
|
---|
| 437 | + ((int)ge->TOE - (int)handle->GPSTOW) - 2*60*60;
|
---|
| 438 | if(i > 5*60*60 && i < 8*60*60)
|
---|
| 439 | {
|
---|
| 440 | handle->GPSTOW = ge->TOE;
|
---|
| 441 | handle->GPSWeek = ge->GPSweek;
|
---|
| 442 | }
|
---|
[2994] | 443 | ge->TOW = 0.9999E9;
|
---|
[502] | 444 | ret = 1019;
|
---|
| 445 | }
|
---|
| 446 | break;
|
---|
[2756] | 447 | case 1045:
|
---|
| 448 | {
|
---|
| 449 | struct galileoephemeris *ge;
|
---|
| 450 | int sv;
|
---|
| 451 |
|
---|
| 452 | ge = &handle->ephemerisGALILEO;
|
---|
| 453 | memset(ge, 0, sizeof(*ge));
|
---|
| 454 |
|
---|
| 455 | GETBITS(sv, 6)
|
---|
| 456 | ge->satellite = sv;
|
---|
| 457 | GETBITS(ge->Week, 12)
|
---|
| 458 | GETBITS(ge->IODnav, 10)
|
---|
| 459 | GETBITS(ge->SISA, 8)
|
---|
| 460 | GETFLOATSIGN(ge->IDOT, 14, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 461 | GETBITSFACTOR(ge->TOC, 14, 60)
|
---|
| 462 | GETFLOATSIGN(ge->clock_driftrate, 6, 1.0/(double)(1<<30)/(double)(1<<29))
|
---|
| 463 | GETFLOATSIGN(ge->clock_drift, 21, 1.0/(double)(1<<30)/(double)(1<<16))
|
---|
| 464 | GETFLOATSIGN(ge->clock_bias, 31, 1.0/(double)(1<<30)/(double)(1<<4))
|
---|
| 465 | GETFLOATSIGN(ge->Crs, 16, 1.0/(double)(1<<5))
|
---|
| 466 | GETFLOATSIGN(ge->Delta_n, 16, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 467 | GETFLOATSIGN(ge->M0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 468 | GETFLOATSIGN(ge->Cuc, 16, 1.0/(double)(1<<29))
|
---|
| 469 | GETFLOAT(ge->e, 32, 1.0/(double)(1<<30)/(double)(1<<3))
|
---|
| 470 | GETFLOATSIGN(ge->Cus, 16, 1.0/(double)(1<<29))
|
---|
| 471 | GETFLOAT(ge->sqrt_A, 32, 1.0/(double)(1<<19))
|
---|
| 472 | GETBITSFACTOR(ge->TOE, 14, 60)
|
---|
| 473 | GETFLOATSIGN(ge->Cic, 16, 1.0/(double)(1<<29))
|
---|
| 474 | GETFLOATSIGN(ge->OMEGA0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 475 | GETFLOATSIGN(ge->Cis, 16, 1.0/(double)(1<<29))
|
---|
| 476 | GETFLOATSIGN(ge->i0, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 477 | GETFLOATSIGN(ge->Crc, 16, 1.0/(double)(1<<5))
|
---|
| 478 | GETFLOATSIGN(ge->omega, 32, R2R_PI/(double)(1<<30)/(double)(1<<1))
|
---|
| 479 | GETFLOATSIGN(ge->OMEGADOT, 24, R2R_PI/(double)(1<<30)/(double)(1<<13))
|
---|
| 480 | GETFLOATSIGN(ge->BGD_1_5A, 10, 1.0/(double)(1<<30)/(double)(1<<2))
|
---|
[2845] | 481 | GETFLOATSIGN(ge->BGD_1_5B, 10, 1.0/(double)(1<<30)/(double)(1<<2))
|
---|
[2756] | 482 | GETBITS(ge->E5aHS, 2)
|
---|
| 483 | GETBITS(sv, 1)
|
---|
| 484 | if(sv)
|
---|
| 485 | ge->flags |= GALEPHF_E5ADINVALID;
|
---|
| 486 | ret = 1045;
|
---|
| 487 | }
|
---|
| 488 | break;
|
---|
[502] | 489 | case 1020:
|
---|
| 490 | {
|
---|
| 491 | struct glonassephemeris *ge;
|
---|
| 492 | int i;
|
---|
| 493 |
|
---|
| 494 | ge = &handle->ephemerisGLONASS;
|
---|
| 495 | memset(ge, 0, sizeof(*ge));
|
---|
| 496 |
|
---|
| 497 | ge->flags |= GLOEPHF_PAVAILABLE;
|
---|
| 498 | GETBITS(ge->almanac_number, 6)
|
---|
| 499 | GETBITS(i, 5)
|
---|
| 500 | ge->frequency_number = i-7;
|
---|
[2659] | 501 | if(ge->almanac_number >= 1 && ge->almanac_number <= PRN_GLONASS_NUM)
|
---|
| 502 | handle->GLOFreq[ge->almanac_number-1] = 100+ge->frequency_number;
|
---|
[502] | 503 | GETBITS(i, 1)
|
---|
| 504 | if(i)
|
---|
| 505 | ge->flags |= GLOEPHF_ALMANACHEALTHY;
|
---|
| 506 | GETBITS(i, 1)
|
---|
| 507 | if(i)
|
---|
| 508 | ge->flags |= GLOEPHF_ALMANACHEALTHOK;
|
---|
| 509 | GETBITS(i, 2)
|
---|
| 510 | if(i & 1)
|
---|
| 511 | ge->flags |= GLOEPHF_P10TRUE;
|
---|
| 512 | if(i & 2)
|
---|
| 513 | ge->flags |= GLOEPHF_P11TRUE;
|
---|
| 514 | GETBITS(i, 5)
|
---|
| 515 | ge->tk = i*60*60;
|
---|
| 516 | GETBITS(i, 6)
|
---|
| 517 | ge->tk += i*60;
|
---|
| 518 | GETBITS(i, 1)
|
---|
| 519 | ge->tk += i*30;
|
---|
| 520 | GETBITS(i, 1)
|
---|
| 521 | if(i)
|
---|
| 522 | ge->flags |= GLOEPHF_UNHEALTHY;
|
---|
| 523 | GETBITS(i, 1)
|
---|
| 524 | if(i)
|
---|
| 525 | ge->flags |= GLOEPHF_P2TRUE;
|
---|
| 526 | GETBITS(i, 7)
|
---|
| 527 | ge->tb = i*15*60;
|
---|
| 528 | GETFLOATSIGNM(ge->x_velocity, 24, 1.0/(double)(1<<20))
|
---|
| 529 | GETFLOATSIGNM(ge->x_pos, 27, 1.0/(double)(1<<11))
|
---|
| 530 | GETFLOATSIGNM(ge->x_acceleration, 5, 1.0/(double)(1<<30))
|
---|
| 531 | GETFLOATSIGNM(ge->y_velocity, 24, 1.0/(double)(1<<20))
|
---|
| 532 | GETFLOATSIGNM(ge->y_pos, 27, 1.0/(double)(1<<11))
|
---|
| 533 | GETFLOATSIGNM(ge->y_acceleration, 5, 1.0/(double)(1<<30))
|
---|
| 534 | GETFLOATSIGNM(ge->z_velocity, 24, 1.0/(double)(1<<20))
|
---|
| 535 | GETFLOATSIGNM(ge->z_pos, 27, 1.0/(double)(1<<11))
|
---|
| 536 | GETFLOATSIGNM(ge->z_acceleration, 5, 1.0/(double)(1<<30))
|
---|
| 537 | GETBITS(i, 1)
|
---|
| 538 | if(i)
|
---|
| 539 | ge->flags |= GLOEPHF_P3TRUE;
|
---|
| 540 | GETFLOATSIGNM(ge->gamma, 11, 1.0/(double)(1<<30)/(double)(1<<10))
|
---|
| 541 | SKIPBITS(3) /* GLONASS-M P, GLONASS-M ln (third string) */
|
---|
| 542 | GETFLOATSIGNM(ge->tau, 22, 1.0/(double)(1<<30)) /* GLONASS tau n(tb) */
|
---|
| 543 | SKIPBITS(5) /* GLONASS-M delta tau n(tb) */
|
---|
| 544 | GETBITS(ge->E, 5)
|
---|
| 545 | /* GETBITS(b, 1) / * GLONASS-M P4 */
|
---|
| 546 | /* GETBITS(b, 4) / * GLONASS-M Ft */
|
---|
| 547 | /* GETBITS(b, 11) / * GLONASS-M Nt */
|
---|
| 548 | /* GETBITS(b, 2) / * GLONASS-M M */
|
---|
| 549 | /* GETBITS(b, 1) / * GLONASS-M The Availability of Additional Data */
|
---|
| 550 | /* GETBITS(b, 11) / * GLONASS-M Na */
|
---|
| 551 | /* GETFLOATSIGNM(b, 32, 1.0/(double)(1<<30)/(double)(1<<1)) / * GLONASS tau c */
|
---|
| 552 | /* GETBITS(b, 5) / * GLONASS-M N4 */
|
---|
| 553 | /* GETFLOATSIGNM(b, 22, 1.0/(double)(1<<30)/(double)(1<<1)) / * GLONASS-M tau GPS */
|
---|
| 554 | /* GETBITS(b, 1) / * GLONASS-M ln (fifth string) */
|
---|
| 555 | ge->GPSWeek = handle->GPSWeek;
|
---|
| 556 | ge->GPSTOW = handle->GPSTOW;
|
---|
| 557 | ret = 1020;
|
---|
| 558 | }
|
---|
| 559 | break;
|
---|
[33] | 560 | case 1001: case 1002: case 1003: case 1004:
|
---|
[27] | 561 | if(handle->GPSWeek)
|
---|
| 562 | {
|
---|
| 563 | int lastlockl1[64];
|
---|
| 564 | int lastlockl2[64];
|
---|
| 565 | struct gnssdata *gnss;
|
---|
[1270] | 566 | int i, numsats, wasamb=0;
|
---|
[27] | 567 |
|
---|
| 568 | for(i = 0; i < 64; ++i)
|
---|
| 569 | lastlockl1[i] = lastlockl2[i] = 0;
|
---|
| 570 |
|
---|
[270] | 571 | gnss = &handle->DataNew;
|
---|
[27] | 572 |
|
---|
| 573 | SKIPBITS(12) /* id */
|
---|
| 574 | GETBITS(i,30)
|
---|
| 575 | if(i/1000 < (int)handle->GPSTOW - 86400)
|
---|
| 576 | ++handle->GPSWeek;
|
---|
| 577 | handle->GPSTOW = i/1000;
|
---|
[270] | 578 | if(gnss->week && (gnss->timeofweek != i || gnss->week
|
---|
| 579 | != handle->GPSWeek))
|
---|
| 580 | {
|
---|
| 581 | handle->Data = *gnss;
|
---|
| 582 | memset(gnss, 0, sizeof(*gnss));
|
---|
| 583 | old = 1;
|
---|
| 584 | }
|
---|
[27] | 585 | gnss->timeofweek = i;
|
---|
| 586 | gnss->week = handle->GPSWeek;
|
---|
| 587 |
|
---|
[270] | 588 | GETBITS(syncf,1) /* sync */
|
---|
[1270] | 589 | GETBITS(numsats,5)
|
---|
[27] | 590 | SKIPBITS(4) /* smind, smint */
|
---|
| 591 |
|
---|
[2352] | 592 | while(numsats-- && gnss->numsats < GNSS_MAXSATS)
|
---|
[27] | 593 | {
|
---|
[33] | 594 | int sv, code, l1range, c,l,s,ce,le,se,amb=0;
|
---|
[1270] | 595 | int fullsat, num;
|
---|
[27] | 596 |
|
---|
[1270] | 597 | GETBITS(sv, 6)
|
---|
| 598 | fullsat = sv < 40 ? sv : sv+80;
|
---|
| 599 | for(num = 0; num < gnss->numsats
|
---|
| 600 | && fullsat != gnss->satellites[num]; ++num)
|
---|
| 601 | ;
|
---|
| 602 |
|
---|
| 603 | if(num == gnss->numsats)
|
---|
| 604 | gnss->satellites[gnss->numsats++] = fullsat;
|
---|
| 605 |
|
---|
[27] | 606 | /* L1 */
|
---|
| 607 | GETBITS(code, 1);
|
---|
| 608 | if(code)
|
---|
| 609 | {
|
---|
| 610 | c = GNSSDF_P1DATA; ce = GNSSENTRY_P1DATA;
|
---|
| 611 | l = GNSSDF_L1PDATA; le = GNSSENTRY_L1PDATA;
|
---|
| 612 | s = GNSSDF_S1PDATA; se = GNSSENTRY_S1PDATA;
|
---|
[4430] | 613 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "1 ";
|
---|
[27] | 614 | }
|
---|
| 615 | else
|
---|
| 616 | {
|
---|
| 617 | c = GNSSDF_C1DATA; ce = GNSSENTRY_C1DATA;
|
---|
| 618 | l = GNSSDF_L1CDATA; le = GNSSENTRY_L1CDATA;
|
---|
| 619 | s = GNSSDF_S1CDATA; se = GNSSENTRY_S1CDATA;
|
---|
[4430] | 620 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "1C";
|
---|
[27] | 621 | }
|
---|
| 622 | GETBITS(l1range, 24);
|
---|
| 623 | GETBITSSIGN(i, 20);
|
---|
[325] | 624 | if((i&((1<<20)-1)) != 0x80000)
|
---|
[27] | 625 | {
|
---|
[744] | 626 | gnss->dataflags[num] |= (c|l);
|
---|
| 627 | gnss->measdata[num][ce] = l1range*0.02;
|
---|
[27] | 628 | gnss->measdata[num][le] = l1range*0.02+i*0.0005;
|
---|
| 629 | }
|
---|
| 630 | GETBITS(i, 7);
|
---|
| 631 | lastlockl1[sv] = i;
|
---|
[2500] | 632 | if(handle->lastlockGPSl1[sv] > i || i == 0)
|
---|
[2659] | 633 | gnss->dataflags2[num] |= GNSSDF2_LOCKLOSSL1;
|
---|
[33] | 634 | if(type == 1002 || type == 1004)
|
---|
[27] | 635 | {
|
---|
[33] | 636 | GETBITS(amb,8);
|
---|
| 637 | if(amb && (gnss->dataflags[num] & c))
|
---|
| 638 | {
|
---|
| 639 | gnss->measdata[num][ce] += amb*299792.458;
|
---|
| 640 | gnss->measdata[num][le] += amb*299792.458;
|
---|
| 641 | ++wasamb;
|
---|
| 642 | }
|
---|
| 643 | GETBITS(i, 8);
|
---|
| 644 | if(i)
|
---|
| 645 | {
|
---|
| 646 | gnss->dataflags[num] |= s;
|
---|
| 647 | gnss->measdata[num][se] = i*0.25;
|
---|
| 648 | i /= 4*4;
|
---|
| 649 | if(i > 9) i = 9;
|
---|
| 650 | else if(i < 1) i = 1;
|
---|
| 651 | gnss->snrL1[num] = i;
|
---|
| 652 | }
|
---|
[27] | 653 | }
|
---|
[81] | 654 | gnss->measdata[num][le] /= GPS_WAVELENGTH_L1;
|
---|
[33] | 655 | if(type == 1003 || type == 1004)
|
---|
[27] | 656 | {
|
---|
[33] | 657 | /* L2 */
|
---|
| 658 | GETBITS(code,2);
|
---|
| 659 | if(code)
|
---|
| 660 | {
|
---|
| 661 | c = GNSSDF_P2DATA; ce = GNSSENTRY_P2DATA;
|
---|
| 662 | l = GNSSDF_L2PDATA; le = GNSSENTRY_L2PDATA;
|
---|
| 663 | s = GNSSDF_S2PDATA; se = GNSSENTRY_S2PDATA;
|
---|
[2422] | 664 | if(code >= 2)
|
---|
[4430] | 665 | {
|
---|
| 666 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "2W";
|
---|
[2659] | 667 | gnss->dataflags2[num] |= GNSSDF2_XCORRL2;
|
---|
[4430] | 668 | }
|
---|
| 669 | else
|
---|
| 670 | {
|
---|
| 671 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "2P";
|
---|
| 672 | }
|
---|
[33] | 673 | }
|
---|
| 674 | else
|
---|
| 675 | {
|
---|
| 676 | c = GNSSDF_C2DATA; ce = GNSSENTRY_C2DATA;
|
---|
| 677 | l = GNSSDF_L2CDATA; le = GNSSENTRY_L2CDATA;
|
---|
| 678 | s = GNSSDF_S2CDATA; se = GNSSENTRY_S2CDATA;
|
---|
[4430] | 679 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "2 ";
|
---|
[33] | 680 | }
|
---|
| 681 | GETBITSSIGN(i,14);
|
---|
[325] | 682 | if((i&((1<<14)-1)) != 0x2000)
|
---|
[33] | 683 | {
|
---|
| 684 | gnss->dataflags[num] |= c;
|
---|
| 685 | gnss->measdata[num][ce] = l1range*0.02+i*0.02
|
---|
| 686 | +amb*299792.458;
|
---|
| 687 | }
|
---|
| 688 | GETBITSSIGN(i,20);
|
---|
[325] | 689 | if((i&((1<<20)-1)) != 0x80000)
|
---|
[33] | 690 | {
|
---|
| 691 | gnss->dataflags[num] |= l;
|
---|
| 692 | gnss->measdata[num][le] = l1range*0.02+i*0.0005
|
---|
| 693 | +amb*299792.458;
|
---|
| 694 | }
|
---|
| 695 | GETBITS(i,7);
|
---|
| 696 | lastlockl2[sv] = i;
|
---|
[2500] | 697 | if(handle->lastlockGPSl2[sv] > i || i == 0)
|
---|
[2659] | 698 | gnss->dataflags2[num] |= GNSSDF2_LOCKLOSSL2;
|
---|
[33] | 699 | if(type == 1004)
|
---|
| 700 | {
|
---|
| 701 | GETBITS(i, 8);
|
---|
| 702 | if(i)
|
---|
| 703 | {
|
---|
| 704 | gnss->dataflags[num] |= s;
|
---|
| 705 | gnss->measdata[num][se] = i*0.25;
|
---|
| 706 | i /= 4*4;
|
---|
| 707 | if(i > 9) i = 9;
|
---|
| 708 | else if(i < 1) i = 1;
|
---|
| 709 | gnss->snrL2[num] = i;
|
---|
| 710 | }
|
---|
| 711 | }
|
---|
[81] | 712 | gnss->measdata[num][le] /= GPS_WAVELENGTH_L2;
|
---|
[27] | 713 | }
|
---|
| 714 | }
|
---|
| 715 | for(i = 0; i < 64; ++i)
|
---|
| 716 | {
|
---|
[2490] | 717 | handle->lastlockGPSl1[i] = lastlockl1[i];
|
---|
| 718 | handle->lastlockGPSl2[i] = lastlockl2[i];
|
---|
[27] | 719 | }
|
---|
[270] | 720 | if(!syncf && !old)
|
---|
| 721 | {
|
---|
| 722 | handle->Data = *gnss;
|
---|
| 723 | memset(gnss, 0, sizeof(*gnss));
|
---|
| 724 | }
|
---|
| 725 | if(!syncf || old)
|
---|
| 726 | {
|
---|
| 727 | if(wasamb) /* not RINEX compatible without */
|
---|
| 728 | ret = 1;
|
---|
| 729 | else
|
---|
| 730 | ret = 2;
|
---|
| 731 | }
|
---|
[1265] | 732 | #ifdef NO_RTCM3_MAIN
|
---|
| 733 | else
|
---|
| 734 | ret = type;
|
---|
| 735 | #endif /* NO_RTCM3_MAIN */
|
---|
[27] | 736 | }
|
---|
| 737 | break;
|
---|
[270] | 738 | case 1009: case 1010: case 1011: case 1012:
|
---|
| 739 | {
|
---|
| 740 | int lastlockl1[64];
|
---|
| 741 | int lastlockl2[64];
|
---|
| 742 | struct gnssdata *gnss;
|
---|
[1270] | 743 | int i, numsats;
|
---|
[270] | 744 | int wasamb=0;
|
---|
| 745 |
|
---|
| 746 | for(i = 0; i < 64; ++i)
|
---|
| 747 | lastlockl1[i] = lastlockl2[i] = 0;
|
---|
| 748 |
|
---|
| 749 | gnss = &handle->DataNew;
|
---|
| 750 |
|
---|
| 751 | SKIPBITS(12) /* id */;
|
---|
| 752 | GETBITS(i,27) /* tk */
|
---|
| 753 |
|
---|
[2346] | 754 | updatetime(&handle->GPSWeek, &handle->GPSTOW, i, 0); /* Moscow -> GPS */
|
---|
[270] | 755 | i = handle->GPSTOW*1000;
|
---|
| 756 | if(gnss->week && (gnss->timeofweek != i || gnss->week
|
---|
| 757 | != handle->GPSWeek))
|
---|
| 758 | {
|
---|
| 759 | handle->Data = *gnss;
|
---|
| 760 | memset(gnss, 0, sizeof(*gnss));
|
---|
| 761 | old = 1;
|
---|
| 762 | }
|
---|
| 763 |
|
---|
| 764 | gnss->timeofweek = i;
|
---|
| 765 | gnss->week = handle->GPSWeek;
|
---|
| 766 |
|
---|
| 767 | GETBITS(syncf,1) /* sync */
|
---|
[1270] | 768 | GETBITS(numsats,5)
|
---|
[270] | 769 |
|
---|
| 770 | SKIPBITS(4) /* smind, smint */
|
---|
| 771 |
|
---|
[2352] | 772 | while(numsats-- && gnss->numsats < GNSS_MAXSATS)
|
---|
[270] | 773 | {
|
---|
| 774 | int sv, code, l1range, c,l,s,ce,le,se,amb=0;
|
---|
[325] | 775 | int freq;
|
---|
[1270] | 776 | int fullsat, num;
|
---|
[270] | 777 |
|
---|
| 778 | GETBITS(sv, 6)
|
---|
[1270] | 779 | fullsat = sv-1 + PRN_GLONASS_START;
|
---|
| 780 | for(num = 0; num < gnss->numsats
|
---|
| 781 | && fullsat != gnss->satellites[num]; ++num)
|
---|
| 782 | ;
|
---|
| 783 |
|
---|
| 784 | if(num == gnss->numsats)
|
---|
| 785 | gnss->satellites[gnss->numsats++] = fullsat;
|
---|
| 786 |
|
---|
[325] | 787 | /* L1 */
|
---|
| 788 | GETBITS(code, 1)
|
---|
| 789 | GETBITS(freq, 5)
|
---|
[2346] | 790 |
|
---|
[2660] | 791 | if(sv >= 1 && sv <= PRN_GLONASS_NUM)
|
---|
| 792 | handle->GLOFreq[sv-1] = 100+freq-7;
|
---|
[2346] | 793 |
|
---|
[325] | 794 | if(code)
|
---|
[270] | 795 | {
|
---|
[325] | 796 | c = GNSSDF_P1DATA; ce = GNSSENTRY_P1DATA;
|
---|
| 797 | l = GNSSDF_L1PDATA; le = GNSSENTRY_L1PDATA;
|
---|
| 798 | s = GNSSDF_S1PDATA; se = GNSSENTRY_S1PDATA;
|
---|
[4430] | 799 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "1P";
|
---|
[270] | 800 | }
|
---|
| 801 | else
|
---|
| 802 | {
|
---|
[325] | 803 | c = GNSSDF_C1DATA; ce = GNSSENTRY_C1DATA;
|
---|
| 804 | l = GNSSDF_L1CDATA; le = GNSSENTRY_L1CDATA;
|
---|
| 805 | s = GNSSDF_S1CDATA; se = GNSSENTRY_S1CDATA;
|
---|
[4430] | 806 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "1C";
|
---|
[325] | 807 | }
|
---|
| 808 | GETBITS(l1range, 25)
|
---|
| 809 | GETBITSSIGN(i, 20)
|
---|
| 810 | if((i&((1<<20)-1)) != 0x80000)
|
---|
| 811 | {
|
---|
[744] | 812 | /* Handle this like GPS. Actually for GLONASS L1 range is always
|
---|
| 813 | valid. To be on the save side, we handle it as invalid like we
|
---|
| 814 | do for GPS and also remove range in case of 0x80000. */
|
---|
| 815 | gnss->dataflags[num] |= (c|l);
|
---|
| 816 | gnss->measdata[num][ce] = l1range*0.02;
|
---|
[325] | 817 | gnss->measdata[num][le] = l1range*0.02+i*0.0005;
|
---|
| 818 | }
|
---|
| 819 | GETBITS(i, 7)
|
---|
| 820 | lastlockl1[sv] = i;
|
---|
[2500] | 821 | if(handle->lastlockGLOl1[sv] > i || i == 0)
|
---|
[2659] | 822 | gnss->dataflags2[num] |= GNSSDF2_LOCKLOSSL1;
|
---|
[325] | 823 | if(type == 1010 || type == 1012)
|
---|
| 824 | {
|
---|
| 825 | GETBITS(amb,7)
|
---|
| 826 | if(amb && (gnss->dataflags[num] & c))
|
---|
| 827 | {
|
---|
| 828 | gnss->measdata[num][ce] += amb*599584.916;
|
---|
| 829 | gnss->measdata[num][le] += amb*599584.916;
|
---|
| 830 | ++wasamb;
|
---|
| 831 | }
|
---|
| 832 | GETBITS(i, 8)
|
---|
| 833 | if(i)
|
---|
| 834 | {
|
---|
| 835 | gnss->dataflags[num] |= s;
|
---|
| 836 | gnss->measdata[num][se] = i*0.25;
|
---|
| 837 | i /= 4*4;
|
---|
| 838 | if(i > 9) i = 9;
|
---|
| 839 | else if(i < 1) i = 1;
|
---|
| 840 | gnss->snrL1[num] = i;
|
---|
| 841 | }
|
---|
| 842 | }
|
---|
| 843 | gnss->measdata[num][le] /= GLO_WAVELENGTH_L1(freq-7);
|
---|
| 844 | if(type == 1011 || type == 1012)
|
---|
| 845 | {
|
---|
| 846 | /* L2 */
|
---|
| 847 | GETBITS(code,2)
|
---|
[270] | 848 | if(code)
|
---|
| 849 | {
|
---|
[325] | 850 | c = GNSSDF_P2DATA; ce = GNSSENTRY_P2DATA;
|
---|
| 851 | l = GNSSDF_L2PDATA; le = GNSSENTRY_L2PDATA;
|
---|
| 852 | s = GNSSDF_S2PDATA; se = GNSSENTRY_S2PDATA;
|
---|
[4430] | 853 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "2P";
|
---|
[270] | 854 | }
|
---|
| 855 | else
|
---|
| 856 | {
|
---|
[325] | 857 | c = GNSSDF_C2DATA; ce = GNSSENTRY_C2DATA;
|
---|
| 858 | l = GNSSDF_L2CDATA; le = GNSSENTRY_L2CDATA;
|
---|
| 859 | s = GNSSDF_S2CDATA; se = GNSSENTRY_S2CDATA;
|
---|
[4430] | 860 | gnss->codetype[num][ce] = gnss->codetype[num][le] = "2C";
|
---|
[270] | 861 | }
|
---|
[325] | 862 | GETBITSSIGN(i,14)
|
---|
| 863 | if((i&((1<<14)-1)) != 0x2000)
|
---|
[270] | 864 | {
|
---|
| 865 | gnss->dataflags[num] |= c;
|
---|
[325] | 866 | gnss->measdata[num][ce] = l1range*0.02+i*0.02
|
---|
| 867 | +amb*599584.916;
|
---|
[270] | 868 | }
|
---|
[325] | 869 | GETBITSSIGN(i,20)
|
---|
| 870 | if((i&((1<<20)-1)) != 0x80000)
|
---|
[270] | 871 | {
|
---|
| 872 | gnss->dataflags[num] |= l;
|
---|
[325] | 873 | gnss->measdata[num][le] = l1range*0.02+i*0.0005
|
---|
[949] | 874 | +amb*599584.916;
|
---|
[270] | 875 | }
|
---|
[325] | 876 | GETBITS(i,7)
|
---|
| 877 | lastlockl2[sv] = i;
|
---|
[2500] | 878 | if(handle->lastlockGLOl2[sv] > i || i == 0)
|
---|
[2659] | 879 | gnss->dataflags2[num] |= GNSSDF2_LOCKLOSSL2;
|
---|
[325] | 880 | if(type == 1012)
|
---|
[270] | 881 | {
|
---|
| 882 | GETBITS(i, 8)
|
---|
| 883 | if(i)
|
---|
| 884 | {
|
---|
| 885 | gnss->dataflags[num] |= s;
|
---|
| 886 | gnss->measdata[num][se] = i*0.25;
|
---|
| 887 | i /= 4*4;
|
---|
| 888 | if(i > 9) i = 9;
|
---|
| 889 | else if(i < 1) i = 1;
|
---|
[325] | 890 | gnss->snrL2[num] = i;
|
---|
[270] | 891 | }
|
---|
| 892 | }
|
---|
[325] | 893 | gnss->measdata[num][le] /= GLO_WAVELENGTH_L2(freq-7);
|
---|
[270] | 894 | }
|
---|
[1270] | 895 | if(!sv || sv > 24) /* illegal, remove it again */
|
---|
| 896 | --gnss->numsats;
|
---|
[270] | 897 | }
|
---|
| 898 | for(i = 0; i < 64; ++i)
|
---|
| 899 | {
|
---|
[2490] | 900 | handle->lastlockGLOl1[i] = lastlockl1[i];
|
---|
| 901 | handle->lastlockGLOl2[i] = lastlockl2[i];
|
---|
[270] | 902 | }
|
---|
| 903 | if(!syncf && !old)
|
---|
| 904 | {
|
---|
| 905 | handle->Data = *gnss;
|
---|
| 906 | memset(gnss, 0, sizeof(*gnss));
|
---|
| 907 | }
|
---|
| 908 | if(!syncf || old)
|
---|
| 909 | {
|
---|
| 910 | if(wasamb) /* not RINEX compatible without */
|
---|
| 911 | ret = 1;
|
---|
| 912 | else
|
---|
| 913 | ret = 2;
|
---|
| 914 | }
|
---|
[1265] | 915 | #ifdef NO_RTCM3_MAIN
|
---|
| 916 | else
|
---|
| 917 | ret = type;
|
---|
| 918 | #endif /* NO_RTCM3_MAIN */
|
---|
[270] | 919 | }
|
---|
| 920 | break;
|
---|
[4367] | 921 | case 1071: case 1081: case 1091: case 1101: case 1111: case 1121:
|
---|
| 922 | case 1072: case 1082: case 1092: case 1102: case 1112: case 1122:
|
---|
| 923 | case 1073: case 1083: case 1093: case 1103: case 1113: case 1123:
|
---|
| 924 | case 1074: case 1084: case 1094: case 1104: case 1114: case 1124:
|
---|
| 925 | case 1075: case 1085: case 1095: case 1105: case 1115: case 1125:
|
---|
| 926 | case 1076: case 1086: case 1096: case 1106: case 1116: case 1126:
|
---|
| 927 | case 1077: case 1087: case 1097: case 1107: case 1117: case 1127:
|
---|
[2659] | 928 | if(handle->GPSWeek)
|
---|
| 929 | {
|
---|
| 930 | struct CodeData {
|
---|
| 931 | int typeR;
|
---|
| 932 | int typeP;
|
---|
| 933 | int typeD;
|
---|
| 934 | int typeS;
|
---|
| 935 | int lock;
|
---|
| 936 | double wl;
|
---|
| 937 | const char *code; /* currently unused */
|
---|
| 938 | };
|
---|
| 939 | struct CodeData gps[RTCM3_MSM_NUMSIG] =
|
---|
| 940 | {
|
---|
| 941 | {0,0,0,0,0,0,0},
|
---|
| 942 | {GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 943 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1C"},
|
---|
| 944 | {GNSSENTRY_P1DATA,GNSSENTRY_L1PDATA,GNSSENTRY_D1PDATA,
|
---|
| 945 | GNSSENTRY_S1PDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1P"},
|
---|
| 946 | {GNSSENTRY_P1DATA,GNSSENTRY_L1PDATA,GNSSENTRY_D1PDATA,
|
---|
| 947 | GNSSENTRY_S1PDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1W"},
|
---|
[3581] | 948 | {0,0,0,0,0,0,0}/*{GNSSENTRY_P1DATA,GNSSENTRY_L1PDATA,GNSSENTRY_D1PDATA,
|
---|
| 949 | GNSSENTRY_S1PDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1Y"}*/,
|
---|
[2659] | 950 | {0,0,0,0,0,0,0},
|
---|
| 951 | {0,0,0,0,0,0,0},
|
---|
| 952 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 953 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2C"},
|
---|
| 954 | {GNSSENTRY_P2DATA,GNSSENTRY_L2PDATA,GNSSENTRY_D2PDATA,
|
---|
| 955 | GNSSENTRY_S2PDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2P"},
|
---|
| 956 | {GNSSENTRY_P2DATA,GNSSENTRY_L2PDATA,GNSSENTRY_D2PDATA,
|
---|
| 957 | GNSSENTRY_S2PDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2W"},
|
---|
[3581] | 958 | {0,0,0,0,0,0,0}/*{GNSSENTRY_P2DATA,GNSSENTRY_L2PDATA,GNSSENTRY_D2PDATA,
|
---|
| 959 | GNSSENTRY_S2PDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2Y"}*/,
|
---|
[2659] | 960 | {0,0,0,0,0,0,0},
|
---|
| 961 | {0,0,0,0,0,0,0},
|
---|
| 962 | {0,0,0,0,0,0,0},
|
---|
| 963 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 964 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2S"},
|
---|
| 965 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 966 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2L"},
|
---|
| 967 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 968 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2X"},
|
---|
| 969 | {0,0,0,0,0,0,0},
|
---|
| 970 | {0,0,0,0,0,0,0},
|
---|
| 971 | {0,0,0,0,0,0,0},
|
---|
| 972 | {0,0,0,0,0,0,0},
|
---|
| 973 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 974 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GPS_WAVELENGTH_L5,"5I"},
|
---|
| 975 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 976 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GPS_WAVELENGTH_L5,"5Q"},
|
---|
| 977 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
[3581] | 978 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GPS_WAVELENGTH_L5,"5X"},
|
---|
| 979 | {0,0,0,0,0,0,0},
|
---|
| 980 | {0,0,0,0,0,0,0},
|
---|
| 981 | {0,0,0,0,0,0,0},
|
---|
| 982 | {0,0,0,0,0,0,0},
|
---|
| 983 | {0,0,0,0,0,0,0},
|
---|
[4367] | 984 | {GNSSENTRY_C1NDATA,GNSSENTRY_L1NDATA,GNSSENTRY_D1NDATA,
|
---|
| 985 | GNSSENTRY_S1NDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1S"},
|
---|
| 986 | {GNSSENTRY_C1NDATA,GNSSENTRY_L1NDATA,GNSSENTRY_D1NDATA,
|
---|
| 987 | GNSSENTRY_S1NDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1L"},
|
---|
| 988 | {GNSSENTRY_C1NDATA,GNSSENTRY_L1NDATA,GNSSENTRY_D1NDATA,
|
---|
| 989 | GNSSENTRY_S1NDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1X"}
|
---|
[2659] | 990 | };
|
---|
| 991 | /* NOTE: Uses 0.0, 1.0 for wavelength as sat index dependence is done later! */
|
---|
| 992 | struct CodeData glo[RTCM3_MSM_NUMSIG] =
|
---|
| 993 | {
|
---|
| 994 | {0,0,0,0,0,0,0},
|
---|
| 995 | {GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 996 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,0.0,"1C"},
|
---|
| 997 | {GNSSENTRY_P1DATA,GNSSENTRY_L1PDATA,GNSSENTRY_D1PDATA,
|
---|
| 998 | GNSSENTRY_S1PDATA,GNSSDF2_LOCKLOSSL1,0.0,"1P"},
|
---|
| 999 | {0,0,0,0,0,0,0},
|
---|
| 1000 | {0,0,0,0,0,0,0},
|
---|
| 1001 | {0,0,0,0,0,0,0},
|
---|
| 1002 | {0,0,0,0,0,0,0},
|
---|
| 1003 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 1004 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,1.0,"2C"},
|
---|
| 1005 | {GNSSENTRY_P2DATA,GNSSENTRY_L2PDATA,GNSSENTRY_D2PDATA,
|
---|
| 1006 | GNSSENTRY_S2PDATA,GNSSDF2_LOCKLOSSL2,1.0,"2P"},
|
---|
| 1007 | {0,0,0,0,0,0,0},
|
---|
| 1008 | {0,0,0,0,0,0,0},
|
---|
| 1009 | {0,0,0,0,0,0,0},
|
---|
| 1010 | {0,0,0,0,0,0,0},
|
---|
| 1011 | {0,0,0,0,0,0,0},
|
---|
| 1012 | {0,0,0,0,0,0,0},
|
---|
| 1013 | {0,0,0,0,0,0,0},
|
---|
| 1014 | {0,0,0,0,0,0,0},
|
---|
| 1015 | {0,0,0,0,0,0,0},
|
---|
| 1016 | {0,0,0,0,0,0,0},
|
---|
| 1017 | {0,0,0,0,0,0,0},
|
---|
| 1018 | {0,0,0,0,0,0,0},
|
---|
| 1019 | {0,0,0,0,0,0,0},
|
---|
| 1020 | {0,0,0,0,0,0,0},
|
---|
[3581] | 1021 | {0,0,0,0,0,0,0},
|
---|
| 1022 | {0,0,0,0,0,0,0},
|
---|
| 1023 | {0,0,0,0,0,0,0},
|
---|
| 1024 | {0,0,0,0,0,0,0},
|
---|
| 1025 | {0,0,0,0,0,0,0},
|
---|
| 1026 | {0,0,0,0,0,0,0},
|
---|
| 1027 | {0,0,0,0,0,0,0},
|
---|
| 1028 | {0,0,0,0,0,0,0},
|
---|
[2659] | 1029 | {0,0,0,0,0,0,0}
|
---|
| 1030 | };
|
---|
| 1031 | struct CodeData gal[RTCM3_MSM_NUMSIG] =
|
---|
| 1032 | {
|
---|
| 1033 | {0,0,0,0,0,0,0},
|
---|
| 1034 | {GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 1035 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,GAL_WAVELENGTH_E1,"1C"},
|
---|
[3581] | 1036 | {0,0,0,0,0,0,0}/*{GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 1037 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,GAL_WAVELENGTH_E1,"1A"}*/,
|
---|
[2659] | 1038 | {GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 1039 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,GAL_WAVELENGTH_E1,"1B"},
|
---|
[4228] | 1040 | {GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 1041 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,GAL_WAVELENGTH_E1,"1X"}/**/,
|
---|
[3581] | 1042 | {0,0,0,0,0,0,0}/*{GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 1043 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,GAL_WAVELENGTH_E1,"1Z"}*/,
|
---|
[2659] | 1044 | {0,0,0,0,0,0,0},
|
---|
| 1045 | {GNSSENTRY_C6DATA,GNSSENTRY_L6DATA,GNSSENTRY_D6DATA,
|
---|
[3581] | 1046 | GNSSENTRY_S6DATA,GNSSDF2_LOCKLOSSE6,GAL_WAVELENGTH_E6,"6C"},
|
---|
| 1047 | {0,0,0,0,0,0,0}/*{GNSSENTRY_C6DATA,GNSSENTRY_L6DATA,GNSSENTRY_D6DATA,
|
---|
| 1048 | GNSSENTRY_S6DATA,GNSSDF2_LOCKLOSSE6,GAL_WAVELENGTH_E6,"6A"}*/,
|
---|
[2659] | 1049 | {GNSSENTRY_C6DATA,GNSSENTRY_L6DATA,GNSSENTRY_D6DATA,
|
---|
[3581] | 1050 | GNSSENTRY_S6DATA,GNSSDF2_LOCKLOSSE6,GAL_WAVELENGTH_E6,"6B"},
|
---|
| 1051 | {0,0,0,0,0,0,0}/*{GNSSENTRY_C6DATA,GNSSENTRY_L6DATA,GNSSENTRY_D6DATA,
|
---|
| 1052 | GNSSENTRY_S6DATA,GNSSDF2_LOCKLOSSE6,GAL_WAVELENGTH_E6,"6X"}*/,
|
---|
| 1053 | {0,0,0,0,0,0,0}/*{GNSSENTRY_C6DATA,GNSSENTRY_L6DATA,GNSSENTRY_D6DATA,
|
---|
| 1054 | GNSSENTRY_S6DATA,GNSSDF2_LOCKLOSSE6,GAL_WAVELENGTH_E6,"6Z"}*/,
|
---|
[2659] | 1055 | {0,0,0,0,0,0,0},
|
---|
| 1056 | {GNSSENTRY_C5BDATA,GNSSENTRY_L5BDATA,GNSSENTRY_D5BDATA,
|
---|
| 1057 | GNSSENTRY_S5BDATA,GNSSDF2_LOCKLOSSE5B,GAL_WAVELENGTH_E5B,"7I"},
|
---|
| 1058 | {GNSSENTRY_C5BDATA,GNSSENTRY_L5BDATA,GNSSENTRY_D5BDATA,
|
---|
| 1059 | GNSSENTRY_S5BDATA,GNSSDF2_LOCKLOSSE5B,GAL_WAVELENGTH_E5B,"7Q"},
|
---|
[4228] | 1060 | {GNSSENTRY_C5BDATA,GNSSENTRY_L5BDATA,GNSSENTRY_D5BDATA,
|
---|
| 1061 | GNSSENTRY_S5BDATA,GNSSDF2_LOCKLOSSE5B,GAL_WAVELENGTH_E5B,"7X"}/**/,
|
---|
[2659] | 1062 | {0,0,0,0,0,0,0},
|
---|
| 1063 | {GNSSENTRY_C5ABDATA,GNSSENTRY_L5ABDATA,GNSSENTRY_D5ABDATA,
|
---|
| 1064 | GNSSENTRY_S5ABDATA,GNSSDF2_LOCKLOSSE5AB,GAL_WAVELENGTH_E5AB,"8I"},
|
---|
| 1065 | {GNSSENTRY_C5ABDATA,GNSSENTRY_L5ABDATA,GNSSENTRY_D5ABDATA,
|
---|
| 1066 | GNSSENTRY_S5ABDATA,GNSSDF2_LOCKLOSSE5AB,GAL_WAVELENGTH_E5AB,"8Q"},
|
---|
[4228] | 1067 | {GNSSENTRY_C5ABDATA,GNSSENTRY_L5ABDATA,GNSSENTRY_D5ABDATA,
|
---|
| 1068 | GNSSENTRY_S5ABDATA,GNSSDF2_LOCKLOSSE5AB,GAL_WAVELENGTH_E5AB,"8X"}/**/,
|
---|
[2659] | 1069 | {0,0,0,0,0,0,0},
|
---|
| 1070 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 1071 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GAL_WAVELENGTH_E5A,"5I"},
|
---|
| 1072 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 1073 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GAL_WAVELENGTH_E5A,"5Q"},
|
---|
[4228] | 1074 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 1075 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GAL_WAVELENGTH_E5A,"5X"}/**/,
|
---|
[3581] | 1076 | {0,0,0,0,0,0,0},
|
---|
| 1077 | {0,0,0,0,0,0,0},
|
---|
| 1078 | {0,0,0,0,0,0,0},
|
---|
| 1079 | {0,0,0,0,0,0,0},
|
---|
| 1080 | {0,0,0,0,0,0,0},
|
---|
| 1081 | {0,0,0,0,0,0,0},
|
---|
| 1082 | {0,0,0,0,0,0,0},
|
---|
| 1083 | {0,0,0,0,0,0,0},
|
---|
[2659] | 1084 | };
|
---|
[4367] | 1085 | struct CodeData qzss[RTCM3_MSM_NUMSIG] =
|
---|
| 1086 | {
|
---|
| 1087 | {0,0,0,0,0,0,0},
|
---|
| 1088 | {GNSSENTRY_C1DATA,GNSSENTRY_L1CDATA,GNSSENTRY_D1CDATA,
|
---|
| 1089 | GNSSENTRY_S1CDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1C"},
|
---|
| 1090 | {0,0,0,0,0,0,0},
|
---|
| 1091 | {0,0,0,0,0,0,0},
|
---|
| 1092 | {0,0,0,0,0,0,0},
|
---|
| 1093 | {GNSSENTRY_CSAIFDATA,GNSSENTRY_LSAIFDATA,GNSSENTRY_DSAIFDATA,
|
---|
| 1094 | GNSSENTRY_SSAIFDATA,GNSSDF2_LOCKLOSSSAIF,GPS_WAVELENGTH_L1,"1Z"},
|
---|
| 1095 | {0,0,0,0,0,0,0},
|
---|
| 1096 | {0,0,0,0,0,0,0},
|
---|
| 1097 | {GNSSENTRY_CLEXDATA,GNSSENTRY_LLEXDATA,GNSSENTRY_DLEXDATA,
|
---|
| 1098 | GNSSENTRY_SLEXDATA,GNSSDF2_LOCKLOSSLEX,QZSS_WAVELENGTH_LEX,"6S"},
|
---|
| 1099 | {GNSSENTRY_CLEXDATA,GNSSENTRY_LLEXDATA,GNSSENTRY_DLEXDATA,
|
---|
| 1100 | GNSSENTRY_SLEXDATA,GNSSDF2_LOCKLOSSLEX,QZSS_WAVELENGTH_LEX,"6L"},
|
---|
| 1101 | {GNSSENTRY_CLEXDATA,GNSSENTRY_LLEXDATA,GNSSENTRY_DLEXDATA,
|
---|
| 1102 | GNSSENTRY_SLEXDATA,GNSSDF2_LOCKLOSSLEX,QZSS_WAVELENGTH_LEX,"6X"},
|
---|
[4498] | 1103 | {0,0,0,0,0,0,0},
|
---|
| 1104 | {0,0,0,0,0,0,0},
|
---|
| 1105 | {0,0,0,0,0,0,0},
|
---|
[4367] | 1106 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 1107 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2S"},
|
---|
| 1108 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 1109 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2L"},
|
---|
| 1110 | {GNSSENTRY_C2DATA,GNSSENTRY_L2CDATA,GNSSENTRY_D2CDATA,
|
---|
| 1111 | GNSSENTRY_S2CDATA,GNSSDF2_LOCKLOSSL2,GPS_WAVELENGTH_L2,"2X"},
|
---|
| 1112 | {0,0,0,0,0,0,0},
|
---|
| 1113 | {0,0,0,0,0,0,0},
|
---|
| 1114 | {0,0,0,0,0,0,0},
|
---|
| 1115 | {0,0,0,0,0,0,0},
|
---|
| 1116 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 1117 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GPS_WAVELENGTH_L5,"5I"},
|
---|
| 1118 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 1119 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GPS_WAVELENGTH_L5,"5Q"},
|
---|
| 1120 | {GNSSENTRY_C5DATA,GNSSENTRY_L5DATA,GNSSENTRY_D5DATA,
|
---|
| 1121 | GNSSENTRY_S5DATA,GNSSDF2_LOCKLOSSL5,GPS_WAVELENGTH_L5,"5X"},
|
---|
| 1122 | {0,0,0,0,0,0,0},
|
---|
| 1123 | {0,0,0,0,0,0,0},
|
---|
| 1124 | {0,0,0,0,0,0,0},
|
---|
| 1125 | {0,0,0,0,0,0,0},
|
---|
[4535] | 1126 | {0,0,0,0,0,0,0},
|
---|
[4498] | 1127 | {GNSSENTRY_C1NDATA,GNSSENTRY_L1NDATA,GNSSENTRY_D1NDATA,
|
---|
| 1128 | GNSSENTRY_S1NDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1D"},
|
---|
| 1129 | {GNSSENTRY_C1NDATA,GNSSENTRY_L1NDATA,GNSSENTRY_D1NDATA,
|
---|
| 1130 | GNSSENTRY_S1NDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1P"},
|
---|
| 1131 | {GNSSENTRY_C1NDATA,GNSSENTRY_L1NDATA,GNSSENTRY_D1NDATA,
|
---|
| 1132 | GNSSENTRY_S1NDATA,GNSSDF2_LOCKLOSSL1,GPS_WAVELENGTH_L1,"1X"}
|
---|
[4367] | 1133 | };
|
---|
| 1134 | struct CodeData compass[RTCM3_MSM_NUMSIG] =
|
---|
| 1135 | {
|
---|
| 1136 | {0,0,0,0,0,0,0},
|
---|
| 1137 | {GNSSENTRY_CB1DATA,GNSSENTRY_LB1DATA,GNSSENTRY_DB1DATA,
|
---|
| 1138 | GNSSENTRY_SB1DATA,GNSSDF2_LOCKLOSSB1,COMPASS_WAVELENGTH_B1,"2I"},
|
---|
| 1139 | {0,0,0,0,0,0,0},
|
---|
| 1140 | {0,0,0,0,0,0,0},
|
---|
| 1141 | {0,0,0,0,0,0,0},
|
---|
| 1142 | {0,0,0,0,0,0,0},
|
---|
| 1143 | {0,0,0,0,0,0,0},
|
---|
| 1144 | {GNSSENTRY_CB3DATA,GNSSENTRY_LB3DATA,GNSSENTRY_DB3DATA,
|
---|
| 1145 | GNSSENTRY_SB3DATA,GNSSDF2_LOCKLOSSB3,COMPASS_WAVELENGTH_B3,"6I"},
|
---|
| 1146 | {0,0,0,0,0,0,0},
|
---|
| 1147 | {0,0,0,0,0,0,0},
|
---|
| 1148 | {0,0,0,0,0,0,0},
|
---|
| 1149 | {0,0,0,0,0,0,0},
|
---|
| 1150 | {0,0,0,0,0,0,0},
|
---|
| 1151 | {GNSSENTRY_CB2DATA,GNSSENTRY_LB2DATA,GNSSENTRY_DB2DATA,
|
---|
| 1152 | GNSSENTRY_SB2DATA,GNSSDF2_LOCKLOSSB2,COMPASS_WAVELENGTH_B2,"7I"},
|
---|
| 1153 | {0,0,0,0,0,0,0},
|
---|
| 1154 | {0,0,0,0,0,0,0},
|
---|
| 1155 | {0,0,0,0,0,0,0},
|
---|
| 1156 | {0,0,0,0,0,0,0},
|
---|
| 1157 | {0,0,0,0,0,0,0},
|
---|
| 1158 | {0,0,0,0,0,0,0},
|
---|
| 1159 | {0,0,0,0,0,0,0},
|
---|
| 1160 | {0,0,0,0,0,0,0},
|
---|
| 1161 | {0,0,0,0,0,0,0},
|
---|
| 1162 | {0,0,0,0,0,0,0},
|
---|
| 1163 | {0,0,0,0,0,0,0},
|
---|
| 1164 | {0,0,0,0,0,0,0},
|
---|
| 1165 | {0,0,0,0,0,0,0},
|
---|
| 1166 | {0,0,0,0,0,0,0},
|
---|
| 1167 | {0,0,0,0,0,0,0},
|
---|
| 1168 | {0,0,0,0,0,0,0},
|
---|
| 1169 | {0,0,0,0,0,0,0},
|
---|
| 1170 | {0,0,0,0,0,0,0},
|
---|
| 1171 | };
|
---|
[2659] | 1172 |
|
---|
[4371] | 1173 | int sys = RTCM3_MSM_GPS, i=0, count, j, old = 0, wasnoamb = 0,
|
---|
| 1174 | start=PRN_GPS_START;
|
---|
[2659] | 1175 | int syncf, sigmask, numsat = 0, numsig = 0, numcells;
|
---|
| 1176 | uint64_t satmask, cellmask, ui;
|
---|
| 1177 | double rrmod[RTCM3_MSM_NUMSAT];
|
---|
[3581] | 1178 | int rrint[RTCM3_MSM_NUMSAT], rdop[RTCM3_MSM_NUMSAT],
|
---|
| 1179 | extsat[RTCM3_MSM_NUMSAT];
|
---|
[3712] | 1180 | int ll[RTCM3_MSM_NUMCELLS], hc[RTCM3_MSM_NUMCELLS];
|
---|
[2659] | 1181 | double cnr[RTCM3_MSM_NUMCELLS];
|
---|
| 1182 | double cp[RTCM3_MSM_NUMCELLS], psr[RTCM3_MSM_NUMCELLS],
|
---|
| 1183 | dop[RTCM3_MSM_NUMCELLS];
|
---|
| 1184 | struct gnssdata *gnss = &handle->DataNew;
|
---|
| 1185 |
|
---|
| 1186 | SKIPBITS(12)
|
---|
[4367] | 1187 | if(type >= 1121)
|
---|
[4371] | 1188 | {
|
---|
[4367] | 1189 | sys = RTCM3_MSM_COMPASS;
|
---|
[4371] | 1190 | start = PRN_COMPASS_START;
|
---|
| 1191 | }
|
---|
[4367] | 1192 | else if(type >= 1111)
|
---|
[4371] | 1193 | {
|
---|
[4367] | 1194 | sys = RTCM3_MSM_QZSS;
|
---|
[4371] | 1195 | start = PRN_QZSS_START;
|
---|
| 1196 | }
|
---|
[4367] | 1197 | else if(type >= 1101)
|
---|
[4371] | 1198 | {
|
---|
[4367] | 1199 | sys = RTCM3_MSM_SBAS;
|
---|
[4371] | 1200 | start = PRN_SBAS_START;
|
---|
| 1201 | }
|
---|
[4367] | 1202 | else if(type >= 1091)
|
---|
[4371] | 1203 | {
|
---|
[2659] | 1204 | sys = RTCM3_MSM_GALILEO;
|
---|
[4371] | 1205 | start = PRN_GALILEO_START;
|
---|
| 1206 | }
|
---|
[2659] | 1207 | else if(type >= 1081)
|
---|
[4371] | 1208 | {
|
---|
[2659] | 1209 | sys = RTCM3_MSM_GLONASS;
|
---|
[4371] | 1210 | start = PRN_GLONASS_START;
|
---|
| 1211 | }
|
---|
[2659] | 1212 |
|
---|
[4383] | 1213 | for(i = 0; i < RTCM3_MSM_NUMSAT; ++i)
|
---|
| 1214 | extsat[i] = 15;
|
---|
| 1215 |
|
---|
[2659] | 1216 | switch(sys)
|
---|
| 1217 | {
|
---|
[4367] | 1218 | case RTCM3_MSM_COMPASS:
|
---|
[2659] | 1219 | case RTCM3_MSM_GALILEO: /* use DF004 instead of DF248 */
|
---|
[4367] | 1220 | case RTCM3_MSM_QZSS:
|
---|
| 1221 | case RTCM3_MSM_SBAS:
|
---|
[2659] | 1222 | case RTCM3_MSM_GPS:
|
---|
| 1223 | GETBITS(i,30)
|
---|
| 1224 | if(i/1000 < (int)handle->GPSTOW - 86400)
|
---|
| 1225 | ++handle->GPSWeek;
|
---|
| 1226 | handle->GPSTOW = i/1000;
|
---|
| 1227 | break;
|
---|
| 1228 | case RTCM3_MSM_GLONASS:
|
---|
| 1229 | SKIPBITS(3)
|
---|
| 1230 | GETBITS(i,27) /* tk */
|
---|
| 1231 |
|
---|
| 1232 | updatetime(&handle->GPSWeek, &handle->GPSTOW, i, 0); /* Moscow -> GPS */
|
---|
| 1233 | i = handle->GPSTOW*1000;
|
---|
| 1234 | break;
|
---|
| 1235 | }
|
---|
| 1236 |
|
---|
| 1237 | if(gnss->week && (gnss->timeofweek != i || gnss->week
|
---|
| 1238 | != handle->GPSWeek))
|
---|
| 1239 | {
|
---|
| 1240 | handle->Data = *gnss;
|
---|
| 1241 | memset(gnss, 0, sizeof(*gnss));
|
---|
| 1242 | old = 1;
|
---|
| 1243 | }
|
---|
| 1244 | gnss->timeofweek = i;
|
---|
| 1245 | gnss->week = handle->GPSWeek;
|
---|
| 1246 |
|
---|
| 1247 | GETBITS(syncf, 1)
|
---|
[3581] | 1248 | SKIPBITS(3+7+2+2+1+3)
|
---|
[2860] | 1249 | GETBITS64(satmask, RTCM3_MSM_NUMSAT)
|
---|
[2659] | 1250 |
|
---|
| 1251 | /* http://gurmeetsingh.wordpress.com/2008/08/05/fast-bit-counting-routines/ */
|
---|
| 1252 | for(ui = satmask; ui; ui &= (ui - 1) /* remove rightmost bit */)
|
---|
| 1253 | ++numsat;
|
---|
| 1254 | GETBITS(sigmask, RTCM3_MSM_NUMSIG)
|
---|
| 1255 | for(i = sigmask; i; i &= (i - 1) /* remove rightmost bit */)
|
---|
| 1256 | ++numsig;
|
---|
| 1257 | i = numsat*numsig;
|
---|
[2860] | 1258 | GETBITS64(cellmask, (unsigned)i)
|
---|
[2659] | 1259 |
|
---|
| 1260 | switch(type % 10)
|
---|
| 1261 | {
|
---|
| 1262 | case 1: case 2: case 3:
|
---|
[2668] | 1263 | ++wasnoamb;
|
---|
[2659] | 1264 | for(j = numsat; j--;)
|
---|
[3581] | 1265 | GETFLOAT(rrmod[j], 10, 1.0/1024.0)
|
---|
[2659] | 1266 | break;
|
---|
| 1267 | case 4: case 6:
|
---|
| 1268 | for(j = numsat; j--;)
|
---|
| 1269 | GETBITS(rrint[j], 8)
|
---|
| 1270 | for(j = numsat; j--;)
|
---|
[3581] | 1271 | GETFLOAT(rrmod[j], 10, 1.0/1024.0)
|
---|
[2659] | 1272 | break;
|
---|
| 1273 | case 5: case 7:
|
---|
| 1274 | for(j = numsat; j--;)
|
---|
| 1275 | GETBITS(rrint[j], 8)
|
---|
| 1276 | for(j = numsat; j--;)
|
---|
[3581] | 1277 | GETBITS(extsat[j], 4)
|
---|
[2659] | 1278 | for(j = numsat; j--;)
|
---|
[3581] | 1279 | GETFLOAT(rrmod[j], 10, 1.0/1024.0)
|
---|
| 1280 | for(j = numsat; j--;)
|
---|
[2659] | 1281 | GETBITSSIGN(rdop[j], 14)
|
---|
| 1282 | break;
|
---|
| 1283 | }
|
---|
| 1284 |
|
---|
| 1285 | numcells = numsat*numsig;
|
---|
| 1286 | if(numcells <= RTCM3_MSM_NUMCELLS)
|
---|
| 1287 | {
|
---|
| 1288 | switch(type % 10)
|
---|
| 1289 | {
|
---|
| 1290 | case 1:
|
---|
| 1291 | for(count = numcells; count--;)
|
---|
| 1292 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1293 | GETFLOATSIGN(psr[count], 15, 1.0/(1<<24))
|
---|
[2659] | 1294 | break;
|
---|
| 1295 | case 2:
|
---|
| 1296 | for(count = numcells; count--;)
|
---|
| 1297 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1298 | GETFLOATSIGN(cp[count], 22, 1.0/(1<<29))
|
---|
[2659] | 1299 | for(count = numcells; count--;)
|
---|
| 1300 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1301 | GETBITS(ll[count], 4)
|
---|
[3712] | 1302 | for(count = numcells; count--;)
|
---|
| 1303 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1304 | GETBITS(hc[count], 1)
|
---|
[2659] | 1305 | break;
|
---|
| 1306 | case 3:
|
---|
| 1307 | for(count = numcells; count--;)
|
---|
| 1308 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1309 | GETFLOATSIGN(psr[count], 15, 1.0/(1<<24))
|
---|
[2659] | 1310 | for(count = numcells; count--;)
|
---|
| 1311 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1312 | GETFLOATSIGN(cp[count], 22, 1.0/(1<<29))
|
---|
[2659] | 1313 | for(count = numcells; count--;)
|
---|
| 1314 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1315 | GETBITS(ll[count], 4)
|
---|
[3712] | 1316 | for(count = numcells; count--;)
|
---|
| 1317 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1318 | GETBITS(hc[count], 1)
|
---|
[2659] | 1319 | break;
|
---|
| 1320 | case 4:
|
---|
| 1321 | for(count = numcells; count--;)
|
---|
| 1322 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1323 | GETFLOATSIGN(psr[count], 15, 1.0/(1<<24))
|
---|
[2659] | 1324 | for(count = numcells; count--;)
|
---|
| 1325 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1326 | GETFLOATSIGN(cp[count], 22, 1.0/(1<<29))
|
---|
[2659] | 1327 | for(count = numcells; count--;)
|
---|
| 1328 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1329 | GETBITS(ll[count], 4)
|
---|
| 1330 | for(count = numcells; count--;)
|
---|
| 1331 | if(cellmask & (UINT64(1)<<count))
|
---|
[3712] | 1332 | GETBITS(hc[count], 1)
|
---|
| 1333 | for(count = numcells; count--;)
|
---|
| 1334 | if(cellmask & (UINT64(1)<<count))
|
---|
[2659] | 1335 | GETBITS(cnr[count], 6)
|
---|
| 1336 | break;
|
---|
| 1337 | case 5:
|
---|
| 1338 | for(count = numcells; count--;)
|
---|
| 1339 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1340 | GETFLOATSIGN(psr[count], 15, 1.0/(1<<24))
|
---|
[2659] | 1341 | for(count = numcells; count--;)
|
---|
| 1342 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1343 | GETFLOATSIGN(cp[count], 22, 1.0/(1<<29))
|
---|
[2659] | 1344 | for(count = numcells; count--;)
|
---|
| 1345 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1346 | GETBITS(ll[count], 4)
|
---|
| 1347 | for(count = numcells; count--;)
|
---|
| 1348 | if(cellmask & (UINT64(1)<<count))
|
---|
[3712] | 1349 | GETBITS(hc[count], 1)
|
---|
| 1350 | for(count = numcells; count--;)
|
---|
| 1351 | if(cellmask & (UINT64(1)<<count))
|
---|
[2659] | 1352 | GETFLOAT(cnr[count], 6, 1.0)
|
---|
| 1353 | for(count = numcells; count--;)
|
---|
| 1354 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1355 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 1356 | break;
|
---|
| 1357 | case 6:
|
---|
| 1358 | for(count = numcells; count--;)
|
---|
| 1359 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1360 | GETFLOATSIGN(psr[count], 20, 1.0/(1<<29))
|
---|
[2659] | 1361 | for(count = numcells; count--;)
|
---|
| 1362 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1363 | GETFLOATSIGN(cp[count], 24, 1.0/(1U<<31))
|
---|
[2659] | 1364 | for(count = numcells; count--;)
|
---|
| 1365 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1366 | GETBITS(ll[count], 10)
|
---|
| 1367 | for(count = numcells; count--;)
|
---|
| 1368 | if(cellmask & (UINT64(1)<<count))
|
---|
[3712] | 1369 | GETBITS(hc[count], 1)
|
---|
| 1370 | for(count = numcells; count--;)
|
---|
| 1371 | if(cellmask & (UINT64(1)<<count))
|
---|
[3724] | 1372 | GETFLOAT(cnr[count], 10, 1.0/(1<<4))
|
---|
[3581] | 1373 | break;
|
---|
[2659] | 1374 | case 7:
|
---|
| 1375 | for(count = numcells; count--;)
|
---|
| 1376 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1377 | GETFLOATSIGN(psr[count], 20, 1.0/(1<<29))
|
---|
[2659] | 1378 | for(count = numcells; count--;)
|
---|
| 1379 | if(cellmask & (UINT64(1)<<count))
|
---|
[3581] | 1380 | GETFLOATSIGN(cp[count], 24, 1.0/(1U<<31))
|
---|
[2659] | 1381 | for(count = numcells; count--;)
|
---|
| 1382 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1383 | GETBITS(ll[count], 10)
|
---|
| 1384 | for(count = numcells; count--;)
|
---|
| 1385 | if(cellmask & (UINT64(1)<<count))
|
---|
[3712] | 1386 | GETBITS(hc[count], 1)
|
---|
| 1387 | for(count = numcells; count--;)
|
---|
| 1388 | if(cellmask & (UINT64(1)<<count))
|
---|
[3724] | 1389 | GETFLOAT(cnr[count], 10, 1.0/(1<<4))
|
---|
[2659] | 1390 | for(count = numcells; count--;)
|
---|
| 1391 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1392 | GETFLOATSIGN(dop[count], 15, 0.0001)
|
---|
| 1393 | break;
|
---|
| 1394 | }
|
---|
| 1395 | i = RTCM3_MSM_NUMSAT;
|
---|
| 1396 | j = -1;
|
---|
| 1397 | for(count = numcells; count--;)
|
---|
| 1398 | {
|
---|
| 1399 | while(j >= 0 && !(sigmask&(1<<--j)))
|
---|
| 1400 | ;
|
---|
| 1401 | if(j < 0)
|
---|
| 1402 | {
|
---|
| 1403 | while(!(satmask&(UINT64(1)<<(--i)))) /* next satellite */
|
---|
| 1404 | ;
|
---|
| 1405 | j = RTCM3_MSM_NUMSIG;
|
---|
| 1406 | while(!(sigmask&(1<<--j)))
|
---|
| 1407 | ;
|
---|
| 1408 | --numsat;
|
---|
| 1409 | }
|
---|
| 1410 | if(cellmask & (UINT64(1)<<count))
|
---|
| 1411 | {
|
---|
| 1412 | struct CodeData cd = {0,0,0,0,0,0,0};
|
---|
| 1413 | double wl = 0.0;
|
---|
| 1414 | switch(sys)
|
---|
| 1415 | {
|
---|
[4367] | 1416 | case RTCM3_MSM_QZSS:
|
---|
| 1417 | cd = qzss[RTCM3_MSM_NUMSIG-j-1];
|
---|
[2659] | 1418 | wl = cd.wl;
|
---|
| 1419 | break;
|
---|
[4367] | 1420 | case RTCM3_MSM_COMPASS:
|
---|
| 1421 | cd = compass[RTCM3_MSM_NUMSIG-j-1];
|
---|
| 1422 | wl = cd.wl;
|
---|
| 1423 | break;
|
---|
| 1424 | case RTCM3_MSM_GPS: case RTCM3_MSM_SBAS:
|
---|
| 1425 | cd = gps[RTCM3_MSM_NUMSIG-j-1];
|
---|
| 1426 | wl = cd.wl;
|
---|
| 1427 | break;
|
---|
[2659] | 1428 | case RTCM3_MSM_GLONASS: cd = glo[RTCM3_MSM_NUMSIG-j-1];
|
---|
| 1429 | {
|
---|
| 1430 | int k = handle->GLOFreq[RTCM3_MSM_NUMSAT-i-1];
|
---|
[3653] | 1431 | if(!k && extsat[count] < 14)
|
---|
| 1432 | {
|
---|
[3654] | 1433 | k = handle->GLOFreq[RTCM3_MSM_NUMSAT-i-1]
|
---|
[3653] | 1434 | = 100+extsat[count]-7;
|
---|
| 1435 | }
|
---|
[2659] | 1436 | if(k)
|
---|
| 1437 | {
|
---|
| 1438 | if(cd.wl == 0.0)
|
---|
| 1439 | wl = GLO_WAVELENGTH_L1(k-100);
|
---|
| 1440 | else if(cd.wl == 1.0)
|
---|
| 1441 | wl = GLO_WAVELENGTH_L2(k-100);
|
---|
| 1442 | }
|
---|
| 1443 | }
|
---|
| 1444 | break;
|
---|
| 1445 | case RTCM3_MSM_GALILEO: cd = gal[RTCM3_MSM_NUMSIG-j-1];
|
---|
| 1446 | wl = cd.wl;
|
---|
| 1447 | break;
|
---|
| 1448 | }
|
---|
| 1449 | if(cd.lock && wl) /* lock cannot have a valid zero value */
|
---|
| 1450 | {
|
---|
[2996] | 1451 | int fullsat = RTCM3_MSM_NUMSAT-i-1, num;
|
---|
| 1452 |
|
---|
| 1453 | if(sys == RTCM3_MSM_GALILEO && fullsat >= 50 && fullsat <= 51)
|
---|
| 1454 | fullsat += PRN_GIOVE_START-50;
|
---|
| 1455 | else
|
---|
[4371] | 1456 | fullsat += start;
|
---|
[2996] | 1457 |
|
---|
[2659] | 1458 | for(num = 0; num < gnss->numsats
|
---|
| 1459 | && fullsat != gnss->satellites[num]; ++num)
|
---|
| 1460 | ;
|
---|
| 1461 |
|
---|
| 1462 | if(num == gnss->numsats)
|
---|
| 1463 | gnss->satellites[gnss->numsats++] = fullsat;
|
---|
| 1464 |
|
---|
[4374] | 1465 | gnss->codetype[num][cd.typeR] =
|
---|
| 1466 | gnss->codetype[num][cd.typeP] =
|
---|
| 1467 | gnss->codetype[num][cd.typeD] =
|
---|
| 1468 | gnss->codetype[num][cd.typeS] = cd.code;
|
---|
[4371] | 1469 | if(!handle->info[sys].type[cd.typeR])
|
---|
| 1470 | {
|
---|
| 1471 | handle->info[sys].type[cd.typeR] =
|
---|
| 1472 | handle->info[sys].type[cd.typeP] =
|
---|
| 1473 | handle->info[sys].type[cd.typeD] =
|
---|
| 1474 | handle->info[sys].type[cd.typeS] = cd.code[1];
|
---|
| 1475 | }
|
---|
[4367] | 1476 |
|
---|
[2659] | 1477 | switch(type % 10)
|
---|
| 1478 | {
|
---|
| 1479 | case 1:
|
---|
[3581] | 1480 | if(psr[count] > -1.0/(1<<10))
|
---|
[2659] | 1481 | {
|
---|
[3581] | 1482 | gnss->measdata[num][cd.typeR] = psr[count]*LIGHTSPEED/1000.0
|
---|
[2668] | 1483 | +(rrmod[numsat])*LIGHTSPEED/1000.0;
|
---|
[4383] | 1484 | gnss->dataflags[num] |= (1LL<<cd.typeR);
|
---|
[2659] | 1485 | }
|
---|
| 1486 | break;
|
---|
| 1487 | case 2:
|
---|
[3581] | 1488 | if(wl && cp[count] > -1.0/(1<<8))
|
---|
[2659] | 1489 | {
|
---|
[3725] | 1490 | gnss->measdata[num][cd.typeP] = cp[count]*LIGHTSPEED/1000.0/wl
|
---|
[2668] | 1491 | +(rrmod[numsat])*LIGHTSPEED/1000.0/wl;
|
---|
[2659] | 1492 | if(handle->lastlockmsm[j][i] != ll[count])
|
---|
| 1493 | {
|
---|
| 1494 | gnss->dataflags2[num] |= cd.lock;
|
---|
| 1495 | handle->lastlockmsm[j][i] = ll[count];
|
---|
| 1496 | }
|
---|
[4383] | 1497 | gnss->dataflags[num] |= (1LL<<cd.typeP);
|
---|
[2659] | 1498 | }
|
---|
| 1499 | break;
|
---|
| 1500 | case 3:
|
---|
[3581] | 1501 | if(psr[count] > -1.0/(1<<10))
|
---|
[2659] | 1502 | {
|
---|
[3581] | 1503 | gnss->measdata[num][cd.typeR] = psr[count]*LIGHTSPEED/1000.0
|
---|
[2668] | 1504 | +(rrmod[numsat])*LIGHTSPEED/1000.0;
|
---|
[4383] | 1505 | gnss->dataflags[num] |= (1LL<<cd.typeR);
|
---|
[2659] | 1506 | }
|
---|
| 1507 |
|
---|
[3581] | 1508 | if(wl && cp[count] > -1.0/(1<<8))
|
---|
[2659] | 1509 | {
|
---|
[3725] | 1510 | gnss->measdata[num][cd.typeP] = cp[count]*LIGHTSPEED/1000.0/wl
|
---|
[2659] | 1511 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0/wl;
|
---|
| 1512 | if(handle->lastlockmsm[j][i] != ll[count])
|
---|
| 1513 | {
|
---|
| 1514 | gnss->dataflags2[num] |= cd.lock;
|
---|
| 1515 | handle->lastlockmsm[j][i] = ll[count];
|
---|
| 1516 | }
|
---|
[4383] | 1517 | gnss->dataflags[num] |= (1LL<<cd.typeP);
|
---|
[2659] | 1518 | }
|
---|
| 1519 | break;
|
---|
| 1520 | case 4:
|
---|
[3581] | 1521 | if(psr[count] > -1.0/(1<<10))
|
---|
[2659] | 1522 | {
|
---|
[3581] | 1523 | gnss->measdata[num][cd.typeR] = psr[count]*LIGHTSPEED/1000.0
|
---|
[2659] | 1524 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0;
|
---|
[4383] | 1525 | gnss->dataflags[num] |= (1LL<<cd.typeR);
|
---|
[2659] | 1526 | }
|
---|
| 1527 |
|
---|
[3581] | 1528 | if(wl && cp[count] > -1.0/(1<<8))
|
---|
[2659] | 1529 | {
|
---|
[3725] | 1530 | gnss->measdata[num][cd.typeP] = cp[count]*LIGHTSPEED/1000.0/wl
|
---|
[2659] | 1531 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0/wl;
|
---|
| 1532 | if(handle->lastlockmsm[j][i] != ll[count])
|
---|
| 1533 | {
|
---|
| 1534 | gnss->dataflags2[num] |= cd.lock;
|
---|
| 1535 | handle->lastlockmsm[j][i] = ll[count];
|
---|
| 1536 | }
|
---|
[4383] | 1537 | gnss->dataflags[num] |= (1LL<<cd.typeP);
|
---|
[2659] | 1538 | }
|
---|
| 1539 |
|
---|
| 1540 | gnss->measdata[num][cd.typeS] = cnr[count];
|
---|
[4383] | 1541 | gnss->dataflags[num] |= (1LL<<cd.typeS);
|
---|
[2659] | 1542 | break;
|
---|
| 1543 | case 5:
|
---|
[3581] | 1544 | if(psr[count] > -1.0/(1<<10))
|
---|
[2659] | 1545 | {
|
---|
[3581] | 1546 | gnss->measdata[num][cd.typeR] = psr[count]*LIGHTSPEED/1000.0
|
---|
[2659] | 1547 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0;
|
---|
[4383] | 1548 | gnss->dataflags[num] |= (1LL<<cd.typeR);
|
---|
[2659] | 1549 | }
|
---|
| 1550 |
|
---|
[3581] | 1551 | if(wl && cp[count] > -1.0/(1<<8))
|
---|
[2659] | 1552 | {
|
---|
[3725] | 1553 | gnss->measdata[num][cd.typeP] = cp[count]*LIGHTSPEED/1000.0/wl
|
---|
[2659] | 1554 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0/wl;
|
---|
| 1555 | if(handle->lastlockmsm[j][i] != ll[count])
|
---|
| 1556 | {
|
---|
| 1557 | gnss->dataflags2[num] |= cd.lock;
|
---|
| 1558 | handle->lastlockmsm[j][i] = ll[count];
|
---|
| 1559 | }
|
---|
[4383] | 1560 | gnss->dataflags[num] |= (1LL<<cd.typeP);
|
---|
[2659] | 1561 | }
|
---|
| 1562 |
|
---|
| 1563 | gnss->measdata[num][cd.typeS] = cnr[count];
|
---|
| 1564 | gnss->dataflags[num] |= (1<<cd.typeS);
|
---|
| 1565 |
|
---|
| 1566 | if(dop[count] > -1.6384)
|
---|
| 1567 | {
|
---|
[2873] | 1568 | gnss->measdata[num][cd.typeD] = -(dop[count]
|
---|
[2849] | 1569 | +rdop[numsat])/wl;
|
---|
[4383] | 1570 | gnss->dataflags[num] |= (1LL<<cd.typeD);
|
---|
[2659] | 1571 | }
|
---|
| 1572 | break;
|
---|
| 1573 | case 6:
|
---|
[3581] | 1574 | if(psr[count] > -1.0/(1<<10))
|
---|
[2659] | 1575 | {
|
---|
[3581] | 1576 | gnss->measdata[num][cd.typeR] = psr[count]*LIGHTSPEED/1000.0
|
---|
[2659] | 1577 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0;
|
---|
[4383] | 1578 | gnss->dataflags[num] |= (1LL<<cd.typeR);
|
---|
[2659] | 1579 | }
|
---|
| 1580 |
|
---|
[3581] | 1581 | if(wl && cp[count] > -1.0/(1<<8))
|
---|
[2659] | 1582 | {
|
---|
[3725] | 1583 | gnss->measdata[num][cd.typeP] = cp[count]*LIGHTSPEED/1000.0/wl
|
---|
[2659] | 1584 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0/wl;
|
---|
| 1585 | if(handle->lastlockmsm[j][i] != ll[count])
|
---|
| 1586 | {
|
---|
| 1587 | gnss->dataflags2[num] |= cd.lock;
|
---|
| 1588 | handle->lastlockmsm[j][i] = ll[count];
|
---|
| 1589 | }
|
---|
[4383] | 1590 | gnss->dataflags[num] |= (1LL<<cd.typeP);
|
---|
[2659] | 1591 | }
|
---|
| 1592 |
|
---|
| 1593 | gnss->measdata[num][cd.typeS] = cnr[count];
|
---|
[4383] | 1594 | gnss->dataflags[num] |= (1LL<<cd.typeS);
|
---|
[2659] | 1595 | break;
|
---|
| 1596 | case 7:
|
---|
[3581] | 1597 | if(psr[count] > -1.0/(1<<10))
|
---|
[2659] | 1598 | {
|
---|
[3581] | 1599 | gnss->measdata[num][cd.typeR] = psr[count]*LIGHTSPEED/1000.0
|
---|
[2659] | 1600 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0;
|
---|
[4383] | 1601 | gnss->dataflags[num] |= (1LL<<cd.typeR);
|
---|
[2659] | 1602 | }
|
---|
| 1603 |
|
---|
[3581] | 1604 | if(wl && cp[count] > -1.0/(1<<8))
|
---|
[2659] | 1605 | {
|
---|
[3725] | 1606 | gnss->measdata[num][cd.typeP] = cp[count]*LIGHTSPEED/1000.0/wl
|
---|
[2659] | 1607 | +(rrmod[numsat]+rrint[numsat])*LIGHTSPEED/1000.0/wl;
|
---|
| 1608 | if(handle->lastlockmsm[j][i] != ll[count])
|
---|
| 1609 | {
|
---|
| 1610 | gnss->dataflags2[num] |= cd.lock;
|
---|
| 1611 | handle->lastlockmsm[j][i] = ll[count];
|
---|
| 1612 | }
|
---|
[4383] | 1613 | gnss->dataflags[num] |= (1LL<<cd.typeP);
|
---|
[2659] | 1614 | }
|
---|
| 1615 |
|
---|
| 1616 | gnss->measdata[num][cd.typeS] = cnr[count];
|
---|
[4383] | 1617 | gnss->dataflags[num] |= (1LL<<cd.typeS);
|
---|
[2659] | 1618 |
|
---|
| 1619 | if(dop[count] > -1.6384)
|
---|
| 1620 | {
|
---|
[2873] | 1621 | gnss->measdata[num][cd.typeD] = -(dop[count]
|
---|
[2849] | 1622 | +rdop[numsat])/wl;
|
---|
[4383] | 1623 | gnss->dataflags[num] |= (1LL<<cd.typeD);
|
---|
[2659] | 1624 | }
|
---|
| 1625 | break;
|
---|
| 1626 | }
|
---|
| 1627 | }
|
---|
| 1628 | }
|
---|
| 1629 | }
|
---|
| 1630 | }
|
---|
| 1631 | if(!syncf && !old)
|
---|
| 1632 | {
|
---|
| 1633 | handle->Data = *gnss;
|
---|
| 1634 | memset(gnss, 0, sizeof(*gnss));
|
---|
| 1635 | }
|
---|
| 1636 | if(!syncf || old)
|
---|
| 1637 | {
|
---|
[2668] | 1638 | if(!wasnoamb) /* not RINEX compatible without */
|
---|
[2659] | 1639 | ret = 1;
|
---|
| 1640 | else
|
---|
| 1641 | ret = 2;
|
---|
| 1642 | }
|
---|
| 1643 | #ifdef NO_RTCM3_MAIN
|
---|
| 1644 | else
|
---|
| 1645 | ret = type;
|
---|
| 1646 | #endif /* NO_RTCM3_MAIN */
|
---|
| 1647 | }
|
---|
| 1648 | break;
|
---|
[27] | 1649 | }
|
---|
| 1650 | }
|
---|
| 1651 | return ret;
|
---|
| 1652 | }
|
---|
| 1653 |
|
---|
| 1654 | struct Header
|
---|
| 1655 | {
|
---|
| 1656 | const char *version;
|
---|
| 1657 | const char *pgm;
|
---|
| 1658 | const char *marker;
|
---|
[503] | 1659 | const char *markertype;
|
---|
[27] | 1660 | const char *observer;
|
---|
| 1661 | const char *receiver;
|
---|
| 1662 | const char *antenna;
|
---|
| 1663 | const char *position;
|
---|
| 1664 | const char *antennaposition;
|
---|
| 1665 | const char *wavelength;
|
---|
| 1666 | const char *typesofobs; /* should not be modified outside */
|
---|
[502] | 1667 | const char *typesofobsG; /* should not be modified outside */
|
---|
| 1668 | const char *typesofobsR; /* should not be modified outside */
|
---|
| 1669 | const char *typesofobsS; /* should not be modified outside */
|
---|
[2699] | 1670 | const char *typesofobsE; /* should not be modified outside */
|
---|
[4367] | 1671 | const char *typesofobsC; /* should not be modified outside */
|
---|
| 1672 | const char *typesofobsJ; /* should not be modified outside */
|
---|
[27] | 1673 | const char *timeoffirstobs; /* should not be modified outside */
|
---|
| 1674 | };
|
---|
| 1675 |
|
---|
| 1676 | #define MAXHEADERLINES 50
|
---|
| 1677 | #define MAXHEADERBUFFERSIZE 4096
|
---|
| 1678 | struct HeaderData
|
---|
| 1679 | {
|
---|
| 1680 | union
|
---|
| 1681 | {
|
---|
| 1682 | struct Header named;
|
---|
| 1683 | const char *unnamed[MAXHEADERLINES];
|
---|
| 1684 | } data;
|
---|
| 1685 | int numheaders;
|
---|
| 1686 | };
|
---|
| 1687 |
|
---|
[1092] | 1688 | void converttime(struct converttimeinfo *c, int week, int tow)
|
---|
[270] | 1689 | {
|
---|
| 1690 | int i, k, doy, j; /* temporary variables */
|
---|
| 1691 | j = week*(7*24*60*60) + tow + 5*24*60*60;
|
---|
| 1692 | for(i = 1980; j >= (k = (365+longyear(i,0))*24*60*60); ++i)
|
---|
| 1693 | j -= k;
|
---|
| 1694 | c->year = i;
|
---|
| 1695 | doy = 1+ (j / (24*60*60));
|
---|
| 1696 | j %= (24*60*60);
|
---|
| 1697 | c->hour = j / (60*60);
|
---|
| 1698 | j %= (60*60);
|
---|
| 1699 | c->minute = j / 60;
|
---|
| 1700 | c->second = j % 60;
|
---|
| 1701 | j = 0;
|
---|
| 1702 | for(i = 1; j + (k = months[i] + longyear(c->year,i)) < doy; ++i)
|
---|
| 1703 | j += k;
|
---|
| 1704 | c->month = i;
|
---|
| 1705 | c->day = doy - j;
|
---|
| 1706 | }
|
---|
| 1707 |
|
---|
[318] | 1708 | #ifndef NO_RTCM3_MAIN
|
---|
| 1709 | void RTCM3Error(const char *fmt, ...)
|
---|
| 1710 | {
|
---|
| 1711 | va_list v;
|
---|
| 1712 | va_start(v, fmt);
|
---|
| 1713 | vfprintf(stderr, fmt, v);
|
---|
| 1714 | va_end(v);
|
---|
| 1715 | }
|
---|
| 1716 | #endif
|
---|
| 1717 |
|
---|
| 1718 | void RTCM3Text(const char *fmt, ...)
|
---|
| 1719 | {
|
---|
| 1720 | va_list v;
|
---|
| 1721 | va_start(v, fmt);
|
---|
| 1722 | vprintf(fmt, v);
|
---|
| 1723 | va_end(v);
|
---|
| 1724 | }
|
---|
| 1725 |
|
---|
[2487] | 1726 | static void fixrevision(void)
|
---|
| 1727 | {
|
---|
| 1728 | if(revisionstr[0] == '$')
|
---|
| 1729 | {
|
---|
| 1730 | char *a;
|
---|
| 1731 | int i=sizeof(RTCM3TORINEX_VERSION); /* set version to 1.<revision> */
|
---|
| 1732 | strcpy(revisionstr, RTCM3TORINEX_VERSION ".");
|
---|
| 1733 | for(a = revisionstr+11; *a && *a != ' '; ++a)
|
---|
| 1734 | revisionstr[i++] = *a;
|
---|
| 1735 | revisionstr[i] = 0;
|
---|
| 1736 | }
|
---|
| 1737 | }
|
---|
| 1738 |
|
---|
[503] | 1739 | static int HandleRunBy(char *buffer, int buffersize, const char **u,
|
---|
| 1740 | int rinex3)
|
---|
[502] | 1741 | {
|
---|
| 1742 | const char *user;
|
---|
| 1743 | time_t t;
|
---|
| 1744 | struct tm * t2;
|
---|
| 1745 |
|
---|
| 1746 | #ifdef NO_RTCM3_MAIN
|
---|
[2487] | 1747 | fixrevision();
|
---|
[502] | 1748 | #endif
|
---|
| 1749 |
|
---|
| 1750 | user= getenv("USER");
|
---|
| 1751 | if(!user) user = "";
|
---|
| 1752 | t = time(&t);
|
---|
| 1753 | t2 = gmtime(&t);
|
---|
| 1754 | if(u) *u = user;
|
---|
| 1755 | return 1+snprintf(buffer, buffersize,
|
---|
[1088] | 1756 | rinex3 ?
|
---|
[4371] | 1757 | "RTCM3TORINEX %-7.7s%-20.20s%04d%02d%02d %02d%02d%02d UTC "
|
---|
[503] | 1758 | "PGM / RUN BY / DATE" :
|
---|
[4371] | 1759 | "RTCM3TORINEX %-7.7s%-20.20s%04d-%02d-%02d %02d:%02d "
|
---|
[502] | 1760 | "PGM / RUN BY / DATE", revisionstr, user, 1900+t2->tm_year,
|
---|
[503] | 1761 | t2->tm_mon+1, t2->tm_mday, t2->tm_hour, t2->tm_min, t2->tm_sec);
|
---|
[502] | 1762 | }
|
---|
| 1763 |
|
---|
[1092] | 1764 | #ifdef NO_RTCM3_MAIN
|
---|
| 1765 | #define NUMSTARTSKIP 1
|
---|
| 1766 | #else
|
---|
[318] | 1767 | #define NUMSTARTSKIP 3
|
---|
[1092] | 1768 | #endif
|
---|
| 1769 |
|
---|
[268] | 1770 | void HandleHeader(struct RTCM3ParserData *Parser)
|
---|
[27] | 1771 | {
|
---|
[1092] | 1772 | #ifdef NO_RTCM3_MAIN
|
---|
| 1773 | int i;
|
---|
[2502] | 1774 | if(Parser->allflags == 0)
|
---|
| 1775 | Parser->allflags = ~0;
|
---|
[1092] | 1776 | if(Parser->rinex3)
|
---|
| 1777 | {
|
---|
| 1778 | #define CHECKFLAGSNEW(a, b, c) \
|
---|
[2502] | 1779 | if(Parser->allflags & GNSSDF_##b##DATA) \
|
---|
[1092] | 1780 | { \
|
---|
[4372] | 1781 | Parser->info[RTCM3_MSM_##a].flags[Parser->info[RTCM3_MSM_GPS].numtypes] = GNSSDF_##b##DATA; \
|
---|
| 1782 | Parser->info[RTCM3_MSM_##a].pos[Parser->info[RTCM3_MSM_GPS].numtypes] = GNSSENTRY_##b##DATA; \
|
---|
| 1783 | ++Parser->info[RTCM3_MSM_##a].numtypes; \
|
---|
[1092] | 1784 | }
|
---|
| 1785 |
|
---|
| 1786 | CHECKFLAGSNEW(GPS, C1, C1C)
|
---|
| 1787 | CHECKFLAGSNEW(GPS, L1C, L1C)
|
---|
| 1788 | CHECKFLAGSNEW(GPS, D1C, D1C)
|
---|
| 1789 | CHECKFLAGSNEW(GPS, S1C, S1C)
|
---|
| 1790 | CHECKFLAGSNEW(GPS, P1, C1P)
|
---|
| 1791 | CHECKFLAGSNEW(GPS, L1P, L1P)
|
---|
| 1792 | CHECKFLAGSNEW(GPS, D1P, D1P)
|
---|
| 1793 | CHECKFLAGSNEW(GPS, S1P, S1P)
|
---|
| 1794 | CHECKFLAGSNEW(GPS, P2, C2P)
|
---|
| 1795 | CHECKFLAGSNEW(GPS, L2P, L2P)
|
---|
| 1796 | CHECKFLAGSNEW(GPS, D2P, D2P)
|
---|
| 1797 | CHECKFLAGSNEW(GPS, S2P, S2P)
|
---|
| 1798 | CHECKFLAGSNEW(GPS, C2, C2X)
|
---|
| 1799 | CHECKFLAGSNEW(GPS, L2C, L2X)
|
---|
| 1800 | CHECKFLAGSNEW(GPS, D2C, D2X)
|
---|
| 1801 | CHECKFLAGSNEW(GPS, S2C, S2X)
|
---|
[4372] | 1802 | CHECKFLAGSNEW(GLONASS, C1, C1C)
|
---|
| 1803 | CHECKFLAGSNEW(GLONASS, L1C, L1C)
|
---|
| 1804 | CHECKFLAGSNEW(GLONASS, D1C, D1C)
|
---|
| 1805 | CHECKFLAGSNEW(GLONASS, S1C, S1C)
|
---|
| 1806 | CHECKFLAGSNEW(GLONASS, P1, C1P)
|
---|
| 1807 | CHECKFLAGSNEW(GLONASS, L1P, L1P)
|
---|
| 1808 | CHECKFLAGSNEW(GLONASS, D1P, D1P)
|
---|
| 1809 | CHECKFLAGSNEW(GLONASS, S1P, S1P)
|
---|
| 1810 | CHECKFLAGSNEW(GLONASS, P2, C2P)
|
---|
| 1811 | CHECKFLAGSNEW(GLONASS, L2P, L2P)
|
---|
| 1812 | CHECKFLAGSNEW(GLONASS, D2P, D2P)
|
---|
| 1813 | CHECKFLAGSNEW(GLONASS, S2P, S2P)
|
---|
| 1814 | CHECKFLAGSNEW(GLONASS, C2, C2C)
|
---|
| 1815 | CHECKFLAGSNEW(GLONASS, L2C, L2C)
|
---|
| 1816 | CHECKFLAGSNEW(GLONASS, D2C, D2C)
|
---|
| 1817 | CHECKFLAGSNEW(GLONASS, S2C, S2C)
|
---|
[1092] | 1818 | }
|
---|
| 1819 | else
|
---|
| 1820 | {
|
---|
| 1821 | #define CHECKFLAGS(a, b) \
|
---|
[2502] | 1822 | if(Parser->allflags & GNSSDF_##a##DATA) \
|
---|
[1092] | 1823 | { \
|
---|
| 1824 | if(data[RINEXENTRY_##b##DATA]) \
|
---|
| 1825 | { \
|
---|
[4371] | 1826 | Parser->info[RTCM3_MSM_GPS].flags[data[RINEXENTRY_##b##DATA]-1] = GNSSDF_##a##DATA; \
|
---|
| 1827 | Parser->info[RTCM3_MSM_GPS].pos[data[RINEXENTRY_##b##DATA]-1] = GNSSENTRY_##a##DATA; \
|
---|
[1092] | 1828 | } \
|
---|
| 1829 | else \
|
---|
| 1830 | { \
|
---|
[4372] | 1831 | Parser->flags[Parser->info[RTCM3_MSM_GPS].numtypes] = GNSSDF_##a##DATA; \
|
---|
| 1832 | Parser->pos[Parser->info[RTCM3_MSM_GPS].numtypes] = GNSSENTRY_##a##DATA; \
|
---|
[4371] | 1833 | data[RINEXENTRY_##b##DATA] = ++Parser->info[RTCM3_MSM_GPS].numtypes; \
|
---|
[1092] | 1834 | } \
|
---|
| 1835 | }
|
---|
| 1836 |
|
---|
| 1837 | int data[RINEXENTRY_NUMBER];
|
---|
| 1838 | for(i = 0; i < RINEXENTRY_NUMBER; ++i) data[i] = 0;
|
---|
| 1839 |
|
---|
| 1840 | CHECKFLAGS(C1,C1)
|
---|
| 1841 | CHECKFLAGS(C2,C2)
|
---|
| 1842 | CHECKFLAGS(P1,P1)
|
---|
| 1843 | CHECKFLAGS(P2,P2)
|
---|
| 1844 | CHECKFLAGS(L1C,L1)
|
---|
| 1845 | CHECKFLAGS(L1P,L1)
|
---|
| 1846 | CHECKFLAGS(L2C,L2)
|
---|
| 1847 | CHECKFLAGS(L2P,L2)
|
---|
| 1848 | CHECKFLAGS(D1C,D1)
|
---|
| 1849 | CHECKFLAGS(D1P,D1)
|
---|
| 1850 | CHECKFLAGS(D2C,D2)
|
---|
| 1851 | CHECKFLAGS(D2P,D2)
|
---|
| 1852 | CHECKFLAGS(S1C,S1)
|
---|
| 1853 | CHECKFLAGS(S1P,S1)
|
---|
| 1854 | CHECKFLAGS(S2C,S2)
|
---|
| 1855 | CHECKFLAGS(S2P,S2)
|
---|
[2659] | 1856 | CHECKFLAGS(C5,C5)
|
---|
| 1857 | CHECKFLAGS(L5,L5)
|
---|
| 1858 | CHECKFLAGS(D5,D5)
|
---|
| 1859 | CHECKFLAGS(S5,S5)
|
---|
[4367] | 1860 | CHECKFLAGS(C5AB,C8)
|
---|
| 1861 | CHECKFLAGS(L5AB,L8)
|
---|
| 1862 | CHECKFLAGS(D5AB,D8)
|
---|
| 1863 | CHECKFLAGS(S5AB,S8)
|
---|
| 1864 | CHECKFLAGS(C5B,C7)
|
---|
| 1865 | CHECKFLAGS(L5B,L7)
|
---|
| 1866 | CHECKFLAGS(D5B,D7)
|
---|
| 1867 | CHECKFLAGS(S5B,S7)
|
---|
[2659] | 1868 | CHECKFLAGS(C6,C6)
|
---|
| 1869 | CHECKFLAGS(L6,L6)
|
---|
| 1870 | CHECKFLAGS(D6,D6)
|
---|
| 1871 | CHECKFLAGS(S6,S6)
|
---|
[1092] | 1872 | }
|
---|
| 1873 | #else /* NO_RTCM3_MAIN */
|
---|
[27] | 1874 | struct HeaderData hdata;
|
---|
| 1875 | char thebuffer[MAXHEADERBUFFERSIZE];
|
---|
| 1876 | char *buffer = thebuffer;
|
---|
[318] | 1877 | size_t buffersize = sizeof(thebuffer);
|
---|
[27] | 1878 | int i;
|
---|
| 1879 |
|
---|
[549] | 1880 | memset(&hdata, 0, sizeof(hdata));
|
---|
| 1881 |
|
---|
[502] | 1882 | hdata.data.named.version = buffer;
|
---|
| 1883 | i = 1+snprintf(buffer, buffersize,
|
---|
| 1884 | "%9.2f OBSERVATION DATA M (Mixed)"
|
---|
| 1885 | " RINEX VERSION / TYPE", Parser->rinex3 ? 3.0 : 2.11);
|
---|
| 1886 | buffer += i; buffersize -= i;
|
---|
[27] | 1887 |
|
---|
| 1888 | {
|
---|
[30] | 1889 | const char *str;
|
---|
[27] | 1890 | hdata.data.named.pgm = buffer;
|
---|
[503] | 1891 | i = HandleRunBy(buffer, buffersize, &str, Parser->rinex3);
|
---|
[27] | 1892 | buffer += i; buffersize -= i;
|
---|
| 1893 | hdata.data.named.observer = buffer;
|
---|
| 1894 | i = 1+snprintf(buffer, buffersize,
|
---|
| 1895 | "%-20.20s "
|
---|
| 1896 | "OBSERVER / AGENCY", str);
|
---|
| 1897 | buffer += i; buffersize -= i;
|
---|
| 1898 | }
|
---|
| 1899 |
|
---|
| 1900 | hdata.data.named.marker =
|
---|
| 1901 | "RTCM3TORINEX "
|
---|
| 1902 | "MARKER NAME";
|
---|
| 1903 |
|
---|
[503] | 1904 | hdata.data.named.markertype = !Parser->rinex3 ? 0 :
|
---|
| 1905 | "GEODETIC "
|
---|
| 1906 | "MARKER TYPE";
|
---|
| 1907 |
|
---|
[27] | 1908 | hdata.data.named.receiver =
|
---|
| 1909 | " "
|
---|
| 1910 | "REC # / TYPE / VERS";
|
---|
| 1911 |
|
---|
| 1912 | hdata.data.named.antenna =
|
---|
| 1913 | " "
|
---|
| 1914 | "ANT # / TYPE";
|
---|
| 1915 |
|
---|
| 1916 | hdata.data.named.position =
|
---|
| 1917 | " .0000 .0000 .0000 "
|
---|
| 1918 | "APPROX POSITION XYZ";
|
---|
| 1919 |
|
---|
| 1920 | hdata.data.named.antennaposition =
|
---|
| 1921 | " .0000 .0000 .0000 "
|
---|
| 1922 | "ANTENNA: DELTA H/E/N";
|
---|
[744] | 1923 |
|
---|
[502] | 1924 | hdata.data.named.wavelength = Parser->rinex3 ? 0 :
|
---|
[27] | 1925 | " 1 1 "
|
---|
| 1926 | "WAVELENGTH FACT L1/2";
|
---|
| 1927 |
|
---|
[4367] | 1928 | hdata.numheaders = 18;
|
---|
| 1929 |
|
---|
[502] | 1930 | if(Parser->rinex3)
|
---|
[27] | 1931 | {
|
---|
[502] | 1932 | #define CHECKFLAGSNEW(a, b, c) \
|
---|
| 1933 | if(flags & GNSSDF_##b##DATA) \
|
---|
| 1934 | { \
|
---|
[4371] | 1935 | Parser->info[RTCM3_MSM_##a].flags[Parser->info[RTCM3_MSM_##a].numtypes] \
|
---|
| 1936 | = GNSSDF_##b##DATA; \
|
---|
| 1937 | Parser->info[RTCM3_MSM_##a].pos[Parser->info[RTCM3_MSM_##a].numtypes] \
|
---|
| 1938 | = GNSSENTRY_##b##DATA; \
|
---|
| 1939 | ++Parser->info[RTCM3_MSM_##a].numtypes; \
|
---|
| 1940 | if(Parser->info[RTCM3_MSM_##a].type[GNSSENTRY_##b##DATA]) \
|
---|
| 1941 | snprintf(tbuffer+tbufferpos, sizeof(tbuffer)-tbufferpos, " %-2.2s%c", #c,\
|
---|
| 1942 | Parser->info[RTCM3_MSM_##a].type[GNSSENTRY_##b##DATA]); \
|
---|
| 1943 | else \
|
---|
| 1944 | snprintf(tbuffer+tbufferpos, sizeof(tbuffer)-tbufferpos, " %-3s", #c); \
|
---|
[502] | 1945 | tbufferpos += 4; \
|
---|
| 1946 | }
|
---|
| 1947 |
|
---|
| 1948 | int flags = Parser->startflags;
|
---|
| 1949 | char tbuffer[6*RINEXENTRY_NUMBER+1];
|
---|
| 1950 | int tbufferpos = 0;
|
---|
| 1951 | for(i = 0; i < Parser->Data.numsats; ++i)
|
---|
| 1952 | flags |= Parser->Data.dataflags[i];
|
---|
| 1953 |
|
---|
[4371] | 1954 | CHECKFLAGSNEW(SBAS, C1, C1C)
|
---|
| 1955 | CHECKFLAGSNEW(SBAS, L1C, L1C)
|
---|
| 1956 | CHECKFLAGSNEW(SBAS, D1C, D1C)
|
---|
| 1957 | CHECKFLAGSNEW(SBAS, S1C, S1C)
|
---|
| 1958 | CHECKFLAGSNEW(SBAS, P1, C1W)
|
---|
| 1959 | CHECKFLAGSNEW(SBAS, L1P, L1W)
|
---|
| 1960 | CHECKFLAGSNEW(SBAS, D1P, D1W)
|
---|
| 1961 | CHECKFLAGSNEW(SBAS, S1P, S1W)
|
---|
| 1962 | CHECKFLAGSNEW(SBAS, C5, C5)
|
---|
| 1963 | CHECKFLAGSNEW(SBAS, L5, L5)
|
---|
| 1964 | CHECKFLAGSNEW(SBAS, D5, D5)
|
---|
| 1965 | CHECKFLAGSNEW(SBAS, S5, S5)
|
---|
| 1966 |
|
---|
| 1967 | hdata.data.named.typesofobsS = buffer;
|
---|
| 1968 | i = 1+snprintf(buffer, buffersize,
|
---|
| 1969 | "S %3d%-52.52s SYS / # / OBS TYPES", Parser->info[RTCM3_MSM_SBAS].numtypes, tbuffer);
|
---|
| 1970 | buffer += i; buffersize -= i;
|
---|
| 1971 |
|
---|
[4374] | 1972 | tbufferpos = 0;
|
---|
| 1973 |
|
---|
[502] | 1974 | CHECKFLAGSNEW(GPS, C1, C1C)
|
---|
| 1975 | CHECKFLAGSNEW(GPS, L1C, L1C)
|
---|
| 1976 | CHECKFLAGSNEW(GPS, D1C, D1C)
|
---|
| 1977 | CHECKFLAGSNEW(GPS, S1C, S1C)
|
---|
[2699] | 1978 | CHECKFLAGSNEW(GPS, P1, C1W)
|
---|
| 1979 | CHECKFLAGSNEW(GPS, L1P, L1W)
|
---|
| 1980 | CHECKFLAGSNEW(GPS, D1P, D1W)
|
---|
| 1981 | CHECKFLAGSNEW(GPS, S1P, S1W)
|
---|
[4367] | 1982 | CHECKFLAGSNEW(GPS, C5, C5)
|
---|
| 1983 | CHECKFLAGSNEW(GPS, L5, L5)
|
---|
| 1984 | CHECKFLAGSNEW(GPS, D5, D5)
|
---|
| 1985 | CHECKFLAGSNEW(GPS, S5, S5)
|
---|
[4383] | 1986 | CHECKFLAGSNEW(GPS, P2, C2W)
|
---|
| 1987 | CHECKFLAGSNEW(GPS, L2P, L2W)
|
---|
| 1988 | CHECKFLAGSNEW(GPS, D2P, D2W)
|
---|
| 1989 | CHECKFLAGSNEW(GPS, S2P, S2W)
|
---|
| 1990 | CHECKFLAGSNEW(GPS, C2, C2)
|
---|
| 1991 | CHECKFLAGSNEW(GPS, L2C, L2)
|
---|
| 1992 | CHECKFLAGSNEW(GPS, D2C, D2)
|
---|
| 1993 | CHECKFLAGSNEW(GPS, S2C, S2)
|
---|
[4371] | 1994 | CHECKFLAGSNEW(GPS, C1N, C1)
|
---|
| 1995 | CHECKFLAGSNEW(GPS, L1N, L1)
|
---|
| 1996 | CHECKFLAGSNEW(GPS, D1N, D1)
|
---|
| 1997 | CHECKFLAGSNEW(GPS, S1N, S1)
|
---|
[502] | 1998 |
|
---|
| 1999 | hdata.data.named.typesofobsG = buffer;
|
---|
| 2000 | i = 1+snprintf(buffer, buffersize,
|
---|
[4371] | 2001 | "G %3d%-52.52s SYS / # / OBS TYPES", Parser->info[RTCM3_MSM_GPS].numtypes, tbuffer);
|
---|
| 2002 | if(Parser->info[RTCM3_MSM_GPS].numtypes>13)
|
---|
[502] | 2003 | {
|
---|
| 2004 | i += snprintf(buffer+i-1, buffersize,
|
---|
| 2005 | "\n %-52.52s SYS / # / OBS TYPES", tbuffer+13*4);
|
---|
| 2006 | }
|
---|
| 2007 | buffer += i; buffersize -= i;
|
---|
| 2008 |
|
---|
| 2009 | tbufferpos = 0;
|
---|
| 2010 |
|
---|
[4371] | 2011 | CHECKFLAGSNEW(GLONASS, C1, C1C)
|
---|
| 2012 | CHECKFLAGSNEW(GLONASS, L1C, L1C)
|
---|
| 2013 | CHECKFLAGSNEW(GLONASS, D1C, D1C)
|
---|
| 2014 | CHECKFLAGSNEW(GLONASS, S1C, S1C)
|
---|
| 2015 | CHECKFLAGSNEW(GLONASS, P1, C1P)
|
---|
| 2016 | CHECKFLAGSNEW(GLONASS, L1P, L1P)
|
---|
| 2017 | CHECKFLAGSNEW(GLONASS, D1P, D1P)
|
---|
| 2018 | CHECKFLAGSNEW(GLONASS, S1P, S1P)
|
---|
| 2019 | CHECKFLAGSNEW(GLONASS, P2, C2P)
|
---|
| 2020 | CHECKFLAGSNEW(GLONASS, L2P, L2P)
|
---|
| 2021 | CHECKFLAGSNEW(GLONASS, D2P, D2P)
|
---|
| 2022 | CHECKFLAGSNEW(GLONASS, S2P, S2P)
|
---|
| 2023 | CHECKFLAGSNEW(GLONASS, C2, C2C)
|
---|
| 2024 | CHECKFLAGSNEW(GLONASS, L2C, L2C)
|
---|
| 2025 | CHECKFLAGSNEW(GLONASS, D2C, D2C)
|
---|
| 2026 | CHECKFLAGSNEW(GLONASS, S2C, S2C)
|
---|
[502] | 2027 |
|
---|
| 2028 | hdata.data.named.typesofobsR = buffer;
|
---|
| 2029 | i = 1+snprintf(buffer, buffersize,
|
---|
[4371] | 2030 | "R %3d%-52.52s SYS / # / OBS TYPES", Parser->info[RTCM3_MSM_GLONASS].numtypes, tbuffer);
|
---|
| 2031 | if(Parser->info[RTCM3_MSM_GLONASS].numtypes>13)
|
---|
[502] | 2032 | {
|
---|
| 2033 | i += snprintf(buffer+i-1, buffersize,
|
---|
| 2034 | "\n %-52.52s SYS / # / OBS TYPES", tbuffer+13*4);
|
---|
| 2035 | }
|
---|
| 2036 | buffer += i; buffersize -= i;
|
---|
[2699] | 2037 |
|
---|
| 2038 | tbufferpos = 0;
|
---|
| 2039 |
|
---|
[4371] | 2040 | CHECKFLAGSNEW(GALILEO, C1, C1)
|
---|
| 2041 | CHECKFLAGSNEW(GALILEO, L1C, L1)
|
---|
| 2042 | CHECKFLAGSNEW(GALILEO, D1C, D1)
|
---|
| 2043 | CHECKFLAGSNEW(GALILEO, S1C, S1)
|
---|
| 2044 | CHECKFLAGSNEW(GALILEO, C6, C6)
|
---|
| 2045 | CHECKFLAGSNEW(GALILEO, L6, L6)
|
---|
| 2046 | CHECKFLAGSNEW(GALILEO, D6, D6)
|
---|
| 2047 | CHECKFLAGSNEW(GALILEO, S6, S6)
|
---|
| 2048 | CHECKFLAGSNEW(GALILEO, C5, C5)
|
---|
| 2049 | CHECKFLAGSNEW(GALILEO, L5, L5)
|
---|
| 2050 | CHECKFLAGSNEW(GALILEO, D5, D5)
|
---|
| 2051 | CHECKFLAGSNEW(GALILEO, S5, S5)
|
---|
| 2052 | CHECKFLAGSNEW(GALILEO, C5B, C7)
|
---|
| 2053 | CHECKFLAGSNEW(GALILEO, L5B, L7)
|
---|
| 2054 | CHECKFLAGSNEW(GALILEO, D5B, D7)
|
---|
| 2055 | CHECKFLAGSNEW(GALILEO, S5B, S7)
|
---|
| 2056 | CHECKFLAGSNEW(GALILEO, C5AB, C8)
|
---|
| 2057 | CHECKFLAGSNEW(GALILEO, L5AB, L8)
|
---|
| 2058 | CHECKFLAGSNEW(GALILEO, D5AB, D8)
|
---|
| 2059 | CHECKFLAGSNEW(GALILEO, S5AB, S8)
|
---|
[2699] | 2060 |
|
---|
| 2061 | hdata.data.named.typesofobsE = buffer;
|
---|
| 2062 | i = 1+snprintf(buffer, buffersize,
|
---|
[4371] | 2063 | "E %3d%-52.52s SYS / # / OBS TYPES", Parser->info[RTCM3_MSM_GALILEO].numtypes, tbuffer);
|
---|
| 2064 | if(Parser->info[RTCM3_MSM_GALILEO].numtypes>13)
|
---|
[2699] | 2065 | {
|
---|
| 2066 | i += snprintf(buffer+i-1, buffersize,
|
---|
| 2067 | "\n %-52.52s SYS / # / OBS TYPES", tbuffer+13*4);
|
---|
| 2068 | }
|
---|
| 2069 | buffer += i; buffersize -= i;
|
---|
[4367] | 2070 |
|
---|
| 2071 | tbufferpos = 0;
|
---|
| 2072 |
|
---|
[4371] | 2073 | CHECKFLAGSNEW(COMPASS, CB1, C2I)
|
---|
| 2074 | CHECKFLAGSNEW(COMPASS, LB1, L2I)
|
---|
| 2075 | CHECKFLAGSNEW(COMPASS, DB1, D2I)
|
---|
| 2076 | CHECKFLAGSNEW(COMPASS, SB1, S2I)
|
---|
| 2077 | CHECKFLAGSNEW(COMPASS, CB2, C7I)
|
---|
| 2078 | CHECKFLAGSNEW(COMPASS, LB2, L7I)
|
---|
| 2079 | CHECKFLAGSNEW(COMPASS, DB2, D7I)
|
---|
| 2080 | CHECKFLAGSNEW(COMPASS, SB2, S7I)
|
---|
| 2081 | CHECKFLAGSNEW(COMPASS, CB3, C6I)
|
---|
| 2082 | CHECKFLAGSNEW(COMPASS, LB3, L6I)
|
---|
| 2083 | CHECKFLAGSNEW(COMPASS, DB3, D6I)
|
---|
| 2084 | CHECKFLAGSNEW(COMPASS, SB3, S6I)
|
---|
[4367] | 2085 |
|
---|
| 2086 | hdata.data.named.typesofobsC = buffer;
|
---|
| 2087 | i = 1+snprintf(buffer, buffersize,
|
---|
[4371] | 2088 | "C %3d%-52.52s SYS / # / OBS TYPES", Parser->info[RTCM3_MSM_COMPASS].numtypes, tbuffer);
|
---|
| 2089 | if(Parser->info[RTCM3_MSM_COMPASS].numtypes>13)
|
---|
[4367] | 2090 | {
|
---|
| 2091 | i += snprintf(buffer+i-1, buffersize,
|
---|
| 2092 | "\n %-52.52s SYS / # / OBS TYPES", tbuffer+13*4);
|
---|
| 2093 | }
|
---|
| 2094 | buffer += i; buffersize -= i;
|
---|
| 2095 |
|
---|
| 2096 | tbufferpos = 0;
|
---|
| 2097 |
|
---|
[4371] | 2098 | CHECKFLAGSNEW(QZSS, C1, C1C)
|
---|
| 2099 | CHECKFLAGSNEW(QZSS, L1C, L1C)
|
---|
| 2100 | CHECKFLAGSNEW(QZSS, D1C, D1C)
|
---|
| 2101 | CHECKFLAGSNEW(QZSS, S1C, S1C)
|
---|
[4367] | 2102 |
|
---|
[4371] | 2103 | CHECKFLAGSNEW(QZSS, CSAIF, C1Z)
|
---|
| 2104 | CHECKFLAGSNEW(QZSS, LSAIF, L1Z)
|
---|
| 2105 | CHECKFLAGSNEW(QZSS, DSAIF, D1Z)
|
---|
| 2106 | CHECKFLAGSNEW(QZSS, SSAIF, S1Z)
|
---|
[4367] | 2107 |
|
---|
[4371] | 2108 | CHECKFLAGSNEW(QZSS, C1N, C1)
|
---|
| 2109 | CHECKFLAGSNEW(QZSS, L1N, L1)
|
---|
| 2110 | CHECKFLAGSNEW(QZSS, D1N, D1)
|
---|
| 2111 | CHECKFLAGSNEW(QZSS, S1N, S1)
|
---|
[4367] | 2112 |
|
---|
[4371] | 2113 | CHECKFLAGSNEW(QZSS, C6, C6)
|
---|
| 2114 | CHECKFLAGSNEW(QZSS, L6, L6)
|
---|
| 2115 | CHECKFLAGSNEW(QZSS, D6, D6)
|
---|
| 2116 | CHECKFLAGSNEW(QZSS, S6, S6)
|
---|
[4367] | 2117 |
|
---|
[4371] | 2118 | CHECKFLAGSNEW(QZSS, C2, C2)
|
---|
| 2119 | CHECKFLAGSNEW(QZSS, L2C, L2)
|
---|
| 2120 | CHECKFLAGSNEW(QZSS, D2C, D2)
|
---|
| 2121 | CHECKFLAGSNEW(QZSS, S2C, S2)
|
---|
[4367] | 2122 |
|
---|
[4371] | 2123 | CHECKFLAGSNEW(QZSS, C5, C5)
|
---|
| 2124 | CHECKFLAGSNEW(QZSS, L5, L5)
|
---|
| 2125 | CHECKFLAGSNEW(QZSS, D5, D5)
|
---|
| 2126 | CHECKFLAGSNEW(QZSS, S5, S5)
|
---|
[4367] | 2127 |
|
---|
| 2128 | hdata.data.named.typesofobsJ = buffer;
|
---|
| 2129 | i = 1+snprintf(buffer, buffersize,
|
---|
[4371] | 2130 | "J %3d%-52.52s SYS / # / OBS TYPES", Parser->info[RTCM3_MSM_QZSS].numtypes, tbuffer);
|
---|
| 2131 | if(Parser->info[RTCM3_MSM_QZSS].numtypes>13)
|
---|
[4367] | 2132 | {
|
---|
| 2133 | i += snprintf(buffer+i-1, buffersize,
|
---|
| 2134 | "\n %-52.52s SYS / # / OBS TYPES", tbuffer+13*4);
|
---|
| 2135 | }
|
---|
| 2136 | buffer += i; buffersize -= i;
|
---|
[502] | 2137 | }
|
---|
| 2138 | else
|
---|
| 2139 | {
|
---|
[27] | 2140 | #define CHECKFLAGS(a, b) \
|
---|
[363] | 2141 | if(flags & GNSSDF_##a##DATA) \
|
---|
[27] | 2142 | { \
|
---|
[363] | 2143 | if(data[RINEXENTRY_##b##DATA]) \
|
---|
| 2144 | { \
|
---|
[4371] | 2145 | Parser->info[RTCM3_MSM_GPS].flags[data[RINEXENTRY_##b##DATA]-1] = GNSSDF_##a##DATA; \
|
---|
| 2146 | Parser->info[RTCM3_MSM_GPS].pos[data[RINEXENTRY_##b##DATA]-1] = GNSSENTRY_##a##DATA; \
|
---|
[363] | 2147 | } \
|
---|
| 2148 | else \
|
---|
| 2149 | { \
|
---|
[4371] | 2150 | Parser->flags[Parser->info[RTCM3_MSM_GPS].numtypes] = GNSSDF_##a##DATA; \
|
---|
| 2151 | Parser->pos[Parser->info[RTCM3_MSM_GPS].numtypes] = GNSSENTRY_##a##DATA; \
|
---|
| 2152 | data[RINEXENTRY_##b##DATA] = ++Parser->info[RTCM3_MSM_GPS].numtypes; \
|
---|
[364] | 2153 | snprintf(tbuffer+tbufferpos, sizeof(tbuffer)-tbufferpos, " "#b); \
|
---|
| 2154 | tbufferpos += 6; \
|
---|
[363] | 2155 | } \
|
---|
[27] | 2156 | }
|
---|
| 2157 |
|
---|
[318] | 2158 | int flags = Parser->startflags;
|
---|
[27] | 2159 | int data[RINEXENTRY_NUMBER];
|
---|
| 2160 | char tbuffer[6*RINEXENTRY_NUMBER+1];
|
---|
| 2161 | int tbufferpos = 0;
|
---|
| 2162 | for(i = 0; i < RINEXENTRY_NUMBER; ++i)
|
---|
| 2163 | data[i] = 0;
|
---|
| 2164 | for(i = 0; i < Parser->Data.numsats; ++i)
|
---|
| 2165 | flags |= Parser->Data.dataflags[i];
|
---|
| 2166 |
|
---|
| 2167 | CHECKFLAGS(C1,C1)
|
---|
| 2168 | CHECKFLAGS(C2,C2)
|
---|
| 2169 | CHECKFLAGS(P1,P1)
|
---|
| 2170 | CHECKFLAGS(P2,P2)
|
---|
| 2171 | CHECKFLAGS(L1C,L1)
|
---|
| 2172 | CHECKFLAGS(L1P,L1)
|
---|
| 2173 | CHECKFLAGS(L2C,L2)
|
---|
| 2174 | CHECKFLAGS(L2P,L2)
|
---|
| 2175 | CHECKFLAGS(D1C,D1)
|
---|
| 2176 | CHECKFLAGS(D1P,D1)
|
---|
| 2177 | CHECKFLAGS(D2C,D2)
|
---|
| 2178 | CHECKFLAGS(D2P,D2)
|
---|
| 2179 | CHECKFLAGS(S1C,S1)
|
---|
| 2180 | CHECKFLAGS(S1P,S1)
|
---|
| 2181 | CHECKFLAGS(S2C,S2)
|
---|
| 2182 | CHECKFLAGS(S2P,S2)
|
---|
[2659] | 2183 | CHECKFLAGS(C5,C5)
|
---|
| 2184 | CHECKFLAGS(L5,L5)
|
---|
| 2185 | CHECKFLAGS(D5,D5)
|
---|
| 2186 | CHECKFLAGS(S5,S5)
|
---|
[4367] | 2187 | CHECKFLAGS(C5AB,C8)
|
---|
| 2188 | CHECKFLAGS(L5AB,L8)
|
---|
| 2189 | CHECKFLAGS(D5AB,D8)
|
---|
| 2190 | CHECKFLAGS(S5AB,S8)
|
---|
| 2191 | CHECKFLAGS(C5B,C7)
|
---|
| 2192 | CHECKFLAGS(L5B,L7)
|
---|
| 2193 | CHECKFLAGS(D5B,D7)
|
---|
| 2194 | CHECKFLAGS(S5B,S7)
|
---|
[2659] | 2195 | CHECKFLAGS(C6,C6)
|
---|
| 2196 | CHECKFLAGS(L6,L6)
|
---|
| 2197 | CHECKFLAGS(D6,D6)
|
---|
| 2198 | CHECKFLAGS(S6,S6)
|
---|
[4369] | 2199 | /* Skip C1N and SAIF for RINEX2! */
|
---|
[27] | 2200 |
|
---|
| 2201 | hdata.data.named.typesofobs = buffer;
|
---|
| 2202 | i = 1+snprintf(buffer, buffersize,
|
---|
[4371] | 2203 | "%6d%-54.54s# / TYPES OF OBSERV", Parser->info[RTCM3_MSM_GPS].numtypes, tbuffer);
|
---|
| 2204 | if(Parser->info[RTCM3_MSM_GPS].numtypes>9)
|
---|
[27] | 2205 | {
|
---|
| 2206 | i += snprintf(buffer+i-1, buffersize,
|
---|
| 2207 | "\n %-54.54s# / TYPES OF OBSERV", tbuffer+9*6);
|
---|
| 2208 | }
|
---|
[4371] | 2209 | if(Parser->info[RTCM3_MSM_GPS].numtypes>18)
|
---|
[4367] | 2210 | {
|
---|
| 2211 | i += snprintf(buffer+i-1, buffersize,
|
---|
| 2212 | "\n %-54.54s# / TYPES OF OBSERV", tbuffer+18*6);
|
---|
| 2213 | }
|
---|
[27] | 2214 | buffer += i; buffersize -= i;
|
---|
| 2215 | }
|
---|
| 2216 |
|
---|
| 2217 | {
|
---|
| 2218 | struct converttimeinfo cti;
|
---|
| 2219 | converttime(&cti, Parser->Data.week,
|
---|
[268] | 2220 | (int)floor(Parser->Data.timeofweek/1000.0));
|
---|
[27] | 2221 | hdata.data.named.timeoffirstobs = buffer;
|
---|
[502] | 2222 | i = 1+snprintf(buffer, buffersize,
|
---|
[27] | 2223 | " %4d %2d %2d %2d %2d %10.7f GPS "
|
---|
[378] | 2224 | "TIME OF FIRST OBS", cti.year, cti.month, cti.day, cti.hour,
|
---|
[27] | 2225 | cti.minute, cti.second + fmod(Parser->Data.timeofweek/1000.0,1.0));
|
---|
| 2226 |
|
---|
| 2227 | buffer += i; buffersize -= i;
|
---|
| 2228 | }
|
---|
| 2229 |
|
---|
| 2230 | if(Parser->headerfile)
|
---|
| 2231 | {
|
---|
| 2232 | FILE *fh;
|
---|
| 2233 | if((fh = fopen(Parser->headerfile, "r")))
|
---|
| 2234 | {
|
---|
[318] | 2235 | size_t siz;
|
---|
[27] | 2236 | char *lastblockstart;
|
---|
| 2237 | if((siz = fread(buffer, 1, buffersize-1, fh)) > 0)
|
---|
| 2238 | {
|
---|
| 2239 | buffer[siz] = '\n';
|
---|
| 2240 | if(siz == buffersize)
|
---|
| 2241 | {
|
---|
[318] | 2242 | RTCM3Error("Header file is too large. Only %d bytes read.",
|
---|
[364] | 2243 | (int)siz);
|
---|
[27] | 2244 | }
|
---|
| 2245 | /* scan the file line by line and enter the entries in the list */
|
---|
| 2246 | /* warn for "# / TYPES OF OBSERV" and "TIME OF FIRST OBS" */
|
---|
| 2247 | /* overwrites entries, except for comments */
|
---|
| 2248 | lastblockstart = buffer;
|
---|
[318] | 2249 | for(i = 0; i < (int)siz; ++i)
|
---|
[27] | 2250 | {
|
---|
| 2251 | if(buffer[i] == '\n')
|
---|
| 2252 | { /* we found a line */
|
---|
| 2253 | char *end;
|
---|
| 2254 | while(buffer[i+1] == '\r')
|
---|
| 2255 | ++i; /* skip \r in case there are any */
|
---|
| 2256 | end = buffer+i;
|
---|
| 2257 | while(*end == '\t' || *end == ' ' || *end == '\r' || *end == '\n')
|
---|
| 2258 | *(end--) = 0;
|
---|
| 2259 | if(end-lastblockstart < 60+5) /* short line */
|
---|
[318] | 2260 | RTCM3Error("Short Header line '%s' ignored.\n", lastblockstart);
|
---|
[27] | 2261 | else
|
---|
| 2262 | {
|
---|
| 2263 | int pos;
|
---|
| 2264 | if(!strcmp("COMMENT", lastblockstart+60))
|
---|
| 2265 | pos = hdata.numheaders;
|
---|
| 2266 | else
|
---|
| 2267 | {
|
---|
| 2268 | for(pos = 0; pos < hdata.numheaders; ++pos)
|
---|
| 2269 | {
|
---|
| 2270 | if(!strcmp(hdata.data.unnamed[pos]+60, lastblockstart+60))
|
---|
| 2271 | break;
|
---|
| 2272 | }
|
---|
| 2273 | if(!strcmp("# / TYPES OF OBSERV", lastblockstart+60)
|
---|
| 2274 | || !strcmp("TIME OF FIRST OBS", lastblockstart+60))
|
---|
| 2275 | {
|
---|
[318] | 2276 | RTCM3Error("Overwriting header '%s' is dangerous.\n",
|
---|
[27] | 2277 | lastblockstart+60);
|
---|
| 2278 | }
|
---|
| 2279 | }
|
---|
| 2280 | if(pos >= MAXHEADERLINES)
|
---|
| 2281 | {
|
---|
[318] | 2282 | RTCM3Error("Maximum number of header lines of %d reached.\n",
|
---|
[27] | 2283 | MAXHEADERLINES);
|
---|
| 2284 | }
|
---|
| 2285 | else if(!strcmp("END OF HEADER", lastblockstart+60))
|
---|
| 2286 | {
|
---|
[318] | 2287 | RTCM3Error("End of header ignored.\n");
|
---|
[27] | 2288 | }
|
---|
| 2289 | else
|
---|
| 2290 | {
|
---|
| 2291 | hdata.data.unnamed[pos] = lastblockstart;
|
---|
| 2292 | if(pos == hdata.numheaders)
|
---|
| 2293 | ++hdata.numheaders;
|
---|
| 2294 | }
|
---|
| 2295 | }
|
---|
| 2296 | lastblockstart = buffer+i+1;
|
---|
| 2297 | }
|
---|
| 2298 | }
|
---|
| 2299 | }
|
---|
| 2300 | else
|
---|
| 2301 | {
|
---|
[318] | 2302 | RTCM3Error("Could not read data from headerfile '%s'.\n",
|
---|
[27] | 2303 | Parser->headerfile);
|
---|
| 2304 | }
|
---|
| 2305 | fclose(fh);
|
---|
| 2306 | }
|
---|
| 2307 | else
|
---|
| 2308 | {
|
---|
[318] | 2309 | RTCM3Error("Could not open header datafile '%s'.\n",
|
---|
[27] | 2310 | Parser->headerfile);
|
---|
| 2311 | }
|
---|
| 2312 | }
|
---|
| 2313 |
|
---|
| 2314 | for(i = 0; i < hdata.numheaders; ++i)
|
---|
[502] | 2315 | {
|
---|
| 2316 | if(hdata.data.unnamed[i] && hdata.data.unnamed[i][0])
|
---|
| 2317 | RTCM3Text("%s\n", hdata.data.unnamed[i]);
|
---|
| 2318 | }
|
---|
[318] | 2319 | RTCM3Text(" "
|
---|
[27] | 2320 | "END OF HEADER\n");
|
---|
[287] | 2321 | #endif
|
---|
[27] | 2322 | }
|
---|
| 2323 |
|
---|
[502] | 2324 | static void ConvLine(FILE *file, const char *fmt, ...)
|
---|
| 2325 | {
|
---|
| 2326 | char buffer[100], *b;
|
---|
| 2327 | va_list v;
|
---|
| 2328 | va_start(v, fmt);
|
---|
| 2329 | vsnprintf(buffer, sizeof(buffer), fmt, v);
|
---|
| 2330 | for(b = buffer; *b; ++b)
|
---|
| 2331 | {
|
---|
| 2332 | if(*b == 'e') *b = 'D';
|
---|
| 2333 | }
|
---|
| 2334 | fprintf(file, "%s", buffer);
|
---|
| 2335 | va_end(v);
|
---|
| 2336 | }
|
---|
| 2337 |
|
---|
[268] | 2338 | void HandleByte(struct RTCM3ParserData *Parser, unsigned int byte)
|
---|
[27] | 2339 | {
|
---|
| 2340 | Parser->Message[Parser->MessageSize++] = byte;
|
---|
| 2341 | if(Parser->MessageSize >= Parser->NeedBytes)
|
---|
| 2342 | {
|
---|
| 2343 | int r;
|
---|
| 2344 | while((r = RTCM3Parser(Parser)))
|
---|
| 2345 | {
|
---|
[502] | 2346 | if(r == 1020 || r == 1019)
|
---|
[27] | 2347 | {
|
---|
[502] | 2348 | FILE *file = 0;
|
---|
[318] | 2349 |
|
---|
[502] | 2350 | if(Parser->rinex3 && !(file = Parser->gpsfile))
|
---|
| 2351 | {
|
---|
| 2352 | const char *n = Parser->gpsephemeris ? Parser->gpsephemeris : Parser->glonassephemeris;
|
---|
| 2353 | if(n)
|
---|
| 2354 | {
|
---|
| 2355 | if(!(Parser->gpsfile = fopen(n, "w")))
|
---|
| 2356 | {
|
---|
| 2357 | RTCM3Error("Could not open ephemeris output file.\n");
|
---|
| 2358 | }
|
---|
| 2359 | else
|
---|
| 2360 | {
|
---|
| 2361 | char buffer[100];
|
---|
| 2362 | fprintf(Parser->gpsfile,
|
---|
| 2363 | "%9.2f%11sN: GNSS NAV DATA M: Mixed%12sRINEX VERSION / TYPE\n", 3.0, "", "");
|
---|
[503] | 2364 | HandleRunBy(buffer, sizeof(buffer), 0, Parser->rinex3);
|
---|
[502] | 2365 | fprintf(Parser->gpsfile, "%s\n%60sEND OF HEADER\n", buffer, "");
|
---|
| 2366 | }
|
---|
| 2367 | Parser->gpsephemeris = 0;
|
---|
| 2368 | Parser->glonassephemeris = 0;
|
---|
| 2369 | file = Parser->gpsfile;
|
---|
| 2370 | }
|
---|
| 2371 | }
|
---|
[318] | 2372 | else
|
---|
| 2373 | {
|
---|
[502] | 2374 | if(r == 1020)
|
---|
| 2375 | {
|
---|
| 2376 | if(Parser->glonassephemeris)
|
---|
| 2377 | {
|
---|
| 2378 | if(!(Parser->glonassfile = fopen(Parser->glonassephemeris, "w")))
|
---|
| 2379 | {
|
---|
| 2380 | RTCM3Error("Could not open GLONASS ephemeris output file.\n");
|
---|
| 2381 | }
|
---|
| 2382 | else
|
---|
| 2383 | {
|
---|
| 2384 | char buffer[100];
|
---|
| 2385 | fprintf(Parser->glonassfile,
|
---|
| 2386 | "%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n", 2.1, "", "");
|
---|
[503] | 2387 | HandleRunBy(buffer, sizeof(buffer), 0, Parser->rinex3);
|
---|
[502] | 2388 | fprintf(Parser->glonassfile, "%s\n%60sEND OF HEADER\n", buffer, "");
|
---|
| 2389 | }
|
---|
| 2390 | Parser->glonassephemeris = 0;
|
---|
| 2391 | }
|
---|
| 2392 | file = Parser->glonassfile;
|
---|
| 2393 | }
|
---|
| 2394 | else if(r == 1019)
|
---|
| 2395 | {
|
---|
| 2396 | if(Parser->gpsephemeris)
|
---|
| 2397 | {
|
---|
| 2398 | if(!(Parser->gpsfile = fopen(Parser->gpsephemeris, "w")))
|
---|
| 2399 | {
|
---|
| 2400 | RTCM3Error("Could not open GPS ephemeris output file.\n");
|
---|
| 2401 | }
|
---|
| 2402 | else
|
---|
| 2403 | {
|
---|
| 2404 | char buffer[100];
|
---|
| 2405 | fprintf(Parser->gpsfile,
|
---|
| 2406 | "%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n", 2.1, "", "");
|
---|
[503] | 2407 | HandleRunBy(buffer, sizeof(buffer), 0, Parser->rinex3);
|
---|
[502] | 2408 | fprintf(Parser->gpsfile, "%s\n%60sEND OF HEADER\n", buffer, "");
|
---|
| 2409 | }
|
---|
| 2410 | Parser->gpsephemeris = 0;
|
---|
| 2411 | }
|
---|
| 2412 | file = Parser->gpsfile;
|
---|
| 2413 | }
|
---|
[318] | 2414 | }
|
---|
[502] | 2415 | if(file)
|
---|
| 2416 | {
|
---|
| 2417 | if(r == 1020)
|
---|
| 2418 | {
|
---|
| 2419 | struct glonassephemeris *e = &Parser->ephemerisGLONASS;
|
---|
| 2420 | int w = e->GPSWeek, tow = e->GPSTOW, i;
|
---|
| 2421 | struct converttimeinfo cti;
|
---|
| 2422 |
|
---|
[2346] | 2423 | updatetime(&w, &tow, e->tb*1000, 1); /* Moscow - > UTC */
|
---|
[502] | 2424 | converttime(&cti, w, tow);
|
---|
| 2425 |
|
---|
| 2426 | i = e->tk-3*60*60; if(i < 0) i += 86400;
|
---|
| 2427 |
|
---|
| 2428 | if(Parser->rinex3)
|
---|
| 2429 | ConvLine(file, "R%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
| 2430 | e->almanac_number, cti.year, cti.month, cti.day, cti.hour, cti.minute,
|
---|
| 2431 | cti.second, -e->tau, e->gamma, (double) i);
|
---|
| 2432 | else
|
---|
| 2433 | ConvLine(file, "%02d %02d %02d %02d %02d %02d%5.1f%19.12e%19.12e%19.12e\n",
|
---|
| 2434 | e->almanac_number, cti.year%100, cti.month, cti.day, cti.hour, cti.minute,
|
---|
| 2435 | (double) cti.second, -e->tau, e->gamma, (double) i);
|
---|
| 2436 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", e->x_pos,
|
---|
| 2437 | e->x_velocity, e->x_acceleration, (e->flags & GLOEPHF_UNHEALTHY) ? 1.0 : 0.0);
|
---|
| 2438 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", e->y_pos,
|
---|
| 2439 | e->y_velocity, e->y_acceleration, (double) e->frequency_number);
|
---|
| 2440 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", e->z_pos,
|
---|
| 2441 | e->z_velocity, e->z_acceleration, (double) e->E);
|
---|
| 2442 | }
|
---|
| 2443 | else /* if(r == 1019) */
|
---|
| 2444 | {
|
---|
| 2445 | struct gpsephemeris *e = &Parser->ephemerisGPS;
|
---|
| 2446 | double d; /* temporary variable */
|
---|
| 2447 | unsigned long int i; /* temporary variable */
|
---|
| 2448 | struct converttimeinfo cti;
|
---|
| 2449 | converttime(&cti, e->GPSweek, e->TOC);
|
---|
| 2450 |
|
---|
| 2451 | if(Parser->rinex3)
|
---|
| 2452 | ConvLine(file, "G%02d %04d %02d %02d %02d %02d %02d%19.12e%19.12e%19.12e\n",
|
---|
| 2453 | e->satellite, cti.year, cti.month, cti.day, cti.hour,
|
---|
| 2454 | cti.minute, cti.second, e->clock_bias, e->clock_drift,
|
---|
| 2455 | e->clock_driftrate);
|
---|
| 2456 | else
|
---|
| 2457 | ConvLine(file, "%02d %02d %02d %02d %02d %02d%05.1f%19.12e%19.12e%19.12e\n",
|
---|
| 2458 | e->satellite, cti.year%100, cti.month, cti.day, cti.hour,
|
---|
| 2459 | cti.minute, (double) cti.second, e->clock_bias, e->clock_drift,
|
---|
| 2460 | e->clock_driftrate);
|
---|
| 2461 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", (double)e->IODE,
|
---|
| 2462 | e->Crs, e->Delta_n, e->M0);
|
---|
| 2463 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", e->Cuc,
|
---|
| 2464 | e->e, e->Cus, e->sqrt_A);
|
---|
| 2465 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n",
|
---|
| 2466 | (double) e->TOE, e->Cic, e->OMEGA0, e->Cis);
|
---|
| 2467 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", e->i0,
|
---|
| 2468 | e->Crc, e->omega, e->OMEGADOT);
|
---|
| 2469 | d = 0;
|
---|
| 2470 | i = e->flags;
|
---|
| 2471 | if(i & GPSEPHF_L2CACODE)
|
---|
| 2472 | d += 2.0;
|
---|
| 2473 | if(i & GPSEPHF_L2PCODE)
|
---|
| 2474 | d += 1.0;
|
---|
| 2475 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", e->IDOT, d,
|
---|
| 2476 | (double) e->GPSweek, i & GPSEPHF_L2PCODEDATA ? 1.0 : 0.0);
|
---|
| 2477 | if(e->URAindex <= 6) /* URA index */
|
---|
| 2478 | d = ceil(10.0*pow(2.0, 1.0+((double)e->URAindex)/2.0))/10.0;
|
---|
| 2479 | else
|
---|
| 2480 | d = ceil(10.0*pow(2.0, ((double)e->URAindex)/2.0))/10.0;
|
---|
| 2481 | /* 15 indicates not to use satellite. We can't handle this special
|
---|
| 2482 | case, so we create a high "non"-accuracy value. */
|
---|
| 2483 | ConvLine(file, " %19.12e%19.12e%19.12e%19.12e\n", d,
|
---|
| 2484 | ((double) e->SVhealth), e->TGD, ((double) e->IODC));
|
---|
| 2485 |
|
---|
| 2486 | ConvLine(file, " %19.12e%19.12e\n", ((double)e->TOW), 0.0);
|
---|
| 2487 | /* TOW */
|
---|
| 2488 | }
|
---|
| 2489 | }
|
---|
[27] | 2490 | }
|
---|
[2507] | 2491 | else if (r == 1 || r == 2)
|
---|
[27] | 2492 | {
|
---|
[502] | 2493 | int i, j, o;
|
---|
| 2494 | struct converttimeinfo cti;
|
---|
[27] | 2495 |
|
---|
[502] | 2496 | if(Parser->init < NUMSTARTSKIP) /* skip first epochs to detect correct data types */
|
---|
[27] | 2497 | {
|
---|
[502] | 2498 | ++Parser->init;
|
---|
| 2499 |
|
---|
| 2500 | if(Parser->init == NUMSTARTSKIP)
|
---|
| 2501 | HandleHeader(Parser);
|
---|
[27] | 2502 | else
|
---|
[502] | 2503 | {
|
---|
| 2504 | for(i = 0; i < Parser->Data.numsats; ++i)
|
---|
| 2505 | Parser->startflags |= Parser->Data.dataflags[i];
|
---|
| 2506 | continue;
|
---|
| 2507 | }
|
---|
[27] | 2508 | }
|
---|
[502] | 2509 | if(r == 2 && !Parser->validwarning)
|
---|
[27] | 2510 | {
|
---|
[502] | 2511 | RTCM3Text("No valid RINEX! All values are modulo 299792.458!"
|
---|
| 2512 | " COMMENT\n");
|
---|
| 2513 | Parser->validwarning = 1;
|
---|
| 2514 | }
|
---|
| 2515 |
|
---|
| 2516 | converttime(&cti, Parser->Data.week,
|
---|
| 2517 | (int)floor(Parser->Data.timeofweek/1000.0));
|
---|
| 2518 | if(Parser->rinex3)
|
---|
| 2519 | {
|
---|
| 2520 | RTCM3Text("> %04d %02d %02d %02d %02d%11.7f 0%3d\n",
|
---|
| 2521 | cti.year, cti.month, cti.day, cti.hour, cti.minute, cti.second
|
---|
| 2522 | + fmod(Parser->Data.timeofweek/1000.0,1.0), Parser->Data.numsats);
|
---|
| 2523 | for(i = 0; i < Parser->Data.numsats; ++i)
|
---|
[363] | 2524 | {
|
---|
[4371] | 2525 | int sys[RTCM3_MSM_NUMSYS] = {0,0,0,0,0,0};
|
---|
[502] | 2526 | if(Parser->Data.satellites[i] <= PRN_GPS_END)
|
---|
[4371] | 2527 | {
|
---|
[502] | 2528 | RTCM3Text("G%02d", Parser->Data.satellites[i]);
|
---|
[4371] | 2529 | sys[RTCM3_MSM_GPS] = 1;
|
---|
| 2530 | }
|
---|
[502] | 2531 | else if(Parser->Data.satellites[i] >= PRN_GLONASS_START
|
---|
| 2532 | && Parser->Data.satellites[i] <= PRN_GLONASS_END)
|
---|
| 2533 | {
|
---|
| 2534 | RTCM3Text("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1));
|
---|
[4371] | 2535 | sys[RTCM3_MSM_GLONASS] = 1;
|
---|
[502] | 2536 | }
|
---|
[2699] | 2537 | else if(Parser->Data.satellites[i] >= PRN_GALILEO_START
|
---|
| 2538 | && Parser->Data.satellites[i] <= PRN_GALILEO_END)
|
---|
| 2539 | {
|
---|
| 2540 | RTCM3Text("E%02d", Parser->Data.satellites[i] - (PRN_GALILEO_START-1));
|
---|
[4371] | 2541 | sys[RTCM3_MSM_GALILEO] = 1;
|
---|
[2699] | 2542 | }
|
---|
| 2543 | else if(Parser->Data.satellites[i] >= PRN_GIOVE_START
|
---|
| 2544 | && Parser->Data.satellites[i] <= PRN_GIOVE_END)
|
---|
| 2545 | {
|
---|
| 2546 | RTCM3Text("E%02d", Parser->Data.satellites[i] - (PRN_GIOVE_START-PRN_GIOVE_OFFSET));
|
---|
[4371] | 2547 | sys[RTCM3_MSM_GALILEO] = 1;
|
---|
[2699] | 2548 | }
|
---|
[4367] | 2549 | else if(Parser->Data.satellites[i] >= PRN_QZSS_START
|
---|
| 2550 | && Parser->Data.satellites[i] <= PRN_QZSS_END)
|
---|
| 2551 | {
|
---|
| 2552 | RTCM3Text("J%02d", Parser->Data.satellites[i] - (PRN_QZSS_START-1));
|
---|
[4371] | 2553 | sys[RTCM3_MSM_QZSS] = 1;
|
---|
[4367] | 2554 | }
|
---|
| 2555 | else if(Parser->Data.satellites[i] >= PRN_COMPASS_START
|
---|
| 2556 | && Parser->Data.satellites[i] <= PRN_COMPASS_END)
|
---|
| 2557 | {
|
---|
| 2558 | RTCM3Text("C%02d", Parser->Data.satellites[i] - (PRN_COMPASS_START-1));
|
---|
[4371] | 2559 | sys[RTCM3_MSM_COMPASS] = 1;
|
---|
[4367] | 2560 | }
|
---|
| 2561 | else if(Parser->Data.satellites[i] >= PRN_SBAS_START
|
---|
| 2562 | && Parser->Data.satellites[i] <= PRN_SBAS_END)
|
---|
[4371] | 2563 | {
|
---|
[4367] | 2564 | RTCM3Text("S%02d", Parser->Data.satellites[i] - PRN_SBAS_START+20);
|
---|
[4371] | 2565 | sys[RTCM3_MSM_SBAS] = 1;
|
---|
| 2566 | }
|
---|
[502] | 2567 | else
|
---|
[4371] | 2568 | {
|
---|
[502] | 2569 | RTCM3Text("%3d", Parser->Data.satellites[i]);
|
---|
[4371] | 2570 | }
|
---|
[363] | 2571 |
|
---|
[4371] | 2572 | if(sys[RTCM3_MSM_GLONASS])
|
---|
[363] | 2573 | {
|
---|
[4371] | 2574 | for(j = 0; j < Parser->info[RTCM3_MSM_GLONASS].numtypes; ++j)
|
---|
[502] | 2575 | {
|
---|
[4383] | 2576 | long long df = Parser->info[RTCM3_MSM_GLONASS].flags[j];
|
---|
[4371] | 2577 | int pos = Parser->info[RTCM3_MSM_GLONASS].pos[j];
|
---|
[502] | 2578 | if((Parser->Data.dataflags[i] & df)
|
---|
| 2579 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
[4374] | 2580 | && !isinf(Parser->Data.measdata[i][pos])
|
---|
| 2581 | && (Parser->Data.codetype[i][pos]
|
---|
| 2582 | && Parser->info[RTCM3_MSM_GLONASS].type[pos]
|
---|
| 2583 | && Parser->info[RTCM3_MSM_GLONASS].type[pos]
|
---|
| 2584 | == Parser->Data.codetype[i][pos][1]))
|
---|
[502] | 2585 | {
|
---|
| 2586 | char lli = ' ';
|
---|
| 2587 | char snr = ' ';
|
---|
| 2588 | if(df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA))
|
---|
| 2589 | {
|
---|
[2659] | 2590 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL1)
|
---|
[502] | 2591 | lli = '1';
|
---|
| 2592 | snr = '0'+Parser->Data.snrL1[i];
|
---|
| 2593 | }
|
---|
| 2594 | if(df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA))
|
---|
| 2595 | {
|
---|
[2659] | 2596 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL2)
|
---|
[502] | 2597 | lli = '1';
|
---|
| 2598 | snr = '0'+Parser->Data.snrL2[i];
|
---|
| 2599 | }
|
---|
| 2600 | RTCM3Text("%14.3f%c%c",
|
---|
| 2601 | Parser->Data.measdata[i][pos],lli,snr);
|
---|
| 2602 | }
|
---|
| 2603 | else
|
---|
| 2604 | { /* no or illegal data */
|
---|
| 2605 | RTCM3Text(" ");
|
---|
| 2606 | }
|
---|
| 2607 | }
|
---|
[363] | 2608 | }
|
---|
[4371] | 2609 | else if(sys[RTCM3_MSM_GALILEO])
|
---|
[2699] | 2610 | {
|
---|
[4371] | 2611 | for(j = 0; j < Parser->info[RTCM3_MSM_GALILEO].numtypes; ++j)
|
---|
[2699] | 2612 | {
|
---|
[4383] | 2613 | long long df = Parser->info[RTCM3_MSM_GALILEO].flags[j];
|
---|
[4371] | 2614 | int pos = Parser->info[RTCM3_MSM_GALILEO].pos[j];
|
---|
[2699] | 2615 | if((Parser->Data.dataflags[i] & df)
|
---|
| 2616 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
[4374] | 2617 | && !isinf(Parser->Data.measdata[i][pos])
|
---|
| 2618 | && (Parser->Data.codetype[i][pos]
|
---|
| 2619 | && Parser->info[RTCM3_MSM_GALILEO].type[pos]
|
---|
| 2620 | && Parser->info[RTCM3_MSM_GALILEO].type[pos]
|
---|
| 2621 | == Parser->Data.codetype[i][pos][1]))
|
---|
[2699] | 2622 | {
|
---|
| 2623 | char lli = ' ';
|
---|
| 2624 | char snr = ' ';
|
---|
| 2625 | if(df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA))
|
---|
| 2626 | {
|
---|
| 2627 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL1)
|
---|
| 2628 | lli = '1';
|
---|
| 2629 | snr = '0'+Parser->Data.snrL1[i];
|
---|
| 2630 | }
|
---|
| 2631 | if(df & GNSSDF_L6DATA)
|
---|
| 2632 | {
|
---|
| 2633 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSE6)
|
---|
| 2634 | lli = '1';
|
---|
| 2635 | snr = ' ';
|
---|
| 2636 | }
|
---|
| 2637 | if(df & GNSSDF_L5DATA)
|
---|
| 2638 | {
|
---|
| 2639 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL5)
|
---|
| 2640 | lli = '1';
|
---|
| 2641 | snr = ' ';
|
---|
| 2642 | }
|
---|
| 2643 | if(df & GNSSDF_L5BDATA)
|
---|
| 2644 | {
|
---|
| 2645 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSE5B)
|
---|
| 2646 | lli = '1';
|
---|
| 2647 | snr = ' ';
|
---|
| 2648 | }
|
---|
| 2649 | if(df & GNSSDF_L5ABDATA)
|
---|
| 2650 | {
|
---|
| 2651 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSE5AB)
|
---|
| 2652 | lli = '1';
|
---|
| 2653 | snr = ' ';
|
---|
| 2654 | }
|
---|
| 2655 | RTCM3Text("%14.3f%c%c",
|
---|
| 2656 | Parser->Data.measdata[i][pos],lli,snr);
|
---|
| 2657 | }
|
---|
| 2658 | else
|
---|
| 2659 | { /* no or illegal data */
|
---|
| 2660 | RTCM3Text(" ");
|
---|
| 2661 | }
|
---|
| 2662 | }
|
---|
| 2663 | }
|
---|
[4371] | 2664 | else if(sys[RTCM3_MSM_COMPASS])
|
---|
[4367] | 2665 | {
|
---|
[4371] | 2666 | for(j = 0; j < Parser->info[RTCM3_MSM_COMPASS].numtypes; ++j)
|
---|
[4367] | 2667 | {
|
---|
[4383] | 2668 | long long df = Parser->info[RTCM3_MSM_COMPASS].flags[j];
|
---|
[4371] | 2669 | int pos = Parser->info[RTCM3_MSM_COMPASS].pos[j];
|
---|
[4367] | 2670 | if((Parser->Data.dataflags[i] & df)
|
---|
| 2671 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
[4374] | 2672 | && !isinf(Parser->Data.measdata[i][pos])
|
---|
| 2673 | && (Parser->Data.codetype[i][pos]
|
---|
| 2674 | && Parser->info[RTCM3_MSM_COMPASS].type[pos]
|
---|
| 2675 | && Parser->info[RTCM3_MSM_COMPASS].type[pos]
|
---|
| 2676 | == Parser->Data.codetype[i][pos][1]))
|
---|
[4367] | 2677 | {
|
---|
| 2678 | char lli = ' ';
|
---|
| 2679 | char snr = ' ';
|
---|
| 2680 | if(df & GNSSDF_LB1DATA)
|
---|
| 2681 | {
|
---|
| 2682 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSB1)
|
---|
| 2683 | lli = '1';
|
---|
| 2684 | }
|
---|
| 2685 | if(df & GNSSDF_LB2DATA)
|
---|
| 2686 | {
|
---|
| 2687 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSB2)
|
---|
| 2688 | lli = '1';
|
---|
| 2689 | }
|
---|
| 2690 | if(df & GNSSDF_LB3DATA)
|
---|
| 2691 | {
|
---|
| 2692 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSB3)
|
---|
| 2693 | lli = '1';
|
---|
| 2694 | }
|
---|
| 2695 | RTCM3Text("%14.3f%c%c",
|
---|
| 2696 | Parser->Data.measdata[i][pos],lli,snr);
|
---|
| 2697 | }
|
---|
| 2698 | else
|
---|
| 2699 | { /* no or illegal data */
|
---|
| 2700 | RTCM3Text(" ");
|
---|
| 2701 | }
|
---|
| 2702 | }
|
---|
| 2703 | }
|
---|
[4371] | 2704 | else if(sys[RTCM3_MSM_QZSS])
|
---|
[4367] | 2705 | {
|
---|
[4371] | 2706 | for(j = 0; j < Parser->info[RTCM3_MSM_QZSS].numtypes; ++j)
|
---|
[4367] | 2707 | {
|
---|
[4383] | 2708 | long long df = Parser->info[RTCM3_MSM_QZSS].flags[j];
|
---|
[4371] | 2709 | int pos = Parser->info[RTCM3_MSM_QZSS].pos[j];
|
---|
[4367] | 2710 | if((Parser->Data.dataflags[i] & df)
|
---|
| 2711 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
[4371] | 2712 | && !isinf(Parser->Data.measdata[i][pos])
|
---|
[4374] | 2713 | && (Parser->Data.codetype[i][pos]
|
---|
[4371] | 2714 | && Parser->info[RTCM3_MSM_QZSS].type[pos]
|
---|
| 2715 | && Parser->info[RTCM3_MSM_QZSS].type[pos]
|
---|
[4374] | 2716 | == Parser->Data.codetype[i][pos][1]))
|
---|
[4367] | 2717 | {
|
---|
| 2718 | char lli = ' ';
|
---|
| 2719 | char snr = ' ';
|
---|
| 2720 | if(df & GNSSDF_L1CDATA)
|
---|
| 2721 | {
|
---|
| 2722 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL1)
|
---|
| 2723 | lli = '1';
|
---|
| 2724 | snr = '0'+Parser->Data.snrL1[i];
|
---|
| 2725 | }
|
---|
| 2726 | if(df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA))
|
---|
| 2727 | {
|
---|
| 2728 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL2)
|
---|
| 2729 | lli = '1';
|
---|
| 2730 | snr = '0'+Parser->Data.snrL2[i];
|
---|
| 2731 | }
|
---|
| 2732 | if(df & GNSSDF_L5DATA)
|
---|
| 2733 | {
|
---|
| 2734 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL5)
|
---|
| 2735 | lli = '1';
|
---|
| 2736 | snr = ' ';
|
---|
| 2737 | }
|
---|
| 2738 | RTCM3Text("%14.3f%c%c",
|
---|
| 2739 | Parser->Data.measdata[i][pos],lli,snr);
|
---|
| 2740 | }
|
---|
| 2741 | else
|
---|
| 2742 | { /* no or illegal data */
|
---|
| 2743 | RTCM3Text(" ");
|
---|
| 2744 | }
|
---|
| 2745 | }
|
---|
| 2746 | }
|
---|
[4371] | 2747 | else if(sys[RTCM3_MSM_SBAS])
|
---|
| 2748 | {
|
---|
| 2749 | for(j = 0; j < Parser->info[RTCM3_MSM_SBAS].numtypes; ++j)
|
---|
| 2750 | {
|
---|
[4383] | 2751 | long long df = Parser->info[RTCM3_MSM_SBAS].flags[j];
|
---|
[4371] | 2752 | int pos = Parser->info[RTCM3_MSM_SBAS].pos[j];
|
---|
| 2753 | if((Parser->Data.dataflags[i] & df)
|
---|
| 2754 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
[4374] | 2755 | && !isinf(Parser->Data.measdata[i][pos])
|
---|
| 2756 | && (Parser->Data.codetype[i][pos]
|
---|
| 2757 | && Parser->info[RTCM3_MSM_SBAS].type[pos]
|
---|
| 2758 | && Parser->info[RTCM3_MSM_SBAS].type[pos]
|
---|
| 2759 | == Parser->Data.codetype[i][pos][1]))
|
---|
[4371] | 2760 | {
|
---|
| 2761 | char lli = ' ';
|
---|
| 2762 | char snr = ' ';
|
---|
| 2763 | if(df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA))
|
---|
| 2764 | {
|
---|
| 2765 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL1)
|
---|
| 2766 | lli = '1';
|
---|
| 2767 | snr = '0'+Parser->Data.snrL1[i];
|
---|
| 2768 | }
|
---|
| 2769 | if(df & GNSSDF_L5DATA)
|
---|
| 2770 | {
|
---|
| 2771 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL5)
|
---|
| 2772 | lli = '1';
|
---|
| 2773 | snr = ' ';
|
---|
| 2774 | }
|
---|
| 2775 | RTCM3Text("%14.3f%c%c",
|
---|
| 2776 | Parser->Data.measdata[i][pos],lli,snr);
|
---|
| 2777 | }
|
---|
| 2778 | else
|
---|
| 2779 | { /* no or illegal data */
|
---|
| 2780 | RTCM3Text(" ");
|
---|
| 2781 | }
|
---|
| 2782 | }
|
---|
| 2783 | }
|
---|
[502] | 2784 | else
|
---|
| 2785 | {
|
---|
[4371] | 2786 | for(j = 0; j < Parser->info[RTCM3_MSM_GPS].numtypes; ++j)
|
---|
[502] | 2787 | {
|
---|
[4383] | 2788 | long long df = Parser->info[RTCM3_MSM_GPS].flags[j];
|
---|
[4371] | 2789 | int pos = Parser->info[RTCM3_MSM_GPS].pos[j];
|
---|
[4383] | 2790 | if((Parser->Data.dataflags[i] & df)
|
---|
[502] | 2791 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
[4374] | 2792 | && !isinf(Parser->Data.measdata[i][pos])
|
---|
| 2793 | && (Parser->Data.codetype[i][pos]
|
---|
| 2794 | && Parser->info[RTCM3_MSM_GPS].type[pos]
|
---|
| 2795 | && Parser->info[RTCM3_MSM_GPS].type[pos]
|
---|
| 2796 | == Parser->Data.codetype[i][pos][1]))
|
---|
[502] | 2797 | {
|
---|
| 2798 | char lli = ' ';
|
---|
| 2799 | char snr = ' ';
|
---|
| 2800 | if(df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA))
|
---|
| 2801 | {
|
---|
[2659] | 2802 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL1)
|
---|
[502] | 2803 | lli = '1';
|
---|
| 2804 | snr = '0'+Parser->Data.snrL1[i];
|
---|
| 2805 | }
|
---|
| 2806 | if(df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA))
|
---|
| 2807 | {
|
---|
[2659] | 2808 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL2)
|
---|
[502] | 2809 | lli = '1';
|
---|
| 2810 | snr = '0'+Parser->Data.snrL2[i];
|
---|
| 2811 | }
|
---|
[2699] | 2812 | if(df & GNSSDF_L5DATA)
|
---|
| 2813 | {
|
---|
| 2814 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL5)
|
---|
| 2815 | lli = '1';
|
---|
| 2816 | snr = ' ';
|
---|
| 2817 | }
|
---|
[502] | 2818 | RTCM3Text("%14.3f%c%c",
|
---|
| 2819 | Parser->Data.measdata[i][pos],lli,snr);
|
---|
| 2820 | }
|
---|
| 2821 | else
|
---|
| 2822 | { /* no or illegal data */
|
---|
| 2823 | RTCM3Text(" ");
|
---|
| 2824 | }
|
---|
| 2825 | }
|
---|
| 2826 | }
|
---|
| 2827 | RTCM3Text("\n");
|
---|
[363] | 2828 | }
|
---|
[502] | 2829 | }
|
---|
| 2830 | else
|
---|
| 2831 | {
|
---|
| 2832 | RTCM3Text(" %02d %2d %2d %2d %2d %10.7f 0%3d",
|
---|
| 2833 | cti.year%100, cti.month, cti.day, cti.hour, cti.minute, cti.second
|
---|
| 2834 | + fmod(Parser->Data.timeofweek/1000.0,1.0), Parser->Data.numsats);
|
---|
| 2835 | for(i = 0; i < 12 && i < Parser->Data.numsats; ++i)
|
---|
| 2836 | {
|
---|
| 2837 | if(Parser->Data.satellites[i] <= PRN_GPS_END)
|
---|
| 2838 | RTCM3Text("G%02d", Parser->Data.satellites[i]);
|
---|
| 2839 | else if(Parser->Data.satellites[i] >= PRN_GLONASS_START
|
---|
| 2840 | && Parser->Data.satellites[i] <= PRN_GLONASS_END)
|
---|
[2659] | 2841 | RTCM3Text("R%02d", Parser->Data.satellites[i]
|
---|
| 2842 | - (PRN_GLONASS_START-1));
|
---|
[4367] | 2843 | else if(Parser->Data.satellites[i] >= PRN_SBAS_START
|
---|
| 2844 | && Parser->Data.satellites[i] <= PRN_SBAS_END)
|
---|
[2659] | 2845 | RTCM3Text("S%02d", Parser->Data.satellites[i]
|
---|
[4367] | 2846 | - PRN_SBAS_START+20);
|
---|
[2659] | 2847 | else if(Parser->Data.satellites[i] >= PRN_GALILEO_START
|
---|
| 2848 | && Parser->Data.satellites[i] <= PRN_GALILEO_END)
|
---|
| 2849 | RTCM3Text("E%02d", Parser->Data.satellites[i]
|
---|
| 2850 | - (PRN_GALILEO_START-1));
|
---|
| 2851 | else if(Parser->Data.satellites[i] >= PRN_GIOVE_START
|
---|
| 2852 | && Parser->Data.satellites[i] <= PRN_GIOVE_END)
|
---|
| 2853 | RTCM3Text("E%02d", Parser->Data.satellites[i]
|
---|
| 2854 | - (PRN_GIOVE_START-PRN_GIOVE_OFFSET));
|
---|
[4367] | 2855 | else if(Parser->Data.satellites[i] >= PRN_QZSS_START
|
---|
| 2856 | && Parser->Data.satellites[i] <= PRN_QZSS_END)
|
---|
| 2857 | RTCM3Text("J%02d", Parser->Data.satellites[i]
|
---|
| 2858 | - (PRN_QZSS_START-1));
|
---|
| 2859 | else if(Parser->Data.satellites[i] >= PRN_COMPASS_START
|
---|
| 2860 | && Parser->Data.satellites[i] <= PRN_COMPASS_END)
|
---|
| 2861 | RTCM3Text("C%02d", Parser->Data.satellites[i]
|
---|
| 2862 | - (PRN_COMPASS_START-1));
|
---|
[502] | 2863 | else
|
---|
| 2864 | RTCM3Text("%3d", Parser->Data.satellites[i]);
|
---|
[27] | 2865 | }
|
---|
[502] | 2866 | RTCM3Text("\n");
|
---|
| 2867 | o = 12;
|
---|
| 2868 | j = Parser->Data.numsats - 12;
|
---|
| 2869 | while(j > 0)
|
---|
[27] | 2870 | {
|
---|
[502] | 2871 | RTCM3Text(" ");
|
---|
| 2872 | for(i = o; i < o+12 && i < Parser->Data.numsats; ++i)
|
---|
[27] | 2873 | {
|
---|
[502] | 2874 | if(Parser->Data.satellites[i] <= PRN_GPS_END)
|
---|
| 2875 | RTCM3Text("G%02d", Parser->Data.satellites[i]);
|
---|
| 2876 | else if(Parser->Data.satellites[i] >= PRN_GLONASS_START
|
---|
| 2877 | && Parser->Data.satellites[i] <= PRN_GLONASS_END)
|
---|
[2659] | 2878 | RTCM3Text("R%02d", Parser->Data.satellites[i]
|
---|
| 2879 | - (PRN_GLONASS_START-1));
|
---|
[4367] | 2880 | else if(Parser->Data.satellites[i] >= PRN_SBAS_START
|
---|
| 2881 | && Parser->Data.satellites[i] <= PRN_SBAS_END)
|
---|
[2659] | 2882 | RTCM3Text("S%02d", Parser->Data.satellites[i]
|
---|
[4367] | 2883 | - PRN_SBAS_START+20);
|
---|
[2659] | 2884 | else if(Parser->Data.satellites[i] >= PRN_GALILEO_START
|
---|
| 2885 | && Parser->Data.satellites[i] <= PRN_GALILEO_END)
|
---|
| 2886 | RTCM3Text("E%02d", Parser->Data.satellites[i]
|
---|
| 2887 | - (PRN_GALILEO_START-1));
|
---|
| 2888 | else if(Parser->Data.satellites[i] >= PRN_GIOVE_START
|
---|
| 2889 | && Parser->Data.satellites[i] <= PRN_GIOVE_END)
|
---|
| 2890 | RTCM3Text("E%02d", Parser->Data.satellites[i]
|
---|
| 2891 | - (PRN_GIOVE_START-PRN_GIOVE_OFFSET));
|
---|
[4367] | 2892 | else if(Parser->Data.satellites[i] >= PRN_QZSS_START
|
---|
| 2893 | && Parser->Data.satellites[i] <= PRN_QZSS_END)
|
---|
| 2894 | RTCM3Text("J%02d", Parser->Data.satellites[i]
|
---|
| 2895 | - (PRN_QZSS_START-1));
|
---|
| 2896 | else if(Parser->Data.satellites[i] >= PRN_COMPASS_START
|
---|
| 2897 | && Parser->Data.satellites[i] <= PRN_COMPASS_END)
|
---|
| 2898 | RTCM3Text("C%02d", Parser->Data.satellites[i]
|
---|
| 2899 | - (PRN_COMPASS_START-1));
|
---|
[502] | 2900 | else
|
---|
| 2901 | RTCM3Text("%3d", Parser->Data.satellites[i]);
|
---|
[27] | 2902 | }
|
---|
[502] | 2903 | RTCM3Text("\n");
|
---|
| 2904 | j -= 12;
|
---|
| 2905 | o += 12;
|
---|
| 2906 | }
|
---|
| 2907 | for(i = 0; i < Parser->Data.numsats; ++i)
|
---|
| 2908 | {
|
---|
[4371] | 2909 | for(j = 0; j < Parser->info[RTCM3_MSM_GPS].numtypes; ++j)
|
---|
[27] | 2910 | {
|
---|
[502] | 2911 | int v = 0;
|
---|
[4383] | 2912 | long long df = Parser->flags[j];
|
---|
[4371] | 2913 | int pos = Parser->pos[j];
|
---|
[502] | 2914 | if((Parser->Data.dataflags[i] & df)
|
---|
| 2915 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
| 2916 | && !isinf(Parser->Data.measdata[i][pos]))
|
---|
| 2917 | {
|
---|
| 2918 | v = 1;
|
---|
| 2919 | }
|
---|
| 2920 | else
|
---|
| 2921 | {
|
---|
[4371] | 2922 | df = Parser->info[RTCM3_MSM_GPS].flags[j];
|
---|
| 2923 | pos = Parser->info[RTCM3_MSM_GPS].pos[j];
|
---|
[502] | 2924 |
|
---|
| 2925 | if((Parser->Data.dataflags[i] & df)
|
---|
| 2926 | && !isnan(Parser->Data.measdata[i][pos])
|
---|
| 2927 | && !isinf(Parser->Data.measdata[i][pos]))
|
---|
| 2928 | {
|
---|
| 2929 | v = 1;
|
---|
| 2930 | }
|
---|
| 2931 | }
|
---|
| 2932 |
|
---|
| 2933 | if(!v)
|
---|
| 2934 | { /* no or illegal data */
|
---|
| 2935 | RTCM3Text(" ");
|
---|
| 2936 | }
|
---|
| 2937 | else
|
---|
| 2938 | {
|
---|
| 2939 | char lli = ' ';
|
---|
| 2940 | char snr = ' ';
|
---|
| 2941 | if(df & (GNSSDF_L1CDATA|GNSSDF_L1PDATA))
|
---|
| 2942 | {
|
---|
[2659] | 2943 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL1)
|
---|
[502] | 2944 | lli = '1';
|
---|
| 2945 | snr = '0'+Parser->Data.snrL1[i];
|
---|
| 2946 | }
|
---|
| 2947 | if(df & (GNSSDF_L2CDATA|GNSSDF_L2PDATA))
|
---|
| 2948 | {
|
---|
[2659] | 2949 | if(Parser->Data.dataflags2[i]
|
---|
| 2950 | & (GNSSDF2_LOCKLOSSL2|GNSSDF2_XCORRL2))
|
---|
[2422] | 2951 | {
|
---|
| 2952 | lli = '0';
|
---|
[2659] | 2953 | if(Parser->Data.dataflags2[i] & GNSSDF2_LOCKLOSSL2)
|
---|
[2422] | 2954 | lli += 1;
|
---|
[2659] | 2955 | if(Parser->Data.dataflags2[i] & GNSSDF2_XCORRL2)
|
---|
[2422] | 2956 | lli += 4;
|
---|
| 2957 | }
|
---|
[502] | 2958 | snr = '0'+Parser->Data.snrL2[i];
|
---|
| 2959 | }
|
---|
[2659] | 2960 | if((df & GNSSDF_P2DATA) && (Parser->Data.dataflags2[i]
|
---|
| 2961 | & GNSSDF2_XCORRL2))
|
---|
[2422] | 2962 | lli = '4';
|
---|
[502] | 2963 | RTCM3Text("%14.3f%c%c",
|
---|
| 2964 | Parser->Data.measdata[i][pos],lli,snr);
|
---|
| 2965 | }
|
---|
[4371] | 2966 | if(j%5 == 4 || j == Parser->info[RTCM3_MSM_GPS].numtypes-1)
|
---|
[502] | 2967 | RTCM3Text("\n");
|
---|
[27] | 2968 | }
|
---|
| 2969 | }
|
---|
| 2970 | }
|
---|
| 2971 | }
|
---|
| 2972 | }
|
---|
| 2973 | }
|
---|
| 2974 | }
|
---|
| 2975 |
|
---|
[268] | 2976 | #ifndef NO_RTCM3_MAIN
|
---|
[2487] | 2977 | static char datestr[] = "$Date: 2012-08-16 13:24:51 +0000 (Thu, 16 Aug 2012) $";
|
---|
[269] | 2978 |
|
---|
[268] | 2979 | /* The string, which is send as agent in HTTP request */
|
---|
| 2980 | #define AGENTSTRING "NTRIP NtripRTCM3ToRINEX"
|
---|
| 2981 |
|
---|
| 2982 | #define MAXDATASIZE 1000 /* max number of bytes we can get at once */
|
---|
| 2983 |
|
---|
[269] | 2984 | static const char encodingTable [64] = {
|
---|
| 2985 | 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',
|
---|
| 2986 | 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',
|
---|
| 2987 | 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',
|
---|
| 2988 | 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'
|
---|
| 2989 | };
|
---|
| 2990 |
|
---|
| 2991 | /* does not buffer overrun, but breaks directly after an error */
|
---|
| 2992 | /* returns the number of required bytes */
|
---|
| 2993 | static int encode(char *buf, int size, const char *user, const char *pwd)
|
---|
| 2994 | {
|
---|
| 2995 | unsigned char inbuf[3];
|
---|
| 2996 | char *out = buf;
|
---|
| 2997 | int i, sep = 0, fill = 0, bytes = 0;
|
---|
| 2998 |
|
---|
| 2999 | while(*user || *pwd)
|
---|
| 3000 | {
|
---|
| 3001 | i = 0;
|
---|
| 3002 | while(i < 3 && *user) inbuf[i++] = *(user++);
|
---|
| 3003 | if(i < 3 && !sep) {inbuf[i++] = ':'; ++sep; }
|
---|
| 3004 | while(i < 3 && *pwd) inbuf[i++] = *(pwd++);
|
---|
| 3005 | while(i < 3) {inbuf[i++] = 0; ++fill; }
|
---|
| 3006 | if(out-buf < size-1)
|
---|
| 3007 | *(out++) = encodingTable[(inbuf [0] & 0xFC) >> 2];
|
---|
| 3008 | if(out-buf < size-1)
|
---|
| 3009 | *(out++) = encodingTable[((inbuf [0] & 0x03) << 4)
|
---|
| 3010 | | ((inbuf [1] & 0xF0) >> 4)];
|
---|
| 3011 | if(out-buf < size-1)
|
---|
| 3012 | {
|
---|
| 3013 | if(fill == 2)
|
---|
| 3014 | *(out++) = '=';
|
---|
| 3015 | else
|
---|
| 3016 | *(out++) = encodingTable[((inbuf [1] & 0x0F) << 2)
|
---|
| 3017 | | ((inbuf [2] & 0xC0) >> 6)];
|
---|
| 3018 | }
|
---|
| 3019 | if(out-buf < size-1)
|
---|
| 3020 | {
|
---|
| 3021 | if(fill >= 1)
|
---|
| 3022 | *(out++) = '=';
|
---|
| 3023 | else
|
---|
| 3024 | *(out++) = encodingTable[inbuf [2] & 0x3F];
|
---|
| 3025 | }
|
---|
| 3026 | bytes += 4;
|
---|
| 3027 | }
|
---|
| 3028 | if(out-buf < size)
|
---|
| 3029 | *out = 0;
|
---|
| 3030 | return bytes;
|
---|
| 3031 | }
|
---|
| 3032 |
|
---|
[268] | 3033 | static int stop = 0;
|
---|
| 3034 |
|
---|
| 3035 | struct Args
|
---|
| 3036 | {
|
---|
| 3037 | const char *server;
|
---|
[502] | 3038 | const char *port;
|
---|
| 3039 | int mode;
|
---|
[477] | 3040 | int timeout;
|
---|
[502] | 3041 | int rinex3;
|
---|
[268] | 3042 | const char *user;
|
---|
| 3043 | const char *password;
|
---|
[502] | 3044 | const char *proxyhost;
|
---|
| 3045 | const char *proxyport;
|
---|
| 3046 | const char *nmea;
|
---|
[268] | 3047 | const char *data;
|
---|
| 3048 | const char *headerfile;
|
---|
[502] | 3049 | const char *gpsephemeris;
|
---|
| 3050 | const char *glonassephemeris;
|
---|
[268] | 3051 | };
|
---|
| 3052 |
|
---|
| 3053 | /* option parsing */
|
---|
| 3054 | #ifdef NO_LONG_OPTS
|
---|
| 3055 | #define LONG_OPT(a)
|
---|
| 3056 | #else
|
---|
| 3057 | #define LONG_OPT(a) a
|
---|
| 3058 | static struct option opts[] = {
|
---|
[502] | 3059 | { "data", required_argument, 0, 'd'},
|
---|
| 3060 | { "server", required_argument, 0, 's'},
|
---|
| 3061 | { "password", required_argument, 0, 'p'},
|
---|
| 3062 | { "port", required_argument, 0, 'r'},
|
---|
| 3063 | { "timeout", required_argument, 0, 't'},
|
---|
| 3064 | { "header", required_argument, 0, 'f'},
|
---|
| 3065 | { "user", required_argument, 0, 'u'},
|
---|
| 3066 | { "gpsephemeris", required_argument, 0, 'E'},
|
---|
| 3067 | { "glonassephemeris", required_argument, 0, 'G'},
|
---|
| 3068 | { "rinex3", no_argument, 0, '3'},
|
---|
| 3069 | { "proxyport", required_argument, 0, 'R'},
|
---|
| 3070 | { "proxyhost", required_argument, 0, 'S'},
|
---|
| 3071 | { "nmea", required_argument, 0, 'n'},
|
---|
| 3072 | { "mode", required_argument, 0, 'M'},
|
---|
| 3073 | { "help", no_argument, 0, 'h'},
|
---|
[268] | 3074 | {0,0,0,0}};
|
---|
| 3075 | #endif
|
---|
[502] | 3076 | #define ARGOPT "-d:s:p:r:t:f:u:E:G:M:S:R:n:h3"
|
---|
[268] | 3077 |
|
---|
[502] | 3078 | enum MODE { HTTP = 1, RTSP = 2, NTRIP1 = 3, AUTO = 4, END };
|
---|
| 3079 |
|
---|
[270] | 3080 | static const char *geturl(const char *url, struct Args *args)
|
---|
| 3081 | {
|
---|
| 3082 | static char buf[1000];
|
---|
| 3083 | static char *Buffer = buf;
|
---|
| 3084 | static char *Bufend = buf+sizeof(buf);
|
---|
| 3085 |
|
---|
| 3086 | if(strncmp("ntrip:", url, 6))
|
---|
| 3087 | return "URL must start with 'ntrip:'.";
|
---|
| 3088 | url += 6; /* skip ntrip: */
|
---|
| 3089 |
|
---|
| 3090 | if(*url != '@' && *url != '/')
|
---|
| 3091 | {
|
---|
| 3092 | /* scan for mountpoint */
|
---|
| 3093 | args->data = Buffer;
|
---|
[502] | 3094 | while(*url && *url != '@' && *url != ';' &&*url != '/' && Buffer != Bufend)
|
---|
[270] | 3095 | *(Buffer++) = *(url++);
|
---|
| 3096 | if(Buffer == args->data)
|
---|
| 3097 | return "Mountpoint required.";
|
---|
| 3098 | else if(Buffer >= Bufend-1)
|
---|
| 3099 | return "Parsing buffer too short.";
|
---|
| 3100 | *(Buffer++) = 0;
|
---|
| 3101 | }
|
---|
| 3102 |
|
---|
| 3103 | if(*url == '/') /* username and password */
|
---|
| 3104 | {
|
---|
| 3105 | ++url;
|
---|
| 3106 | args->user = Buffer;
|
---|
[502] | 3107 | while(*url && *url != '@' && *url != ';' && *url != ':' && Buffer != Bufend)
|
---|
[270] | 3108 | *(Buffer++) = *(url++);
|
---|
| 3109 | if(Buffer == args->user)
|
---|
| 3110 | return "Username cannot be empty.";
|
---|
| 3111 | else if(Buffer >= Bufend-1)
|
---|
| 3112 | return "Parsing buffer too short.";
|
---|
| 3113 | *(Buffer++) = 0;
|
---|
| 3114 |
|
---|
| 3115 | if(*url == ':') ++url;
|
---|
| 3116 |
|
---|
| 3117 | args->password = Buffer;
|
---|
[502] | 3118 | while(*url && *url != '@' && *url != ';' && Buffer != Bufend)
|
---|
[270] | 3119 | *(Buffer++) = *(url++);
|
---|
| 3120 | if(Buffer == args->password)
|
---|
| 3121 | return "Password cannot be empty.";
|
---|
| 3122 | else if(Buffer >= Bufend-1)
|
---|
| 3123 | return "Parsing buffer too short.";
|
---|
| 3124 | *(Buffer++) = 0;
|
---|
| 3125 | }
|
---|
| 3126 |
|
---|
| 3127 | if(*url == '@') /* server */
|
---|
| 3128 | {
|
---|
| 3129 | ++url;
|
---|
[502] | 3130 | if(*url != '@' && *url != ':')
|
---|
| 3131 | {
|
---|
| 3132 | args->server = Buffer;
|
---|
| 3133 | while(*url && *url != '@' && *url != ':' && *url != ';' && Buffer != Bufend)
|
---|
| 3134 | *(Buffer++) = *(url++);
|
---|
| 3135 | if(Buffer == args->server)
|
---|
| 3136 | return "Servername cannot be empty.";
|
---|
| 3137 | else if(Buffer >= Bufend-1)
|
---|
| 3138 | return "Parsing buffer too short.";
|
---|
| 3139 | *(Buffer++) = 0;
|
---|
| 3140 | }
|
---|
[270] | 3141 |
|
---|
| 3142 | if(*url == ':')
|
---|
| 3143 | {
|
---|
[502] | 3144 | ++url;
|
---|
| 3145 | args->port = Buffer;
|
---|
| 3146 | while(*url && *url != '@' && *url != ';' && Buffer != Bufend)
|
---|
| 3147 | *(Buffer++) = *(url++);
|
---|
| 3148 | if(Buffer == args->port)
|
---|
| 3149 | return "Port cannot be empty.";
|
---|
| 3150 | else if(Buffer >= Bufend-1)
|
---|
| 3151 | return "Parsing buffer too short.";
|
---|
| 3152 | *(Buffer++) = 0;
|
---|
[270] | 3153 | }
|
---|
[502] | 3154 |
|
---|
| 3155 | if(*url == '@') /* proxy */
|
---|
| 3156 | {
|
---|
| 3157 | ++url;
|
---|
| 3158 | args->proxyhost = Buffer;
|
---|
| 3159 | while(*url && *url != ':' && *url != ';' && Buffer != Bufend)
|
---|
| 3160 | *(Buffer++) = *(url++);
|
---|
| 3161 | if(Buffer == args->proxyhost)
|
---|
| 3162 | return "Proxy servername cannot be empty.";
|
---|
| 3163 | else if(Buffer >= Bufend-1)
|
---|
| 3164 | return "Parsing buffer too short.";
|
---|
| 3165 | *(Buffer++) = 0;
|
---|
| 3166 |
|
---|
| 3167 | if(*url == ':')
|
---|
| 3168 | {
|
---|
| 3169 | ++url;
|
---|
| 3170 | args->proxyport = Buffer;
|
---|
| 3171 | while(*url && *url != ';' && Buffer != Bufend)
|
---|
| 3172 | *(Buffer++) = *(url++);
|
---|
| 3173 | if(Buffer == args->proxyport)
|
---|
| 3174 | return "Proxy port cannot be empty.";
|
---|
| 3175 | else if(Buffer >= Bufend-1)
|
---|
| 3176 | return "Parsing buffer too short.";
|
---|
| 3177 | *(Buffer++) = 0;
|
---|
| 3178 | }
|
---|
| 3179 | }
|
---|
[270] | 3180 | }
|
---|
[502] | 3181 | if(*url == ';') /* NMEA */
|
---|
| 3182 | {
|
---|
| 3183 | args->nmea = ++url;
|
---|
| 3184 | while(*url)
|
---|
| 3185 | ++url;
|
---|
| 3186 | }
|
---|
[270] | 3187 |
|
---|
| 3188 | return *url ? "Garbage at end of server string." : 0;
|
---|
| 3189 | }
|
---|
| 3190 |
|
---|
[268] | 3191 | static int getargs(int argc, char **argv, struct Args *args)
|
---|
| 3192 | {
|
---|
| 3193 | int res = 1;
|
---|
| 3194 | int getoptr;
|
---|
| 3195 | int help = 0;
|
---|
| 3196 | char *t;
|
---|
| 3197 |
|
---|
| 3198 | args->server = "www.euref-ip.net";
|
---|
[502] | 3199 | args->port = "2101";
|
---|
[477] | 3200 | args->timeout = 60;
|
---|
[268] | 3201 | args->user = "";
|
---|
| 3202 | args->password = "";
|
---|
| 3203 | args->data = 0;
|
---|
| 3204 | args->headerfile = 0;
|
---|
[502] | 3205 | args->gpsephemeris = 0;
|
---|
| 3206 | args->glonassephemeris = 0;
|
---|
| 3207 | args->rinex3 = 0;
|
---|
| 3208 | args->nmea = 0;
|
---|
| 3209 | args->proxyhost = 0;
|
---|
| 3210 | args->proxyport = "2101";
|
---|
| 3211 | args->mode = AUTO;
|
---|
[268] | 3212 | help = 0;
|
---|
| 3213 |
|
---|
| 3214 | do
|
---|
| 3215 | {
|
---|
[477] | 3216 |
|
---|
[268] | 3217 | #ifdef NO_LONG_OPTS
|
---|
| 3218 | switch((getoptr = getopt(argc, argv, ARGOPT)))
|
---|
| 3219 | #else
|
---|
| 3220 | switch((getoptr = getopt_long(argc, argv, ARGOPT, opts, 0)))
|
---|
| 3221 | #endif
|
---|
| 3222 | {
|
---|
| 3223 | case 's': args->server = optarg; break;
|
---|
| 3224 | case 'u': args->user = optarg; break;
|
---|
| 3225 | case 'p': args->password = optarg; break;
|
---|
| 3226 | case 'd': args->data = optarg; break;
|
---|
| 3227 | case 'f': args->headerfile = optarg; break;
|
---|
[502] | 3228 | case 'E': args->gpsephemeris = optarg; break;
|
---|
| 3229 | case 'G': args->glonassephemeris = optarg; break;
|
---|
| 3230 | case 'r': args->port = optarg; break;
|
---|
| 3231 | case '3': args->rinex3 = 1; break;
|
---|
| 3232 | case 'S': args->proxyhost = optarg; break;
|
---|
| 3233 | case 'n': args->nmea = optarg; break;
|
---|
| 3234 | case 'R': args->proxyport = optarg; break;
|
---|
[268] | 3235 | case 'h': help=1; break;
|
---|
[502] | 3236 | case 'M':
|
---|
| 3237 | args->mode = 0;
|
---|
| 3238 | if (!strcmp(optarg,"n") || !strcmp(optarg,"ntrip1"))
|
---|
| 3239 | args->mode = NTRIP1;
|
---|
| 3240 | else if(!strcmp(optarg,"h") || !strcmp(optarg,"http"))
|
---|
| 3241 | args->mode = HTTP;
|
---|
| 3242 | else if(!strcmp(optarg,"r") || !strcmp(optarg,"rtsp"))
|
---|
| 3243 | args->mode = RTSP;
|
---|
| 3244 | else if(!strcmp(optarg,"a") || !strcmp(optarg,"auto"))
|
---|
| 3245 | args->mode = AUTO;
|
---|
| 3246 | else args->mode = atoi(optarg);
|
---|
| 3247 | if((args->mode == 0) || (args->mode >= END))
|
---|
| 3248 | {
|
---|
| 3249 | fprintf(stderr, "Mode %s unknown\n", optarg);
|
---|
[268] | 3250 | res = 0;
|
---|
[502] | 3251 | }
|
---|
[268] | 3252 | break;
|
---|
[502] | 3253 | case 't':
|
---|
[477] | 3254 | args->timeout = strtoul(optarg, &t, 10);
|
---|
| 3255 | if((t && *t) || args->timeout < 0)
|
---|
| 3256 | res = 0;
|
---|
| 3257 | break;
|
---|
| 3258 |
|
---|
[270] | 3259 | case 1:
|
---|
| 3260 | {
|
---|
| 3261 | const char *err;
|
---|
| 3262 | if((err = geturl(optarg, args)))
|
---|
| 3263 | {
|
---|
[318] | 3264 | RTCM3Error("%s\n\n", err);
|
---|
[270] | 3265 | res = 0;
|
---|
| 3266 | }
|
---|
| 3267 | }
|
---|
| 3268 | break;
|
---|
[268] | 3269 | case -1: break;
|
---|
| 3270 | }
|
---|
| 3271 | } while(getoptr != -1 || !res);
|
---|
| 3272 |
|
---|
| 3273 | datestr[0] = datestr[7];
|
---|
| 3274 | datestr[1] = datestr[8];
|
---|
| 3275 | datestr[2] = datestr[9];
|
---|
| 3276 | datestr[3] = datestr[10];
|
---|
| 3277 | datestr[5] = datestr[12];
|
---|
| 3278 | datestr[6] = datestr[13];
|
---|
| 3279 | datestr[8] = datestr[15];
|
---|
| 3280 | datestr[9] = datestr[16];
|
---|
| 3281 | datestr[4] = datestr[7] = '-';
|
---|
| 3282 | datestr[10] = 0;
|
---|
| 3283 |
|
---|
[502] | 3284 | if(args->gpsephemeris && args->glonassephemeris && args->rinex3)
|
---|
[268] | 3285 | {
|
---|
[503] | 3286 | RTCM3Error("RINEX3 produces a combined ephemeris file, but 2 files were specified.\n"
|
---|
| 3287 | "Please specify only one navigation file.\n");
|
---|
[502] | 3288 | res = 0;
|
---|
| 3289 | }
|
---|
| 3290 | else if(!res || help)
|
---|
| 3291 | {
|
---|
[439] | 3292 | RTCM3Error("Version %s (%s) GPL" COMPILEDATE
|
---|
| 3293 | "\nUsage: %s -s server -u user ...\n"
|
---|
[502] | 3294 | " -d " LONG_OPT("--data ") "the requested data set\n"
|
---|
| 3295 | " -f " LONG_OPT("--headerfile ") "file for RINEX header information\n"
|
---|
| 3296 | " -s " LONG_OPT("--server ") "the server name or address\n"
|
---|
| 3297 | " -p " LONG_OPT("--password ") "the login password\n"
|
---|
| 3298 | " -r " LONG_OPT("--port ") "the server port number (default 2101)\n"
|
---|
| 3299 | " -t " LONG_OPT("--timeout ") "timeout in seconds (default 60)\n"
|
---|
| 3300 | " -u " LONG_OPT("--user ") "the user name\n"
|
---|
| 3301 | " -E " LONG_OPT("--gpsephemeris ") "output file for GPS ephemeris data\n"
|
---|
| 3302 | " -G " LONG_OPT("--glonassephemeris ") "output file for GLONASS ephemeris data\n"
|
---|
| 3303 | " -3 " LONG_OPT("--rinex3 ") "output RINEX type 3 data\n"
|
---|
| 3304 | " -S " LONG_OPT("--proxyhost ") "proxy name or address\n"
|
---|
| 3305 | " -R " LONG_OPT("--proxyport ") "proxy port, optional (default 2101)\n"
|
---|
| 3306 | " -n " LONG_OPT("--nmea ") "NMEA string for sending to server\n"
|
---|
| 3307 | " -M " LONG_OPT("--mode ") "mode for data request\n"
|
---|
| 3308 | " Valid modes are:\n"
|
---|
| 3309 | " 1, h, http NTRIP Version 2.0 Caster in TCP/IP mode\n"
|
---|
| 3310 | " 2, r, rtsp NTRIP Version 2.0 Caster in RTSP/RTP mode\n"
|
---|
| 3311 | " 3, n, ntrip1 NTRIP Version 1.0 Caster\n"
|
---|
| 3312 | " 4, a, auto automatic detection (default)\n"
|
---|
| 3313 | "or using an URL:\n%s ntrip:data[/user[:password]][@[server][:port][@proxyhost[:proxyport]]][;nmea]\n"
|
---|
[270] | 3314 | , revisionstr, datestr, argv[0], argv[0]);
|
---|
[268] | 3315 | exit(1);
|
---|
| 3316 | }
|
---|
| 3317 | return res;
|
---|
| 3318 | }
|
---|
| 3319 |
|
---|
| 3320 | /* let the output complete a block if necessary */
|
---|
| 3321 | static void signalhandler(int sig)
|
---|
| 3322 | {
|
---|
| 3323 | if(!stop)
|
---|
| 3324 | {
|
---|
[318] | 3325 | RTCM3Error("Stop signal number %d received. "
|
---|
[268] | 3326 | "Trying to terminate gentle.\n", sig);
|
---|
| 3327 | stop = 1;
|
---|
| 3328 | alarm(1);
|
---|
| 3329 | }
|
---|
| 3330 | }
|
---|
| 3331 |
|
---|
[1091] | 3332 | #ifndef WINDOWSVERSION
|
---|
| 3333 | static void WaitMicro(int mic)
|
---|
| 3334 | {
|
---|
| 3335 | struct timeval tv;
|
---|
| 3336 | tv.tv_sec = mic/1000000;
|
---|
| 3337 | tv.tv_usec = mic%1000000;
|
---|
| 3338 | #ifdef DEBUG
|
---|
| 3339 | fprintf(stderr, "Waiting %d micro seconds\n", mic);
|
---|
| 3340 | #endif
|
---|
| 3341 | select(0, 0, 0, 0, &tv);
|
---|
| 3342 | }
|
---|
| 3343 | #else /* WINDOWSVERSION */
|
---|
| 3344 | void WaitMicro(int mic)
|
---|
| 3345 | {
|
---|
| 3346 | Sleep(mic/1000);
|
---|
| 3347 | }
|
---|
| 3348 | #endif /* WINDOWSVERSION */
|
---|
| 3349 |
|
---|
[502] | 3350 | #define ALARMTIME (2*60)
|
---|
| 3351 |
|
---|
[268] | 3352 | /* for some reason we had to abort hard (maybe waiting for data */
|
---|
| 3353 | #ifdef __GNUC__
|
---|
| 3354 | static __attribute__ ((noreturn)) void signalhandler_alarm(
|
---|
| 3355 | int sig __attribute__((__unused__)))
|
---|
| 3356 | #else /* __GNUC__ */
|
---|
| 3357 | static void signalhandler_alarm(int sig)
|
---|
| 3358 | #endif /* __GNUC__ */
|
---|
| 3359 | {
|
---|
[318] | 3360 | RTCM3Error("Programm forcefully terminated.\n");
|
---|
[268] | 3361 | exit(1);
|
---|
| 3362 | }
|
---|
| 3363 |
|
---|
[27] | 3364 | int main(int argc, char **argv)
|
---|
| 3365 | {
|
---|
| 3366 | struct Args args;
|
---|
| 3367 | struct RTCM3ParserData Parser;
|
---|
| 3368 |
|
---|
| 3369 | setbuf(stdout, 0);
|
---|
| 3370 | setbuf(stdin, 0);
|
---|
| 3371 | setbuf(stderr, 0);
|
---|
| 3372 |
|
---|
[2487] | 3373 | fixrevision();
|
---|
[27] | 3374 |
|
---|
| 3375 | signal(SIGINT, signalhandler);
|
---|
| 3376 | signal(SIGALRM,signalhandler_alarm);
|
---|
| 3377 | signal(SIGQUIT,signalhandler);
|
---|
| 3378 | signal(SIGTERM,signalhandler);
|
---|
| 3379 | signal(SIGPIPE,signalhandler);
|
---|
| 3380 | memset(&Parser, 0, sizeof(Parser));
|
---|
| 3381 | {
|
---|
| 3382 | time_t tim;
|
---|
| 3383 | tim = time(0) - ((10*365+2+5)*24*60*60+LEAPSECONDS);
|
---|
| 3384 | Parser.GPSWeek = tim/(7*24*60*60);
|
---|
| 3385 | Parser.GPSTOW = tim%(7*24*60*60);
|
---|
| 3386 | }
|
---|
| 3387 |
|
---|
| 3388 | if(getargs(argc, argv, &args))
|
---|
| 3389 | {
|
---|
[1088] | 3390 | int sockfd, numbytes;
|
---|
[27] | 3391 | char buf[MAXDATASIZE];
|
---|
[502] | 3392 | struct sockaddr_in their_addr; /* connector's address information */
|
---|
[27] | 3393 | struct hostent *he;
|
---|
[502] | 3394 | struct servent *se;
|
---|
| 3395 | const char *server, *port, *proxyserver = 0;
|
---|
| 3396 | char proxyport[6];
|
---|
| 3397 | char *b;
|
---|
| 3398 | long i;
|
---|
| 3399 | struct timeval tv;
|
---|
[27] | 3400 |
|
---|
[502] | 3401 | alarm(ALARMTIME);
|
---|
| 3402 |
|
---|
[27] | 3403 | Parser.headerfile = args.headerfile;
|
---|
[502] | 3404 | Parser.glonassephemeris = args.glonassephemeris;
|
---|
| 3405 | Parser.gpsephemeris = args.gpsephemeris;
|
---|
| 3406 | Parser.rinex3 = args.rinex3;
|
---|
[27] | 3407 |
|
---|
[502] | 3408 | if(args.proxyhost)
|
---|
[27] | 3409 | {
|
---|
[502] | 3410 | int p;
|
---|
| 3411 | if((i = strtol(args.port, &b, 10)) && (!b || !*b))
|
---|
| 3412 | p = i;
|
---|
| 3413 | else if(!(se = getservbyname(args.port, 0)))
|
---|
| 3414 | {
|
---|
| 3415 | RTCM3Error("Can't resolve port %s.", args.port);
|
---|
| 3416 | exit(1);
|
---|
| 3417 | }
|
---|
| 3418 | else
|
---|
| 3419 | {
|
---|
| 3420 | p = ntohs(se->s_port);
|
---|
| 3421 | }
|
---|
| 3422 | snprintf(proxyport, sizeof(proxyport), "%d", p);
|
---|
| 3423 | port = args.proxyport;
|
---|
| 3424 | proxyserver = args.server;
|
---|
| 3425 | server = args.proxyhost;
|
---|
| 3426 | }
|
---|
| 3427 | else
|
---|
| 3428 | {
|
---|
| 3429 | server = args.server;
|
---|
| 3430 | port = args.port;
|
---|
| 3431 | }
|
---|
| 3432 |
|
---|
| 3433 | memset(&their_addr, 0, sizeof(struct sockaddr_in));
|
---|
| 3434 | if((i = strtol(port, &b, 10)) && (!b || !*b))
|
---|
| 3435 | their_addr.sin_port = htons(i);
|
---|
| 3436 | else if(!(se = getservbyname(port, 0)))
|
---|
| 3437 | {
|
---|
| 3438 | RTCM3Error("Can't resolve port %s.", port);
|
---|
[27] | 3439 | exit(1);
|
---|
| 3440 | }
|
---|
[502] | 3441 | else
|
---|
| 3442 | {
|
---|
| 3443 | their_addr.sin_port = se->s_port;
|
---|
| 3444 | }
|
---|
| 3445 | if(!(he=gethostbyname(server)))
|
---|
| 3446 | {
|
---|
| 3447 | RTCM3Error("Server name lookup failed for '%s'.\n", server);
|
---|
| 3448 | exit(1);
|
---|
| 3449 | }
|
---|
[27] | 3450 | if((sockfd = socket(AF_INET, SOCK_STREAM, 0)) == -1)
|
---|
| 3451 | {
|
---|
[502] | 3452 | perror("socket");
|
---|
[27] | 3453 | exit(1);
|
---|
| 3454 | }
|
---|
[477] | 3455 |
|
---|
| 3456 | tv.tv_sec = args.timeout;
|
---|
| 3457 | tv.tv_usec = 0;
|
---|
| 3458 | if(setsockopt(sockfd, SOL_SOCKET, SO_RCVTIMEO, (struct timeval *)&tv, sizeof(struct timeval) ) == -1)
|
---|
| 3459 | {
|
---|
| 3460 | RTCM3Error("Function setsockopt: %s\n", strerror(errno));
|
---|
| 3461 | exit(1);
|
---|
| 3462 | }
|
---|
| 3463 |
|
---|
[502] | 3464 | their_addr.sin_family = AF_INET;
|
---|
[27] | 3465 | their_addr.sin_addr = *((struct in_addr *)he->h_addr);
|
---|
[502] | 3466 |
|
---|
| 3467 | if(args.data && args.mode == RTSP)
|
---|
[27] | 3468 | {
|
---|
[502] | 3469 | struct sockaddr_in local;
|
---|
| 3470 | int sockudp, localport;
|
---|
| 3471 | int cseq = 1;
|
---|
| 3472 | socklen_t len;
|
---|
[27] | 3473 |
|
---|
[502] | 3474 | if((sockudp = socket(AF_INET, SOCK_DGRAM, 0)) == -1)
|
---|
| 3475 | {
|
---|
| 3476 | perror("socket");
|
---|
| 3477 | exit(1);
|
---|
| 3478 | }
|
---|
| 3479 | /* fill structure with local address information for UDP */
|
---|
| 3480 | memset(&local, 0, sizeof(local));
|
---|
[1088] | 3481 | local.sin_family = AF_INET;
|
---|
[502] | 3482 | local.sin_port = htons(0);
|
---|
[1088] | 3483 | local.sin_addr.s_addr = htonl(INADDR_ANY);
|
---|
[502] | 3484 | len = sizeof(local);
|
---|
[1088] | 3485 | /* bind() in order to get a random RTP client_port */
|
---|
[502] | 3486 | if((bind(sockudp, (struct sockaddr *)&local, len)) < 0)
|
---|
| 3487 | {
|
---|
| 3488 | perror("bind");
|
---|
| 3489 | exit(1);
|
---|
| 3490 | }
|
---|
[1088] | 3491 | if((getsockname(sockudp, (struct sockaddr*)&local, &len)) != -1)
|
---|
[502] | 3492 | {
|
---|
[1088] | 3493 | localport = ntohs(local.sin_port);
|
---|
[502] | 3494 | }
|
---|
| 3495 | else
|
---|
| 3496 | {
|
---|
[1088] | 3497 | perror("local access failed");
|
---|
[502] | 3498 | exit(1);
|
---|
| 3499 | }
|
---|
| 3500 | if(connect(sockfd, (struct sockaddr *)&their_addr,
|
---|
| 3501 | sizeof(struct sockaddr)) == -1)
|
---|
| 3502 | {
|
---|
| 3503 | perror("connect");
|
---|
| 3504 | exit(1);
|
---|
| 3505 | }
|
---|
[27] | 3506 | i=snprintf(buf, MAXDATASIZE-40, /* leave some space for login */
|
---|
[1088] | 3507 | "SETUP rtsp://%s%s%s/%s RTSP/1.0\r\n"
|
---|
| 3508 | "CSeq: %d\r\n"
|
---|
[502] | 3509 | "Ntrip-Version: Ntrip/2.0\r\n"
|
---|
| 3510 | "Ntrip-Component: Ntripclient\r\n"
|
---|
[27] | 3511 | "User-Agent: %s/%s\r\n"
|
---|
[502] | 3512 | "Transport: RTP/GNSS;unicast;client_port=%u\r\n"
|
---|
| 3513 | "Authorization: Basic ",
|
---|
| 3514 | args.server, proxyserver ? ":" : "", proxyserver ? args.port : "",
|
---|
| 3515 | args.data, cseq++, AGENTSTRING, revisionstr, localport);
|
---|
[479] | 3516 | if(i > MAXDATASIZE-40 || i < 0) /* second check for old glibc */
|
---|
[27] | 3517 | {
|
---|
[318] | 3518 | RTCM3Error("Requested data too long\n");
|
---|
[27] | 3519 | exit(1);
|
---|
| 3520 | }
|
---|
[339] | 3521 | i += encode(buf+i, MAXDATASIZE-i-4, args.user, args.password);
|
---|
| 3522 | if(i > MAXDATASIZE-4)
|
---|
[27] | 3523 | {
|
---|
[318] | 3524 | RTCM3Error("Username and/or password too long\n");
|
---|
[27] | 3525 | exit(1);
|
---|
| 3526 | }
|
---|
[339] | 3527 | buf[i++] = '\r';
|
---|
| 3528 | buf[i++] = '\n';
|
---|
| 3529 | buf[i++] = '\r';
|
---|
| 3530 | buf[i++] = '\n';
|
---|
[502] | 3531 | if(args.nmea)
|
---|
[27] | 3532 | {
|
---|
[502] | 3533 | int j = snprintf(buf+i, MAXDATASIZE-i, "%s\r\n", args.nmea);
|
---|
| 3534 | if(j >= 0 && j < MAXDATASIZE-i)
|
---|
| 3535 | i += j;
|
---|
| 3536 | else
|
---|
[27] | 3537 | {
|
---|
[502] | 3538 | RTCM3Error("NMEA string too long\n");
|
---|
| 3539 | exit(1);
|
---|
| 3540 | }
|
---|
| 3541 | }
|
---|
| 3542 | if(send(sockfd, buf, (size_t)i, 0) != i)
|
---|
| 3543 | {
|
---|
| 3544 | perror("send");
|
---|
| 3545 | exit(1);
|
---|
| 3546 | }
|
---|
| 3547 | if((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) != -1)
|
---|
| 3548 | {
|
---|
| 3549 | if(numbytes >= 17 && !strncmp(buf, "RTSP/1.0 200 OK\r\n", 17))
|
---|
[744] | 3550 | {
|
---|
[502] | 3551 | int serverport = 0, session = 0;
|
---|
| 3552 | const char *portcheck = "server_port=";
|
---|
| 3553 | const char *sessioncheck = "session: ";
|
---|
| 3554 | int l = strlen(portcheck)-1;
|
---|
| 3555 | int j=0;
|
---|
| 3556 | for(i = 0; j != l && i < numbytes-l; ++i)
|
---|
[27] | 3557 | {
|
---|
[502] | 3558 | for(j = 0; j < l && tolower(buf[i+j]) == portcheck[j]; ++j)
|
---|
| 3559 | ;
|
---|
| 3560 | }
|
---|
| 3561 | if(i == numbytes-l)
|
---|
| 3562 | {
|
---|
| 3563 | RTCM3Error("No server port number found\n");
|
---|
| 3564 | exit(1);
|
---|
| 3565 | }
|
---|
| 3566 | else
|
---|
| 3567 | {
|
---|
| 3568 | i+=l;
|
---|
| 3569 | while(i < numbytes && buf[i] >= '0' && buf[i] <= '9')
|
---|
| 3570 | serverport = serverport * 10 + buf[i++]-'0';
|
---|
| 3571 | if(buf[i] != '\r' && buf[i] != ';')
|
---|
[27] | 3572 | {
|
---|
[502] | 3573 | RTCM3Error("Could not extract server port\n");
|
---|
| 3574 | exit(1);
|
---|
[27] | 3575 | }
|
---|
[502] | 3576 | }
|
---|
| 3577 | l = strlen(sessioncheck)-1;
|
---|
| 3578 | j=0;
|
---|
| 3579 | for(i = 0; j != l && i < numbytes-l; ++i)
|
---|
| 3580 | {
|
---|
| 3581 | for(j = 0; j < l && tolower(buf[i+j]) == sessioncheck[j]; ++j)
|
---|
| 3582 | ;
|
---|
| 3583 | }
|
---|
| 3584 | if(i == numbytes-l)
|
---|
| 3585 | {
|
---|
| 3586 | RTCM3Error("No session number found\n");
|
---|
[27] | 3587 | exit(1);
|
---|
| 3588 | }
|
---|
[502] | 3589 | else
|
---|
| 3590 | {
|
---|
| 3591 | i+=l;
|
---|
| 3592 | while(i < numbytes && buf[i] >= '0' && buf[i] <= '9')
|
---|
| 3593 | session = session * 10 + buf[i++]-'0';
|
---|
| 3594 | if(buf[i] != '\r')
|
---|
| 3595 | {
|
---|
| 3596 | RTCM3Error("Could not extract session number\n");
|
---|
| 3597 | exit(1);
|
---|
| 3598 | }
|
---|
| 3599 | }
|
---|
| 3600 |
|
---|
| 3601 | i = snprintf(buf, MAXDATASIZE,
|
---|
[1088] | 3602 | "PLAY rtsp://%s%s%s/%s RTSP/1.0\r\n"
|
---|
[502] | 3603 | "CSeq: %d\r\n"
|
---|
| 3604 | "Session: %d\r\n"
|
---|
[1088] | 3605 | "\r\n",
|
---|
[502] | 3606 | args.server, proxyserver ? ":" : "", proxyserver ? args.port : "",
|
---|
| 3607 | args.data, cseq++, session);
|
---|
| 3608 |
|
---|
| 3609 | if(i > MAXDATASIZE || i < 0) /* second check for old glibc */
|
---|
| 3610 | {
|
---|
| 3611 | RTCM3Error("Requested data too long\n");
|
---|
| 3612 | exit(1);
|
---|
| 3613 | }
|
---|
| 3614 | if(send(sockfd, buf, (size_t)i, 0) != i)
|
---|
| 3615 | {
|
---|
| 3616 | perror("send");
|
---|
| 3617 | exit(1);
|
---|
| 3618 | }
|
---|
| 3619 | if((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) != -1)
|
---|
| 3620 | {
|
---|
| 3621 | if(numbytes >= 17 && !strncmp(buf, "RTSP/1.0 200 OK\r\n", 17))
|
---|
| 3622 | {
|
---|
| 3623 | struct sockaddr_in addrRTP;
|
---|
| 3624 | /* fill structure with caster address information for UDP */
|
---|
| 3625 | memset(&addrRTP, 0, sizeof(addrRTP));
|
---|
[1088] | 3626 | addrRTP.sin_family = AF_INET;
|
---|
[502] | 3627 | addrRTP.sin_port = htons(serverport);
|
---|
| 3628 | their_addr.sin_addr = *((struct in_addr *)he->h_addr);
|
---|
| 3629 | len = sizeof(addrRTP);
|
---|
| 3630 | int ts = 0;
|
---|
| 3631 | int sn = 0;
|
---|
| 3632 | int ssrc = 0;
|
---|
| 3633 | int init = 0;
|
---|
| 3634 | int u, v, w;
|
---|
| 3635 | while(!stop && (i = recvfrom(sockudp, buf, 1526, 0,
|
---|
| 3636 | (struct sockaddr*) &addrRTP, &len)) > 0)
|
---|
| 3637 | {
|
---|
| 3638 | alarm(ALARMTIME);
|
---|
| 3639 | if(i >= 12+1 && (unsigned char)buf[0] == (2 << 6) && buf[1] == 0x60)
|
---|
| 3640 | {
|
---|
| 3641 | u= ((unsigned char)buf[2]<<8)+(unsigned char)buf[3];
|
---|
| 3642 | v = ((unsigned char)buf[4]<<24)+((unsigned char)buf[5]<<16)
|
---|
| 3643 | +((unsigned char)buf[6]<<8)+(unsigned char)buf[7];
|
---|
| 3644 | w = ((unsigned char)buf[8]<<24)+((unsigned char)buf[9]<<16)
|
---|
| 3645 | +((unsigned char)buf[10]<<8)+(unsigned char)buf[11];
|
---|
| 3646 |
|
---|
| 3647 | if(init)
|
---|
| 3648 | {
|
---|
[1091] | 3649 | int z;
|
---|
[502] | 3650 | if(u < -30000 && sn > 30000) sn -= 0xFFFF;
|
---|
| 3651 | if(ssrc != w || ts > v)
|
---|
| 3652 | {
|
---|
| 3653 | RTCM3Error("Illegal UDP data received.\n");
|
---|
| 3654 | exit(1);
|
---|
| 3655 | }
|
---|
| 3656 | if(u > sn) /* don't show out-of-order packets */
|
---|
[1091] | 3657 | for(z = 12; z < i && !stop; ++z)
|
---|
| 3658 | HandleByte(&Parser, (unsigned int) buf[z]);
|
---|
[502] | 3659 | }
|
---|
| 3660 | sn = u; ts = v; ssrc = w; init = 1;
|
---|
| 3661 | }
|
---|
| 3662 | else
|
---|
| 3663 | {
|
---|
| 3664 | RTCM3Error("Illegal UDP header.\n");
|
---|
| 3665 | exit(1);
|
---|
| 3666 | }
|
---|
| 3667 | }
|
---|
| 3668 | }
|
---|
| 3669 | i = snprintf(buf, MAXDATASIZE,
|
---|
[1088] | 3670 | "TEARDOWN rtsp://%s%s%s/%s RTSP/1.0\r\n"
|
---|
[502] | 3671 | "CSeq: %d\r\n"
|
---|
| 3672 | "Session: %d\r\n"
|
---|
[1088] | 3673 | "\r\n",
|
---|
[502] | 3674 | args.server, proxyserver ? ":" : "", proxyserver ? args.port : "",
|
---|
| 3675 | args.data, cseq++, session);
|
---|
| 3676 |
|
---|
| 3677 | if(i > MAXDATASIZE || i < 0) /* second check for old glibc */
|
---|
| 3678 | {
|
---|
| 3679 | RTCM3Error("Requested data too long\n");
|
---|
| 3680 | exit(1);
|
---|
| 3681 | }
|
---|
| 3682 | if(send(sockfd, buf, (size_t)i, 0) != i)
|
---|
| 3683 | {
|
---|
| 3684 | perror("send");
|
---|
| 3685 | exit(1);
|
---|
| 3686 | }
|
---|
| 3687 | }
|
---|
| 3688 | else
|
---|
| 3689 | {
|
---|
| 3690 | RTCM3Error("Could not start data stream.\n");
|
---|
| 3691 | exit(1);
|
---|
| 3692 | }
|
---|
[27] | 3693 | }
|
---|
| 3694 | else
|
---|
| 3695 | {
|
---|
[502] | 3696 | RTCM3Error("Could not setup initial control connection.\n");
|
---|
| 3697 | exit(1);
|
---|
[27] | 3698 | }
|
---|
| 3699 | }
|
---|
[502] | 3700 | else
|
---|
| 3701 | {
|
---|
| 3702 | perror("recv");
|
---|
| 3703 | exit(1);
|
---|
| 3704 | }
|
---|
[27] | 3705 | }
|
---|
| 3706 | else
|
---|
| 3707 | {
|
---|
[502] | 3708 | if(connect(sockfd, (struct sockaddr *)&their_addr,
|
---|
| 3709 | sizeof(struct sockaddr)) == -1)
|
---|
[27] | 3710 | {
|
---|
[502] | 3711 | perror("connect");
|
---|
| 3712 | exit(1);
|
---|
[27] | 3713 | }
|
---|
[502] | 3714 | if(!args.data)
|
---|
| 3715 | {
|
---|
| 3716 | i = snprintf(buf, MAXDATASIZE,
|
---|
| 3717 | "GET %s%s%s%s/ HTTP/1.0\r\n"
|
---|
| 3718 | "Host: %s\r\n%s"
|
---|
| 3719 | "User-Agent: %s/%s\r\n"
|
---|
[646] | 3720 | "Connection: close\r\n"
|
---|
[502] | 3721 | "\r\n"
|
---|
| 3722 | , proxyserver ? "http://" : "", proxyserver ? proxyserver : "",
|
---|
| 3723 | proxyserver ? ":" : "", proxyserver ? proxyport : "",
|
---|
| 3724 | args.server, args.mode == NTRIP1 ? "" : "Ntrip-Version: Ntrip/2.0\r\n",
|
---|
| 3725 | AGENTSTRING, revisionstr);
|
---|
| 3726 | }
|
---|
| 3727 | else
|
---|
| 3728 | {
|
---|
| 3729 | i=snprintf(buf, MAXDATASIZE-40, /* leave some space for login */
|
---|
| 3730 | "GET %s%s%s%s/%s HTTP/1.0\r\n"
|
---|
| 3731 | "Host: %s\r\n%s"
|
---|
| 3732 | "User-Agent: %s/%s\r\n"
|
---|
[646] | 3733 | "Connection: close\r\n"
|
---|
[502] | 3734 | "Authorization: Basic "
|
---|
| 3735 | , proxyserver ? "http://" : "", proxyserver ? proxyserver : "",
|
---|
| 3736 | proxyserver ? ":" : "", proxyserver ? proxyport : "",
|
---|
| 3737 | args.data, args.server,
|
---|
| 3738 | args.mode == NTRIP1 ? "" : "Ntrip-Version: Ntrip/2.0\r\n",
|
---|
| 3739 | AGENTSTRING, revisionstr);
|
---|
| 3740 | if(i > MAXDATASIZE-40 || i < 0) /* second check for old glibc */
|
---|
| 3741 | {
|
---|
| 3742 | RTCM3Error("Requested data too long\n");
|
---|
| 3743 | exit(1);
|
---|
| 3744 | }
|
---|
| 3745 | i += encode(buf+i, MAXDATASIZE-i-4, args.user, args.password);
|
---|
| 3746 | if(i > MAXDATASIZE-4)
|
---|
| 3747 | {
|
---|
| 3748 | RTCM3Error("Username and/or password too long\n");
|
---|
| 3749 | exit(1);
|
---|
| 3750 | }
|
---|
| 3751 | buf[i++] = '\r';
|
---|
| 3752 | buf[i++] = '\n';
|
---|
| 3753 | buf[i++] = '\r';
|
---|
| 3754 | buf[i++] = '\n';
|
---|
| 3755 | if(args.nmea)
|
---|
| 3756 | {
|
---|
| 3757 | int j = snprintf(buf+i, MAXDATASIZE-i, "%s\r\n", args.nmea);
|
---|
| 3758 | if(j >= 0 && j < MAXDATASIZE-i)
|
---|
| 3759 | i += j;
|
---|
| 3760 | else
|
---|
| 3761 | {
|
---|
| 3762 | RTCM3Error("NMEA string too long\n");
|
---|
| 3763 | exit(1);
|
---|
| 3764 | }
|
---|
| 3765 | }
|
---|
| 3766 | }
|
---|
| 3767 | if(send(sockfd, buf, (size_t)i, 0) != i)
|
---|
| 3768 | {
|
---|
| 3769 | perror("send");
|
---|
| 3770 | exit(1);
|
---|
| 3771 | }
|
---|
| 3772 | if(args.data)
|
---|
| 3773 | {
|
---|
| 3774 | int k = 0;
|
---|
| 3775 | int chunkymode = 0;
|
---|
| 3776 | int starttime = time(0);
|
---|
| 3777 | int lastout = starttime;
|
---|
| 3778 | int totalbytes = 0;
|
---|
| 3779 | int chunksize = 0;
|
---|
| 3780 |
|
---|
| 3781 | while(!stop && (numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) != -1)
|
---|
| 3782 | {
|
---|
[1091] | 3783 | if(numbytes > 0)
|
---|
| 3784 | alarm(ALARMTIME);
|
---|
| 3785 | else
|
---|
| 3786 | {
|
---|
| 3787 | WaitMicro(100);
|
---|
| 3788 | continue;
|
---|
| 3789 | }
|
---|
[502] | 3790 | if(!k)
|
---|
| 3791 | {
|
---|
| 3792 | if(numbytes > 17 && (!strncmp(buf, "HTTP/1.1 200 OK\r\n", 17)
|
---|
| 3793 | || !strncmp(buf, "HTTP/1.0 200 OK\r\n", 17)))
|
---|
[744] | 3794 | {
|
---|
[502] | 3795 | const char *datacheck = "Content-Type: gnss/data\r\n";
|
---|
| 3796 | const char *chunkycheck = "Transfer-Encoding: chunked\r\n";
|
---|
| 3797 | int l = strlen(datacheck)-1;
|
---|
| 3798 | int j=0;
|
---|
| 3799 | for(i = 0; j != l && i < numbytes-l; ++i)
|
---|
| 3800 | {
|
---|
| 3801 | for(j = 0; j < l && buf[i+j] == datacheck[j]; ++j)
|
---|
| 3802 | ;
|
---|
| 3803 | }
|
---|
| 3804 | if(i == numbytes-l)
|
---|
| 3805 | {
|
---|
| 3806 | RTCM3Error("No 'Content-Type: gnss/data' found\n");
|
---|
| 3807 | exit(1);
|
---|
| 3808 | }
|
---|
| 3809 | l = strlen(chunkycheck)-1;
|
---|
| 3810 | j=0;
|
---|
| 3811 | for(i = 0; j != l && i < numbytes-l; ++i)
|
---|
| 3812 | {
|
---|
| 3813 | for(j = 0; j < l && buf[i+j] == chunkycheck[j]; ++j)
|
---|
| 3814 | ;
|
---|
| 3815 | }
|
---|
| 3816 | if(i < numbytes-l)
|
---|
| 3817 | chunkymode = 1;
|
---|
[1091] | 3818 | }
|
---|
[502] | 3819 | else if(numbytes < 12 || strncmp("ICY 200 OK\r\n", buf, 12))
|
---|
| 3820 | {
|
---|
| 3821 | RTCM3Error("Could not get the requested data: ");
|
---|
| 3822 | for(k = 0; k < numbytes && buf[k] != '\n' && buf[k] != '\r'; ++k)
|
---|
| 3823 | {
|
---|
| 3824 | RTCM3Error("%c", isprint(buf[k]) ? buf[k] : '.');
|
---|
| 3825 | }
|
---|
| 3826 | RTCM3Error("\n");
|
---|
| 3827 | exit(1);
|
---|
| 3828 | }
|
---|
| 3829 | else if(args.mode != NTRIP1)
|
---|
| 3830 | {
|
---|
| 3831 | if(args.mode != AUTO)
|
---|
| 3832 | {
|
---|
| 3833 | RTCM3Error("NTRIP version 2 HTTP connection failed%s.\n",
|
---|
| 3834 | args.mode == AUTO ? ", falling back to NTRIP1" : "");
|
---|
| 3835 | }
|
---|
| 3836 | if(args.mode == HTTP)
|
---|
| 3837 | exit(1);
|
---|
| 3838 | }
|
---|
| 3839 | ++k;
|
---|
| 3840 | }
|
---|
| 3841 | else
|
---|
| 3842 | {
|
---|
| 3843 | if(chunkymode)
|
---|
| 3844 | {
|
---|
| 3845 | int stop = 0;
|
---|
| 3846 | int pos = 0;
|
---|
| 3847 | while(!stop && pos < numbytes)
|
---|
| 3848 | {
|
---|
| 3849 | switch(chunkymode)
|
---|
| 3850 | {
|
---|
| 3851 | case 1: /* reading number starts */
|
---|
| 3852 | chunksize = 0;
|
---|
| 3853 | ++chunkymode; /* no break */
|
---|
| 3854 | case 2: /* during reading number */
|
---|
| 3855 | i = buf[pos++];
|
---|
| 3856 | if(i >= '0' && i <= '9') chunksize = chunksize*16+i-'0';
|
---|
| 3857 | else if(i >= 'a' && i <= 'f') chunksize = chunksize*16+i-'a'+10;
|
---|
| 3858 | else if(i >= 'A' && i <= 'F') chunksize = chunksize*16+i-'A'+10;
|
---|
| 3859 | else if(i == '\r') ++chunkymode;
|
---|
[646] | 3860 | else if(i == ';') chunkymode = 5;
|
---|
[502] | 3861 | else stop = 1;
|
---|
| 3862 | break;
|
---|
| 3863 | case 3: /* scanning for return */
|
---|
| 3864 | if(buf[pos++] == '\n') chunkymode = chunksize ? 4 : 1;
|
---|
| 3865 | else stop = 1;
|
---|
| 3866 | break;
|
---|
| 3867 | case 4: /* output data */
|
---|
| 3868 | i = numbytes-pos;
|
---|
| 3869 | if(i > chunksize) i = chunksize;
|
---|
| 3870 | {
|
---|
| 3871 | int z;
|
---|
| 3872 | for(z = 0; z < i && !stop; ++z)
|
---|
| 3873 | HandleByte(&Parser, (unsigned int) buf[pos+z]);
|
---|
| 3874 | }
|
---|
| 3875 | totalbytes += i;
|
---|
| 3876 | chunksize -= i;
|
---|
| 3877 | pos += i;
|
---|
| 3878 | if(!chunksize)
|
---|
| 3879 | chunkymode = 1;
|
---|
| 3880 | break;
|
---|
[646] | 3881 | case 5:
|
---|
| 3882 | if(i == '\r') chunkymode = 3;
|
---|
| 3883 | break;
|
---|
[502] | 3884 | }
|
---|
| 3885 | }
|
---|
| 3886 | if(stop)
|
---|
| 3887 | {
|
---|
| 3888 | RTCM3Error("Error in chunky transfer encoding\n");
|
---|
| 3889 | break;
|
---|
| 3890 | }
|
---|
| 3891 | }
|
---|
| 3892 | else
|
---|
| 3893 | {
|
---|
| 3894 | totalbytes += numbytes;
|
---|
| 3895 | {
|
---|
| 3896 | int z;
|
---|
| 3897 | for(z = 0; z < numbytes && !stop; ++z)
|
---|
| 3898 | HandleByte(&Parser, (unsigned int) buf[z]);
|
---|
| 3899 | }
|
---|
| 3900 | }
|
---|
| 3901 | if(totalbytes < 0) /* overflow */
|
---|
| 3902 | {
|
---|
| 3903 | totalbytes = 0;
|
---|
| 3904 | starttime = time(0);
|
---|
| 3905 | lastout = starttime;
|
---|
| 3906 | }
|
---|
| 3907 | }
|
---|
| 3908 | }
|
---|
| 3909 | }
|
---|
| 3910 | else
|
---|
| 3911 | {
|
---|
| 3912 | while(!stop && (numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) > 0)
|
---|
| 3913 | {
|
---|
| 3914 | alarm(ALARMTIME);
|
---|
| 3915 | fwrite(buf, (size_t)numbytes, 1, stdout);
|
---|
| 3916 | }
|
---|
| 3917 | }
|
---|
| 3918 | close(sockfd);
|
---|
[27] | 3919 | }
|
---|
| 3920 | }
|
---|
| 3921 | return 0;
|
---|
| 3922 | }
|
---|
[268] | 3923 | #endif /* NO_RTCM3_MAIN */
|
---|