Changeset 320 in ntrip for trunk/BNC/RTCM3
- Timestamp:
- Nov 15, 2006, 7:32:49 PM (18 years ago)
- Location:
- trunk/BNC/RTCM3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTCM3/RTCM3Decoder.cpp
r297 r320 51 51 # define isinf(x) 0 52 52 #endif 53 54 // Error Handling 55 //////////////////////////////////////////////////////////////////////////// 56 void RTCM3Error(const char *fmt, ...) { 57 58 } 53 59 54 60 // Constructor -
trunk/BNC/RTCM3/rtcm3torinex.cpp
r284 r320 1 1 /* 2 2 Converter for RTCM3 data to RINEX. 3 $Id: rtcm3torinex.c pp,v 1.9 2006/11/08 16:08:32 mervartExp $3 $Id: rtcm3torinex.c,v 1.10 2006/11/15 12:31:31 stoecker Exp $ 4 4 Copyright (C) 2005-2006 by Dirk Stoecker <stoecker@euronik.eu> 5 5 … … 29 29 #include <math.h> 30 30 #include <signal.h> 31 #include <stdarg.h> 31 32 #include <stdio.h> 32 33 #include <stdlib.h> … … 50 51 51 52 /* CVS revision and version */ 52 static char revisionstr[] = "$Revision: 1. 9$";53 static char revisionstr[] = "$Revision: 1.10 $"; 53 54 54 55 static uint32_t CRC24(long size, const unsigned char *buf) … … 109 110 i = m - handle->Message; 110 111 if(i && m < e) 111 memmove(handle->Message, m, handle->MessageSize-i);112 memmove(handle->Message, m, (size_t)(handle->MessageSize-i)); 112 113 handle->MessageSize -= i; 113 114 … … 145 146 #define SKIPBITS(b) { LOADBITS(b) numbits -= (b); } 146 147 148 struct leapseconds { /* specify the day of leap second */ 149 int day; /* this is the day, where 23:59:59 exists 2 times */ 150 int month; /* not the next day! */ 151 int year; 152 int taicount; 153 }; 154 static const int months[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; 155 static const struct leapseconds leap[] = { 156 /*{31, 12, 1971, 11},*/ 157 /*{31, 12, 1972, 12},*/ 158 /*{31, 12, 1973, 13},*/ 159 /*{31, 12, 1974, 14},*/ 160 /*{31, 12, 1975, 15},*/ 161 /*{31, 12, 1976, 16},*/ 162 /*{31, 12, 1977, 17},*/ 163 /*{31, 12, 1978, 18},*/ 164 /*{31, 12, 1979, 19},*/ 165 {30, 06, 1981,20}, 166 {30, 06, 1982,21}, 167 {30, 06, 1983,22}, 168 {30, 06, 1985,23}, 169 {31, 12, 1987,24}, 170 {31, 12, 1989,25}, 171 {31, 12, 1990,26}, 172 {30, 06, 1992,27}, 173 {30, 06, 1993,28}, 174 {30, 06, 1994,29}, 175 {31, 12, 1995,30}, 176 {30, 06, 1997,31}, 177 {31, 12, 1998,32}, 178 {31, 12, 2005,33}, 179 {0,0,0,0} /* end marker */ 180 }; 181 #define GPSLEAPSTART 19 /* 19 leap seconds existed at 6.1.1980 */ 182 183 static int longyear(int year, int month) 184 { 185 if(!(year % 4) && (!(year % 400) || (year % 100))) 186 { 187 if(!month || month == 2) 188 return 1; 189 } 190 return 0; 191 } 192 193 static int gnumleap(int year, int month, int day) 194 { 195 int ls = 0; 196 const struct leapseconds *l; 197 198 for(l = leap; l->taicount && year >= l->year; ++l) 199 { 200 if(year > l->year || month > l->month || day > l->day) 201 ls = l->taicount - GPSLEAPSTART; 202 } 203 return ls; 204 } 205 206 static void updatetime(int *week, int *tow, int tk) 207 { 208 int y,m,d,k,l; 209 unsigned int j = *week*(7*24*60*60) + *tow + 5*24*60*60+3*60*60; 210 int glo_daynumber = 0, glo_timeofday; 211 for(y = 1980; j >= (unsigned int)(k = (l = (365+longyear(y,0)))*24*60*60) 212 + gnumleap(y+1,1,1); ++y) 213 { 214 j -= k; glo_daynumber += l; 215 } 216 for(m = 1; j >= (unsigned int)(k = (l = months[m]+longyear(y, m))*24*60*60) 217 + gnumleap(y, m+1, 1); ++m) 218 { 219 j -= k; glo_daynumber += l; 220 } 221 for(d = 1; j >= 24UL*60UL*60UL + gnumleap(y, m, d+1); ++d) 222 j -= 24*60*60; 223 glo_daynumber -= 16*365+4-d; 224 glo_timeofday = j-gnumleap(y, m, d); 225 226 if(tk < 5*60*1000 && glo_timeofday > 23*60*60) 227 *tow += 24*60*60; 228 else if(glo_timeofday < 5*60 && tk > 23*60*60*1000) 229 *tow -= 24*60*60; 230 *tow += tk/1000-glo_timeofday; 231 if(*tow < 0) {*tow += 24*60*60*7; --*week; } 232 if(*tow >= 24*60*60*7) {*tow -= 24*60*60*7; ++*week; } 233 } 234 147 235 int RTCM3Parser(struct RTCM3ParserData *handle) 148 236 { … … 155 243 uint64_t numbits = 0, bitfield = 0; 156 244 int size = handle->size, type; 245 int syncf, old = 0; 157 246 unsigned char *data = handle->Message+3; 158 247 … … 171 260 lastlockl1[i] = lastlockl2[i] = 0; 172 261 173 gnss = &handle->Data; 174 memset(gnss, 0, sizeof(*gnss)); 262 gnss = &handle->DataNew; 175 263 176 264 SKIPBITS(12) /* id */ … … 179 267 ++handle->GPSWeek; 180 268 handle->GPSTOW = i/1000; 269 if(gnss->week && (gnss->timeofweek != i || gnss->week 270 != handle->GPSWeek)) 271 { 272 handle->Data = *gnss; 273 memset(gnss, 0, sizeof(*gnss)); 274 old = 1; 275 } 181 276 gnss->timeofweek = i; 182 277 gnss->week = handle->GPSWeek; 183 278 184 SKIPBITS(1) /* sync */279 GETBITS(syncf,1) /* sync */ 185 280 GETBITS(i,5) 186 281 gnss->numsats = i; … … 299 394 handle->lastlockl2[i] = lastlockl2[i]; 300 395 } 301 if(wasamb) /* not RINEX compatible without */ 302 ret = 1; 303 else 304 ret = 2; 396 if(!syncf && !old) 397 { 398 handle->Data = *gnss; 399 memset(gnss, 0, sizeof(*gnss)); 400 } 401 if(!syncf || old) 402 { 403 if(wasamb) /* not RINEX compatible without */ 404 ret = 1; 405 else 406 ret = 2; 407 } 305 408 } 306 409 break; 410 case 1009: case 1010: case 1011: case 1012: 411 { 412 int lastlockl1[64]; 413 int lastlockl2[64]; 414 struct gnssdata *gnss; 415 int i, num; 416 int wasamb=0; 417 418 for(i = 0; i < 64; ++i) 419 lastlockl1[i] = lastlockl2[i] = 0; 420 421 gnss = &handle->DataNew; 422 423 SKIPBITS(12) /* id */; 424 GETBITS(i,27) /* tk */ 425 426 updatetime(&handle->GPSWeek, &handle->GPSTOW, i); 427 i = handle->GPSTOW*1000; 428 if(gnss->week && (gnss->timeofweek != i || gnss->week 429 != handle->GPSWeek)) 430 { 431 handle->Data = *gnss; 432 memset(gnss, 0, sizeof(*gnss)); 433 old = 1; 434 } 435 436 gnss->timeofweek = i; 437 gnss->week = handle->GPSWeek; 438 439 GETBITS(syncf,1) /* sync */ 440 GETBITS(i,5) 441 gnss->numsats += i; 442 443 SKIPBITS(4) /* smind, smint */ 444 445 for(num = gnss->numsats-i; num < gnss->numsats; ++num) 446 { 447 int sv, code, l1range, c,l,s,ce,le,se,amb=0; 448 449 GETBITS(sv, 6) 450 if(!sv || sv > 24) 451 { 452 --num; --gnss->numsats; 453 } 454 else 455 { 456 int freq; 457 gnss->satellites[num] = sv-1 + PRN_GLONASS_START; 458 /* L1 */ 459 GETBITS(code, 1) 460 GETBITS(freq, 5) 461 if(code) 462 { 463 c = GNSSDF_P1DATA; ce = GNSSENTRY_P1DATA; 464 l = GNSSDF_L1PDATA; le = GNSSENTRY_L1PDATA; 465 s = GNSSDF_S1PDATA; se = GNSSENTRY_S1PDATA; 466 } 467 else 468 { 469 c = GNSSDF_C1DATA; ce = GNSSENTRY_C1DATA; 470 l = GNSSDF_L1CDATA; le = GNSSENTRY_L1CDATA; 471 s = GNSSDF_S1CDATA; se = GNSSENTRY_S1CDATA; 472 } 473 GETBITS(l1range, 25) 474 if(l1range != 0x80000) 475 { 476 gnss->dataflags[num] |= c; 477 gnss->measdata[num][ce] = l1range*0.02; 478 } 479 GETBITSSIGN(i, 20) 480 if(i != 0x80000) 481 { 482 gnss->dataflags[num] |= l; 483 gnss->measdata[num][le] = l1range*0.02+i*0.0005; 484 } 485 GETBITS(i, 7) 486 lastlockl1[sv] = i; 487 if(handle->lastlockl1[sv] > i) 488 gnss->dataflags[num] |= GNSSDF_LOCKLOSSL1; 489 if(type == 1010 || type == 1012) 490 { 491 GETBITS(amb,7) 492 if(amb && (gnss->dataflags[num] & c)) 493 { 494 gnss->measdata[num][ce] += amb*599584.916; 495 gnss->measdata[num][le] += amb*599584.916; 496 ++wasamb; 497 } 498 GETBITS(i, 8) 499 if(i) 500 { 501 gnss->dataflags[num] |= s; 502 gnss->measdata[num][se] = i*0.25; 503 i /= 4*4; 504 if(i > 9) i = 9; 505 else if(i < 1) i = 1; 506 gnss->snrL1[num] = i; 507 } 508 } 509 gnss->measdata[num][le] /= GLO_WAVELENGTH_L1(freq-7); 510 if(type == 1011 || type == 1012) 511 { 512 /* L2 */ 513 GETBITS(code,2) 514 if(code) 515 { 516 c = GNSSDF_P2DATA; ce = GNSSENTRY_P2DATA; 517 l = GNSSDF_L2PDATA; le = GNSSENTRY_L2PDATA; 518 s = GNSSDF_S2PDATA; se = GNSSENTRY_S2PDATA; 519 } 520 else 521 { 522 c = GNSSDF_C2DATA; ce = GNSSENTRY_C2DATA; 523 l = GNSSDF_L2CDATA; le = GNSSENTRY_L2CDATA; 524 s = GNSSDF_S2CDATA; se = GNSSENTRY_S2CDATA; 525 } 526 GETBITSSIGN(i,14) 527 if(i != 0x2000) 528 { 529 gnss->dataflags[num] |= c; 530 gnss->measdata[num][ce] = l1range*0.02+i*0.02 531 +amb*599584.916; 532 } 533 GETBITSSIGN(i,20) 534 if(i != 0x80000) 535 { 536 gnss->dataflags[num] |= l; 537 gnss->measdata[num][le] = l1range*0.02+i*0.0005 538 +amb*599584.915; 539 } 540 GETBITS(i,7) 541 lastlockl2[sv] = i; 542 if(handle->lastlockl2[sv] > i) 543 gnss->dataflags[num] |= GNSSDF_LOCKLOSSL2; 544 if(type == 1012) 545 { 546 GETBITS(i, 8) 547 if(i) 548 { 549 gnss->dataflags[num] |= s; 550 gnss->measdata[num][se] = i*0.25; 551 i /= 4*4; 552 if(i > 9) i = 9; 553 else if(i < 1) i = 1; 554 gnss->snrL2[num] = i; 555 } 556 } 557 gnss->measdata[num][le] /= GLO_WAVELENGTH_L2(freq-7); 558 } 559 } 560 } 561 for(i = 0; i < 64; ++i) 562 { 563 handle->lastlockl1[i] = lastlockl1[i]; 564 handle->lastlockl2[i] = lastlockl2[i]; 565 } 566 if(!syncf && !old) 567 { 568 handle->Data = *gnss; 569 memset(gnss, 0, sizeof(*gnss)); 570 } 571 if(!syncf || old) 572 { 573 if(wasamb) /* not RINEX compatible without */ 574 ret = 1; 575 else 576 ret = 2; 577 } 578 } 579 break; 307 580 } 308 581 } … … 310 583 } 311 584 312 static int longyear(int year, int month) 313 { 314 if(!(year % 4) && (!(year % 400) || (year % 100))) 315 { 316 if(!month || month == 2) 317 return 1; 318 } 319 return 0; 320 } 321 322 void converttime(struct converttimeinfo *c, int week, int tow) 323 { 324 /* static variables */ 325 static const int months[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; 326 585 struct Header 586 { 587 const char *version; 588 const char *pgm; 589 const char *marker; 590 const char *observer; 591 const char *receiver; 592 const char *antenna; 593 const char *position; 594 const char *antennaposition; 595 const char *wavelength; 596 const char *typesofobs; /* should not be modified outside */ 597 const char *timeoffirstobs; /* should not be modified outside */ 598 }; 599 600 #define MAXHEADERLINES 50 601 #define MAXHEADERBUFFERSIZE 4096 602 struct HeaderData 603 { 604 union 605 { 606 struct Header named; 607 const char *unnamed[MAXHEADERLINES]; 608 } data; 609 int numheaders; 610 }; 611 612 struct converttimeinfo { 613 int second; /* seconds of GPS time [0..59] */ 614 int minute; /* minutes of GPS time [0..59] */ 615 int hour; /* hour of GPS time [0..24] */ 616 int day; /* day of GPS time [1..28..30(31)*/ 617 int month; /* month of GPS time [1..12]*/ 618 int year; /* year of GPS time [1980..] */ 619 }; 620 621 static void converttime(struct converttimeinfo *c, int week, int tow) 622 { 327 623 int i, k, doy, j; /* temporary variables */ 328 624 j = week*(7*24*60*60) + tow + 5*24*60*60; … … 343 639 } 344 640 345 struct Header 346 { 347 const char *version; 348 const char *pgm; 349 const char *marker; 350 const char *observer; 351 const char *receiver; 352 const char *antenna; 353 const char *position; 354 const char *antennaposition; 355 const char *wavelength; 356 const char *typesofobs; /* should not be modified outside */ 357 const char *timeoffirstobs; /* should not be modified outside */ 358 }; 359 360 #define MAXHEADERLINES 50 361 #define MAXHEADERBUFFERSIZE 4096 362 struct HeaderData 363 { 364 union 365 { 366 struct Header named; 367 const char *unnamed[MAXHEADERLINES]; 368 } data; 369 int numheaders; 370 }; 371 641 #ifndef NO_RTCM3_MAIN 642 void RTCM3Error(const char *fmt, ...) 643 { 644 va_list v; 645 va_start(v, fmt); 646 vfprintf(stderr, fmt, v); 647 va_end(v); 648 } 649 #endif 650 651 void RTCM3Text(const char *fmt, ...) 652 { 653 va_list v; 654 va_start(v, fmt); 655 vprintf(fmt, v); 656 va_end(v); 657 } 658 659 #define NUMSTARTSKIP 3 372 660 void HandleHeader(struct RTCM3ParserData *Parser) 373 661 { … … 375 663 char thebuffer[MAXHEADERBUFFERSIZE]; 376 664 char *buffer = thebuffer; 377 int buffersize = sizeof(thebuffer);665 size_t buffersize = sizeof(thebuffer); 378 666 int i; 379 667 … … 453 741 } 454 742 455 int flags = 0;743 int flags = Parser->startflags; 456 744 int data[RINEXENTRY_NUMBER]; 457 745 char tbuffer[6*RINEXENTRY_NUMBER+1]; … … 510 798 if((fh = fopen(Parser->headerfile, "r"))) 511 799 { 512 int siz;800 size_t siz; 513 801 char *lastblockstart; 514 802 if((siz = fread(buffer, 1, buffersize-1, fh)) > 0) … … 517 805 if(siz == buffersize) 518 806 { 519 fprintf(stderr,"Header file is too large. Only %d bytes read.",807 RTCM3Error("Header file is too large. Only %d bytes read.", 520 808 siz); 521 809 } … … 524 812 /* overwrites entries, except for comments */ 525 813 lastblockstart = buffer; 526 for(i = 0; i < siz; ++i)814 for(i = 0; i < (int)siz; ++i) 527 815 { 528 816 if(buffer[i] == '\n') … … 535 823 *(end--) = 0; 536 824 if(end-lastblockstart < 60+5) /* short line */ 537 fprintf(stderr,"Short Header line '%s' ignored.\n", lastblockstart);825 RTCM3Error("Short Header line '%s' ignored.\n", lastblockstart); 538 826 else 539 827 { … … 551 839 || !strcmp("TIME OF FIRST OBS", lastblockstart+60)) 552 840 { 553 fprintf(stderr,"Overwriting header '%s' is dangerous.\n",841 RTCM3Error("Overwriting header '%s' is dangerous.\n", 554 842 lastblockstart+60); 555 843 } … … 557 845 if(pos >= MAXHEADERLINES) 558 846 { 559 fprintf(stderr, 560 "Maximum number of header lines of %d reached.\n", 847 RTCM3Error("Maximum number of header lines of %d reached.\n", 561 848 MAXHEADERLINES); 562 849 } 563 850 else if(!strcmp("END OF HEADER", lastblockstart+60)) 564 851 { 565 fprintf(stderr,"End of header ignored.\n");852 RTCM3Error("End of header ignored.\n"); 566 853 } 567 854 else … … 578 865 else 579 866 { 580 fprintf(stderr,"Could not read data from headerfile '%s'.\n",867 RTCM3Error("Could not read data from headerfile '%s'.\n", 581 868 Parser->headerfile); 582 869 } … … 585 872 else 586 873 { 587 fprintf(stderr,"Could not open header datafile '%s'.\n",874 RTCM3Error("Could not open header datafile '%s'.\n", 588 875 Parser->headerfile); 589 876 } … … 592 879 #ifndef NO_RTCM3_MAIN 593 880 for(i = 0; i < hdata.numheaders; ++i) 594 printf("%s\n", hdata.data.unnamed[i]);595 printf(" "881 RTCM3Text("%s\n", hdata.data.unnamed[i]); 882 RTCM3Text(" " 596 883 "END OF HEADER\n"); 597 884 #endif … … 609 896 struct converttimeinfo cti; 610 897 611 if(!Parser->init) 612 { 613 HandleHeader(Parser); 614 Parser->init = 1; 898 if(Parser->init < NUMSTARTSKIP) /* skip first epochs to detect correct data types */ 899 { 900 ++Parser->init; 901 902 if(Parser->init == NUMSTARTSKIP) 903 HandleHeader(Parser); 904 else 905 { 906 for(i = 0; i < Parser->Data.numsats; ++i) 907 Parser->startflags |= Parser->Data.dataflags[i]; 908 continue; 909 } 615 910 } 616 911 if(r == 2 && !Parser->validwarning) 617 912 { 618 printf("No valid RINEX! All values are modulo 299792.458!"913 RTCM3Text("No valid RINEX! All values are modulo 299792.458!" 619 914 " COMMENT\n"); 620 915 Parser->validwarning = 1; … … 623 918 converttime(&cti, Parser->Data.week, 624 919 (int)floor(Parser->Data.timeofweek/1000.0)); 625 printf(" %02d %2d %2d %2d %2d %10.7f 0%3d",920 RTCM3Text(" %02d %2d %2d %2d %2d %10.7f 0%3d", 626 921 cti.year%100, cti.month, cti.day, cti.hour, cti.minute, cti.second 627 922 + fmod(Parser->Data.timeofweek/1000.0,1.0), Parser->Data.numsats); … … 629 924 { 630 925 if(Parser->Data.satellites[i] <= PRN_GPS_END) 631 printf("G%02d", Parser->Data.satellites[i]);926 RTCM3Text("G%02d", Parser->Data.satellites[i]); 632 927 else if(Parser->Data.satellites[i] >= PRN_GLONASS_START 633 928 && Parser->Data.satellites[i] <= PRN_GLONASS_END) 634 printf("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1));929 RTCM3Text("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1)); 635 930 else 636 printf("%3d", Parser->Data.satellites[i]);637 } 638 printf("\n");931 RTCM3Text("%3d", Parser->Data.satellites[i]); 932 } 933 RTCM3Text("\n"); 639 934 o = 12; 640 935 j = Parser->Data.numsats - 12; 641 936 while(j > 0) 642 937 { 643 printf(" ");938 RTCM3Text(" "); 644 939 for(i = o; i < o+12 && i < Parser->Data.numsats; ++i) 645 940 { 646 941 if(Parser->Data.satellites[i] <= PRN_GPS_END) 647 printf("G%02d", Parser->Data.satellites[i]);942 RTCM3Text("G%02d", Parser->Data.satellites[i]); 648 943 else if(Parser->Data.satellites[i] >= PRN_GLONASS_START 649 944 && Parser->Data.satellites[i] <= PRN_GLONASS_END) 650 printf("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1)); 945 RTCM3Text("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1)); 946 else if(Parser->Data.satellites[i] >= PRN_WAAS_START 947 && Parser->Data.satellites[i] <= PRN_WAAS_END) 948 RTCM3Text("S%02d", Parser->Data.satellites[i] - PRN_WAAS_START); 651 949 else 652 printf("%3d", Parser->Data.satellites[i]);653 } 654 printf("\n");950 RTCM3Text("%3d", Parser->Data.satellites[i]); 951 } 952 RTCM3Text("\n"); 655 953 j -= 12; 656 954 o += 12; … … 664 962 || isinf(Parser->Data.measdata[i][Parser->datapos[j]])) 665 963 { /* no or illegal data */ 666 printf(" ");964 RTCM3Text(" "); 667 965 } 668 966 else … … 682 980 snr = '0'+Parser->Data.snrL2[i]; 683 981 } 684 printf("%14.3f%c%c",982 RTCM3Text("%14.3f%c%c", 685 983 Parser->Data.measdata[i][Parser->datapos[j]],lli,snr); 686 984 } 687 985 if(j%5 == 4 || j == Parser->numdatatypes-1) 688 printf("\n");986 RTCM3Text("\n"); 689 987 } 690 988 } … … 694 992 695 993 #ifndef NO_RTCM3_MAIN 696 static char datestr[] = "$Date: 2006/11/ 08 16:08:32$";994 static char datestr[] = "$Date: 2006/11/15 12:31:31 $"; 697 995 698 996 /* The string, which is send as agent in HTTP request */ … … 777 1075 {0,0,0,0}}; 778 1076 #endif 779 #define ARGOPT "d:hp:r:s:u:f:" 1077 #define ARGOPT "-d:hp:r:s:u:f:" 1078 1079 static const char *geturl(const char *url, struct Args *args) 1080 { 1081 static char buf[1000]; 1082 static char *Buffer = buf; 1083 static char *Bufend = buf+sizeof(buf); 1084 1085 if(strncmp("ntrip:", url, 6)) 1086 return "URL must start with 'ntrip:'."; 1087 url += 6; /* skip ntrip: */ 1088 1089 if(*url != '@' && *url != '/') 1090 { 1091 /* scan for mountpoint */ 1092 args->data = Buffer; 1093 while(*url && *url != '@' && *url != '/' && Buffer != Bufend) 1094 *(Buffer++) = *(url++); 1095 if(Buffer == args->data) 1096 return "Mountpoint required."; 1097 else if(Buffer >= Bufend-1) 1098 return "Parsing buffer too short."; 1099 *(Buffer++) = 0; 1100 } 1101 1102 if(*url == '/') /* username and password */ 1103 { 1104 ++url; 1105 args->user = Buffer; 1106 while(*url && *url != '@' && *url != ':' && Buffer != Bufend) 1107 *(Buffer++) = *(url++); 1108 if(Buffer == args->user) 1109 return "Username cannot be empty."; 1110 else if(Buffer >= Bufend-1) 1111 return "Parsing buffer too short."; 1112 *(Buffer++) = 0; 1113 1114 if(*url == ':') ++url; 1115 1116 args->password = Buffer; 1117 while(*url && *url != '@' && Buffer != Bufend) 1118 *(Buffer++) = *(url++); 1119 if(Buffer == args->password) 1120 return "Password cannot be empty."; 1121 else if(Buffer >= Bufend-1) 1122 return "Parsing buffer too short."; 1123 *(Buffer++) = 0; 1124 } 1125 1126 if(*url == '@') /* server */ 1127 { 1128 ++url; 1129 args->server = Buffer; 1130 while(*url && *url != ':' && Buffer != Bufend) 1131 *(Buffer++) = *(url++); 1132 if(Buffer == args->server) 1133 return "Servername cannot be empty."; 1134 else if(Buffer >= Bufend-1) 1135 return "Parsing buffer too short."; 1136 *(Buffer++) = 0; 1137 1138 if(*url == ':') 1139 { 1140 char *s2 = 0; 1141 args->port = strtol(++url, &s2, 10); 1142 if(*s2 || args->port <= 0 || args->port > 0xFFFF) 1143 return "Illegal port number."; 1144 url = s2; 1145 } 1146 } 1147 1148 return *url ? "Garbage at end of server string." : 0; 1149 } 780 1150 781 1151 static int getargs(int argc, char **argv, struct Args *args) … … 813 1183 res = 0; 814 1184 break; 1185 case 1: 1186 { 1187 const char *err; 1188 if((err = geturl(optarg, args))) 1189 { 1190 RTCM3Error("%s\n\n", err); 1191 res = 0; 1192 } 1193 } 1194 break; 815 1195 case -1: break; 816 1196 } … … 830 1210 if(!res || help) 831 1211 { 832 fprintf(stderr,"Version %s (%s) GPL\nUsage: %s -s server -u user ...\n"1212 RTCM3Error("Version %s (%s) GPL\nUsage: %s -s server -u user ...\n" 833 1213 " -d " LONG_OPT("--data ") "the requested data set\n" 834 1214 " -f " LONG_OPT("--headerfile ") "file for RINEX header information\n" … … 837 1217 " -r " LONG_OPT("--port ") "the server port number (default 80)\n" 838 1218 " -u " LONG_OPT("--user ") "the user name\n" 839 , revisionstr, datestr, argv[0]); 1219 "or using an URL:\n%s ntrip:mountpoint[/username[:password]][@server[:port]]\n" 1220 , revisionstr, datestr, argv[0], argv[0]); 840 1221 exit(1); 841 1222 } … … 848 1229 if(!stop) 849 1230 { 850 fprintf(stderr,"Stop signal number %d received. "1231 RTCM3Error("Stop signal number %d received. " 851 1232 "Trying to terminate gentle.\n", sig); 852 1233 stop = 1; … … 863 1244 #endif /* __GNUC__ */ 864 1245 { 865 fprintf(stderr,"Programm forcefully terminated.\n");1246 RTCM3Error("Programm forcefully terminated.\n"); 866 1247 exit(1); 867 1248 } … … 952 1333 if(i > MAXDATASIZE-40 && i < 0) /* second check for old glibc */ 953 1334 { 954 fprintf(stderr,"Requested data too long\n");1335 RTCM3Error("Requested data too long\n"); 955 1336 exit(1); 956 1337 } … … 958 1339 if(i > MAXDATASIZE-5) 959 1340 { 960 fprintf(stderr,"Username and/or password too long\n");1341 RTCM3Error("Username and/or password too long\n"); 961 1342 exit(1); 962 1343 } … … 978 1359 if(numbytes < 12 || strncmp("ICY 200 OK\r\n", buf, 12)) 979 1360 { 980 fprintf(stderr,"Could not get the requested data: ");1361 RTCM3Error("Could not get the requested data: "); 981 1362 for(k = 0; k < numbytes && buf[k] != '\n' && buf[k] != '\r'; ++k) 982 1363 { 983 fprintf(stderr,"%c", isprint(buf[k]) ? buf[k] : '.');984 } 985 fprintf(stderr,"\n");1364 RTCM3Error("%c", isprint(buf[k]) ? buf[k] : '.'); 1365 } 1366 RTCM3Error("\n"); 986 1367 exit(1); 987 1368 } … … 992 1373 int z; 993 1374 for(z = 0; z < numbytes && !stop; ++z) 994 HandleByte(&Parser, buf[z]);1375 HandleByte(&Parser, (unsigned int) buf[z]); 995 1376 } 996 1377 } -
trunk/BNC/RTCM3/rtcm3torinex.h
r282 r320 4 4 /* 5 5 Converter for RTCM3 data to RINEX. 6 $Id: rtcm3torinex.h,v 1. 1 2006/11/02 13:34:00stoecker Exp $6 $Id: rtcm3torinex.h,v 1.3 2006/11/15 12:31:31 stoecker Exp $ 7 7 Copyright (C) 2005-2006 by Dirk Stoecker <stoecker@euronik.eu> 8 8 … … 27 27 #define PRN_GLONASS_START 38 28 28 #define PRN_GLONASS_END 61 29 #define PRN_WAAS_START 120 30 #define PRN_WAAS_END 138 29 31 30 32 #define GNSSENTRY_C1DATA 0 … … 77 79 #define RINEXENTRY_NUMBER 10 78 80 79 #define LIGHTSPEED 2.99792458e8 /* m/sec 81 #define LIGHTSPEED 2.99792458e8 /* m/sec */ 80 82 #define GPS_FREQU_L1 1575420000.0 /* Hz */ 81 83 #define GPS_FREQU_L2 1227600000.0 /* Hz */ 82 84 #define GPS_WAVELENGTH_L1 (LIGHTSPEED / GPS_FREQU_L1) /* m */ 83 85 #define GPS_WAVELENGTH_L2 (LIGHTSPEED / GPS_FREQU_L2) /* m */ 86 87 #define GLO_FREQU_L1_BASE 1602000000.0 /* Hz */ 88 #define GLO_FREQU_L2_BASE 1246000000.0 /* Hz */ 89 #define GLO_FREQU_L1_STEP 562500.0 /* Hz */ 90 #define GLO_FREQU_L2_STEP 437500.0 /* Hz */ 91 #define GLO_FREQU_L1(a) (GLO_FREQU_L1_BASE+(a)*GLO_FREQU_L1_STEP) 92 #define GLO_FREQU_L2(a) (GLO_FREQU_L2_BASE+(a)*GLO_FREQU_L2_STEP) 93 #define GLO_WAVELENGTH_L1(a) (LIGHTSPEED / GLO_FREQU_L1(a)) /* m */ 94 #define GLO_WAVELENGTH_L2(a) (LIGHTSPEED / GLO_FREQU_L2(a)) /* m */ 84 95 85 96 /* unimportant, only for approx. time needed */ … … 110 121 int GPSTOW; /* in seconds */ 111 122 struct gnssdata Data; 123 struct gnssdata DataNew; 112 124 int size; 113 125 int lastlockl1[64]; … … 118 130 int validwarning; 119 131 int init; 132 int startflags; 120 133 const char * headerfile; 121 134 }; 122 135 123 struct converttimeinfo { 124 int second; /* seconds of GPS time [0..59] */ 125 int minute; /* minutes of GPS time [0..59] */ 126 int hour; /* hour of GPS time [0..24] */ 127 int day; /* day of GPS time [1..28..30(31)*/ 128 int month; /* month of GPS time [1..12]*/ 129 int year; /* year of GPS time [1980..] */ 130 }; 136 #ifndef PRINTFARG 137 #ifdef __GNUC__ 138 #define PRINTFARG(a,b) __attribute__ ((format(printf, a, b))) 139 #else /* __GNUC__ */ 140 #define PRINTFARG(a,b) 141 #endif /* __GNUC__ */ 142 #endif /* PRINTFARG */ 131 143 132 144 void HandleHeader(struct RTCM3ParserData *Parser); 133 145 int RTCM3Parser(struct RTCM3ParserData *handle); 134 146 void HandleByte(struct RTCM3ParserData *Parser, unsigned int byte); 135 void converttime(struct converttimeinfo *c, int week, int tow); 147 void PRINTFARG(1,2) RTCM3Error(const char *fmt, ...); 148 void PRINTFARG(1,2) RTCM3Text(const char *fmt, ...); 136 149 137 150 #endif /* RTCM3TORINEX_H */
Note:
See TracChangeset
for help on using the changeset viewer.