- Timestamp:
- Nov 8, 2006, 5:08:32 PM (18 years ago)
- Location:
- trunk/BNC/RTCM3
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/RTCM3/rtcm3.cpp
r248 r283 87 87 } 88 88 else if (_Parser.dataflag[jj] & (GNSSDF_L1CDATA|GNSSDF_L1PDATA)) { 89 obs->L1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]] / 90 t_CST::lambda1; 89 obs->L1 = _Parser.Data.measdata[ii][_Parser.datapos[jj]]; 91 90 obs->SNR1 = _Parser.Data.snrL1[ii]; 92 91 } 93 92 else if (_Parser.dataflag[jj] & (GNSSDF_L2CDATA|GNSSDF_L2PDATA)) { 94 obs->L2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]] / 95 t_CST::lambda2; 93 obs->L2 = _Parser.Data.measdata[ii][_Parser.datapos[jj]]; 96 94 obs->SNR2 = _Parser.Data.snrL2[ii]; 97 95 } -
trunk/BNC/RTCM3/rtcm3torinex.cpp
r131 r283 1 1 /* 2 2 Converter for RTCM3 data to RINEX. 3 $Id: rtcm3torinex.cpp,v 1.7 2006/09/06 16:13:16 mervart Exp $ 4 5 Program written bei 6 Dirk Stoecker 7 Euronik GmbH 8 http://www.euronik.eu/ 9 10 for 11 12 Federal Agency for Cartography and Geodesy (BKG) 13 Richard-Strauss-Allee 11 14 D-60598 Frankfurt 15 http://igs.bkg.bund.de/index_ntrip.htm 16 17 Contact Dirk Stoecker [stoecker@euronik.eu] or [euref-ip@bkg.bund.de] 18 with your comments, suggestions, improvements, patches. 19 20 Copyright (C) 2005-2006 by German Federal Agency for Cartography and Geodesy 3 $Id: rtcm3torinex.c,v 1.7 2006/11/02 13:54:43 stoecker Exp $ 4 Copyright (C) 2005-2006 by Dirk Stoecker <stoecker@euronik.eu> 5 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 8 Stöcker for suggestions and bug reports related to the RTCM3 to RINEX 9 conversion problems and the author of BNC for all the other problems. 21 10 22 11 This program is free software; you can redistribute it and/or modify … … 35 24 or read http://www.gnu.org/licenses/gpl.txt 36 25 */ 37 38 #ifndef NO_RTCM3_MAIN39 #include <getopt.h>40 #include <netdb.h>41 #include <netinet/in.h>42 #include <sys/socket.h>43 #endif44 45 #ifndef sparc46 #include <stdint.h>47 #endif48 26 49 27 #include <ctype.h> … … 58 36 #include <unistd.h> 59 37 60 /* The string, which is send as agent in HTTP request */ 61 #define AGENTSTRING "NTRIP NtripRTCM3ToRINEX" 62 63 #define MAXDATASIZE 1000 /* max number of bytes we can get at once */ 38 #ifndef NO_RTCM3_MAIN 39 #include <getopt.h> 40 #include <netdb.h> 41 #include <netinet/in.h> 42 #include <sys/socket.h> 43 #endif 44 45 #ifndef sparc 46 #include <stdint.h> 47 #endif 64 48 65 49 #include "rtcm3torinex.h" … … 67 51 /* CVS revision and version */ 68 52 static char revisionstr[] = "$Revision: 1.7 $"; 69 static char datestr[] = "$Date: 2006/09/06 16:13:16 $";70 static int stop = 0;71 72 #ifndef NO_RTCM3_MAIN73 74 struct Args75 {76 const char *server;77 int port;78 const char *user;79 const char *password;80 const char *data;81 const char *headerfile;82 };83 84 /* option parsing */85 #ifdef NO_LONG_OPTS86 #define LONG_OPT(a)87 #else88 #define LONG_OPT(a) a89 static struct option opts[] = {90 { "data", required_argument, 0, 'd'},91 { "server", required_argument, 0, 's'},92 { "password", required_argument, 0, 'p'},93 { "port", required_argument, 0, 'r'},94 { "header", required_argument, 0, 'f'},95 { "user", required_argument, 0, 'u'},96 { "help", no_argument, 0, 'h'},97 {0,0,0,0}};98 #endif99 #define ARGOPT "d:hp:r:s:u:f:"100 101 static int getargs(int argc, char **argv, struct Args *args)102 {103 int res = 1;104 int getoptr;105 int help = 0;106 char *t;107 108 args->server = "www.euref-ip.net";109 args->port = 80;110 args->user = "";111 args->password = "";112 args->data = 0;113 args->headerfile = 0;114 help = 0;115 116 do117 {118 #ifdef NO_LONG_OPTS119 switch((getoptr = getopt(argc, argv, ARGOPT)))120 #else121 switch((getoptr = getopt_long(argc, argv, ARGOPT, opts, 0)))122 #endif123 {124 case 's': args->server = optarg; break;125 case 'u': args->user = optarg; break;126 case 'p': args->password = optarg; break;127 case 'd': args->data = optarg; break;128 case 'f': args->headerfile = optarg; break;129 case 'h': help=1; break;130 case 'r':131 args->port = strtoul(optarg, &t, 10);132 if((t && *t) || args->port < 1 || args->port > 65535)133 res = 0;134 break;135 case -1: break;136 }137 } while(getoptr != -1 || !res);138 139 datestr[0] = datestr[7];140 datestr[1] = datestr[8];141 datestr[2] = datestr[9];142 datestr[3] = datestr[10];143 datestr[5] = datestr[12];144 datestr[6] = datestr[13];145 datestr[8] = datestr[15];146 datestr[9] = datestr[16];147 datestr[4] = datestr[7] = '-';148 datestr[10] = 0;149 150 if(!res || help)151 {152 fprintf(stderr, "Version %s (%s) GPL\nUsage: %s -s server -u user ...\n"153 " -d " LONG_OPT("--data ") "the requested data set\n"154 " -f " LONG_OPT("--headerfile ") "file for RINEX header information\n"155 " -s " LONG_OPT("--server ") "the server name or address\n"156 " -p " LONG_OPT("--password ") "the login password\n"157 " -r " LONG_OPT("--port ") "the server port number (default 80)\n"158 " -u " LONG_OPT("--user ") "the user name\n"159 , revisionstr, datestr, argv[0]);160 exit(1);161 }162 return res;163 }164 #endif165 166 167 static const char encodingTable [64] = {168 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P',169 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f',170 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v',171 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/'172 };173 174 /* does not buffer overrun, but breaks directly after an error */175 /* returns the number of required bytes */176 static int encode(char *buf, int size, const char *user, const char *pwd)177 {178 unsigned char inbuf[3];179 char *out = buf;180 int i, sep = 0, fill = 0, bytes = 0;181 182 while(*user || *pwd)183 {184 i = 0;185 while(i < 3 && *user) inbuf[i++] = *(user++);186 if(i < 3 && !sep) {inbuf[i++] = ':'; ++sep; }187 while(i < 3 && *pwd) inbuf[i++] = *(pwd++);188 while(i < 3) {inbuf[i++] = 0; ++fill; }189 if(out-buf < size-1)190 *(out++) = encodingTable[(inbuf [0] & 0xFC) >> 2];191 if(out-buf < size-1)192 *(out++) = encodingTable[((inbuf [0] & 0x03) << 4)193 | ((inbuf [1] & 0xF0) >> 4)];194 if(out-buf < size-1)195 {196 if(fill == 2)197 *(out++) = '=';198 else199 *(out++) = encodingTable[((inbuf [1] & 0x0F) << 2)200 | ((inbuf [2] & 0xC0) >> 6)];201 }202 if(out-buf < size-1)203 {204 if(fill >= 1)205 *(out++) = '=';206 else207 *(out++) = encodingTable[inbuf [2] & 0x3F];208 }209 bytes += 4;210 }211 if(out-buf < size)212 *out = 0;213 return bytes;214 }215 53 216 54 static uint32_t CRC24(long size, const unsigned char *buf) … … 405 243 } 406 244 } 245 gnss->measdata[num][le] /= GPS_WAVELENGTH_L1; 407 246 if(type == 1003 || type == 1004) 408 247 { … … 452 291 } 453 292 } 293 gnss->measdata[num][le] /= GPS_WAVELENGTH_L2; 454 294 } 455 295 } … … 547 387 struct tm * t2; 548 388 389 #ifdef NO_RTCM3_MAIN 390 if(revisionstr[0] == '$') 391 { 392 char *a; 393 int i=0; 394 for(a = revisionstr+11; *a && *a != ' '; ++a) 395 revisionstr[i++] = *a; 396 revisionstr[i] = 0; 397 } 398 #endif 399 549 400 str = getenv("USER"); 550 401 if(!str) str = ""; … … 642 493 struct converttimeinfo cti; 643 494 converttime(&cti, Parser->Data.week, 644 int(floor(Parser->Data.timeofweek/1000.0)));495 (int)floor(Parser->Data.timeofweek/1000.0)); 645 496 hdata.data.named.timeoffirstobs = buffer; 646 497 i = 1+snprintf(buffer, buffersize, … … 739 590 } 740 591 741 742 #ifndef NO_RTCM3_MAIN743 592 for(i = 0; i < hdata.numheaders; ++i) 744 593 printf("%s\n", hdata.data.unnamed[i]); 745 594 printf(" " 746 595 "END OF HEADER\n"); 747 #endif748 }749 750 #ifndef NO_RTCM3_MAIN751 752 /* let the output complete a block if necessary */753 static void signalhandler(int sig)754 {755 if(!stop)756 {757 fprintf(stderr, "Stop signal number %d received. "758 "Trying to terminate gentle.\n", sig);759 stop = 1;760 alarm(1);761 }762 }763 764 static void signalhandler_alarm(int sig)765 {766 fprintf(stderr, "Programm forcefully terminated.\n");767 exit(1);768 596 } 769 597 … … 792 620 793 621 converttime(&cti, Parser->Data.week, 794 floor(Parser->Data.timeofweek/1000.0));622 (int)floor(Parser->Data.timeofweek/1000.0)); 795 623 printf(" %02d %2d %2d %2d %2d %10.7f 0%3d", 796 624 cti.year%100, cti.month, cti.day, cti.hour, cti.minute, cti.second … … 863 691 } 864 692 693 #ifndef NO_RTCM3_MAIN 694 static char datestr[] = "$Date: 2006/11/02 13:54:43 $"; 695 696 /* The string, which is send as agent in HTTP request */ 697 #define AGENTSTRING "NTRIP NtripRTCM3ToRINEX" 698 699 #define MAXDATASIZE 1000 /* max number of bytes we can get at once */ 700 701 static const char encodingTable [64] = { 702 'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P', 703 'Q','R','S','T','U','V','W','X','Y','Z','a','b','c','d','e','f', 704 'g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v', 705 'w','x','y','z','0','1','2','3','4','5','6','7','8','9','+','/' 706 }; 707 708 /* does not buffer overrun, but breaks directly after an error */ 709 /* returns the number of required bytes */ 710 static int encode(char *buf, int size, const char *user, const char *pwd) 711 { 712 unsigned char inbuf[3]; 713 char *out = buf; 714 int i, sep = 0, fill = 0, bytes = 0; 715 716 while(*user || *pwd) 717 { 718 i = 0; 719 while(i < 3 && *user) inbuf[i++] = *(user++); 720 if(i < 3 && !sep) {inbuf[i++] = ':'; ++sep; } 721 while(i < 3 && *pwd) inbuf[i++] = *(pwd++); 722 while(i < 3) {inbuf[i++] = 0; ++fill; } 723 if(out-buf < size-1) 724 *(out++) = encodingTable[(inbuf [0] & 0xFC) >> 2]; 725 if(out-buf < size-1) 726 *(out++) = encodingTable[((inbuf [0] & 0x03) << 4) 727 | ((inbuf [1] & 0xF0) >> 4)]; 728 if(out-buf < size-1) 729 { 730 if(fill == 2) 731 *(out++) = '='; 732 else 733 *(out++) = encodingTable[((inbuf [1] & 0x0F) << 2) 734 | ((inbuf [2] & 0xC0) >> 6)]; 735 } 736 if(out-buf < size-1) 737 { 738 if(fill >= 1) 739 *(out++) = '='; 740 else 741 *(out++) = encodingTable[inbuf [2] & 0x3F]; 742 } 743 bytes += 4; 744 } 745 if(out-buf < size) 746 *out = 0; 747 return bytes; 748 } 749 750 static int stop = 0; 751 752 struct Args 753 { 754 const char *server; 755 int port; 756 const char *user; 757 const char *password; 758 const char *data; 759 const char *headerfile; 760 }; 761 762 /* option parsing */ 763 #ifdef NO_LONG_OPTS 764 #define LONG_OPT(a) 765 #else 766 #define LONG_OPT(a) a 767 static struct option opts[] = { 768 { "data", required_argument, 0, 'd'}, 769 { "server", required_argument, 0, 's'}, 770 { "password", required_argument, 0, 'p'}, 771 { "port", required_argument, 0, 'r'}, 772 { "header", required_argument, 0, 'f'}, 773 { "user", required_argument, 0, 'u'}, 774 { "help", no_argument, 0, 'h'}, 775 {0,0,0,0}}; 776 #endif 777 #define ARGOPT "d:hp:r:s:u:f:" 778 779 static int getargs(int argc, char **argv, struct Args *args) 780 { 781 int res = 1; 782 int getoptr; 783 int help = 0; 784 char *t; 785 786 args->server = "www.euref-ip.net"; 787 args->port = 80; 788 args->user = ""; 789 args->password = ""; 790 args->data = 0; 791 args->headerfile = 0; 792 help = 0; 793 794 do 795 { 796 #ifdef NO_LONG_OPTS 797 switch((getoptr = getopt(argc, argv, ARGOPT))) 798 #else 799 switch((getoptr = getopt_long(argc, argv, ARGOPT, opts, 0))) 800 #endif 801 { 802 case 's': args->server = optarg; break; 803 case 'u': args->user = optarg; break; 804 case 'p': args->password = optarg; break; 805 case 'd': args->data = optarg; break; 806 case 'f': args->headerfile = optarg; break; 807 case 'h': help=1; break; 808 case 'r': 809 args->port = strtoul(optarg, &t, 10); 810 if((t && *t) || args->port < 1 || args->port > 65535) 811 res = 0; 812 break; 813 case -1: break; 814 } 815 } while(getoptr != -1 || !res); 816 817 datestr[0] = datestr[7]; 818 datestr[1] = datestr[8]; 819 datestr[2] = datestr[9]; 820 datestr[3] = datestr[10]; 821 datestr[5] = datestr[12]; 822 datestr[6] = datestr[13]; 823 datestr[8] = datestr[15]; 824 datestr[9] = datestr[16]; 825 datestr[4] = datestr[7] = '-'; 826 datestr[10] = 0; 827 828 if(!res || help) 829 { 830 fprintf(stderr, "Version %s (%s) GPL\nUsage: %s -s server -u user ...\n" 831 " -d " LONG_OPT("--data ") "the requested data set\n" 832 " -f " LONG_OPT("--headerfile ") "file for RINEX header information\n" 833 " -s " LONG_OPT("--server ") "the server name or address\n" 834 " -p " LONG_OPT("--password ") "the login password\n" 835 " -r " LONG_OPT("--port ") "the server port number (default 80)\n" 836 " -u " LONG_OPT("--user ") "the user name\n" 837 , revisionstr, datestr, argv[0]); 838 exit(1); 839 } 840 return res; 841 } 842 843 /* let the output complete a block if necessary */ 844 static void signalhandler(int sig) 845 { 846 if(!stop) 847 { 848 fprintf(stderr, "Stop signal number %d received. " 849 "Trying to terminate gentle.\n", sig); 850 stop = 1; 851 alarm(1); 852 } 853 } 854 855 /* for some reason we had to abort hard (maybe waiting for data */ 856 #ifdef __GNUC__ 857 static __attribute__ ((noreturn)) void signalhandler_alarm( 858 int sig __attribute__((__unused__))) 859 #else /* __GNUC__ */ 860 static void signalhandler_alarm(int sig) 861 #endif /* __GNUC__ */ 862 { 863 fprintf(stderr, "Programm forcefully terminated.\n"); 864 exit(1); 865 } 866 865 867 int main(int argc, char **argv) 866 868 { … … 1004 1006 return 0; 1005 1007 } 1006 1007 #endif // NO_RTCM3_MAIN 1008 #endif /* NO_RTCM3_MAIN */
Note:
See TracChangeset
for help on using the changeset viewer.