Changeset 318 in ntrip
- Timestamp:
- Nov 15, 2006, 1:31:31 PM (18 years ago)
- Location:
- trunk/rtcm3torinex
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/rtcm3torinex/rtcm3torinex.c ¶
r287 r318 1 1 /* 2 2 Converter for RTCM3 data to RINEX. 3 $Id: rtcm3torinex.c,v 1. 82006/11/03 11:50:11stoecker Exp $3 $Id: rtcm3torinex.c,v 1.9 2006/11/08 17:11:08 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. 8$";53 static char revisionstr[] = "$Revision: 1.9 $"; 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 … … 638 639 } 639 640 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 640 660 void HandleHeader(struct RTCM3ParserData *Parser) 641 661 { … … 643 663 char thebuffer[MAXHEADERBUFFERSIZE]; 644 664 char *buffer = thebuffer; 645 int buffersize = sizeof(thebuffer);665 size_t buffersize = sizeof(thebuffer); 646 666 int i; 647 667 … … 721 741 } 722 742 723 int flags = 0;743 int flags = Parser->startflags; 724 744 int data[RINEXENTRY_NUMBER]; 725 745 char tbuffer[6*RINEXENTRY_NUMBER+1]; … … 778 798 if((fh = fopen(Parser->headerfile, "r"))) 779 799 { 780 int siz;800 size_t siz; 781 801 char *lastblockstart; 782 802 if((siz = fread(buffer, 1, buffersize-1, fh)) > 0) … … 785 805 if(siz == buffersize) 786 806 { 787 fprintf(stderr,"Header file is too large. Only %d bytes read.",807 RTCM3Error("Header file is too large. Only %d bytes read.", 788 808 siz); 789 809 } … … 792 812 /* overwrites entries, except for comments */ 793 813 lastblockstart = buffer; 794 for(i = 0; i < siz; ++i) 814 for(i = 0; i < (int)siz; ++i) 795 815 { 796 816 if(buffer[i] == '\n') … … 803 823 *(end--) = 0; 804 824 if(end-lastblockstart < 60+5) /* short line */ 805 fprintf(stderr,"Short Header line '%s' ignored.\n", lastblockstart);825 RTCM3Error("Short Header line '%s' ignored.\n", lastblockstart); 806 826 else 807 827 { … … 819 839 || !strcmp("TIME OF FIRST OBS", lastblockstart+60)) 820 840 { 821 fprintf(stderr,"Overwriting header '%s' is dangerous.\n",841 RTCM3Error("Overwriting header '%s' is dangerous.\n", 822 842 lastblockstart+60); 823 843 } … … 825 845 if(pos >= MAXHEADERLINES) 826 846 { 827 fprintf(stderr, 828 "Maximum number of header lines of %d reached.\n", 847 RTCM3Error("Maximum number of header lines of %d reached.\n", 829 848 MAXHEADERLINES); 830 849 } 831 850 else if(!strcmp("END OF HEADER", lastblockstart+60)) 832 851 { 833 fprintf(stderr,"End of header ignored.\n");852 RTCM3Error("End of header ignored.\n"); 834 853 } 835 854 else … … 846 865 else 847 866 { 848 fprintf(stderr,"Could not read data from headerfile '%s'.\n",867 RTCM3Error("Could not read data from headerfile '%s'.\n", 849 868 Parser->headerfile); 850 869 } … … 853 872 else 854 873 { 855 fprintf(stderr,"Could not open header datafile '%s'.\n",874 RTCM3Error("Could not open header datafile '%s'.\n", 856 875 Parser->headerfile); 857 876 } … … 860 879 #ifndef NO_RTCM3_MAIN 861 880 for(i = 0; i < hdata.numheaders; ++i) 862 printf("%s\n", hdata.data.unnamed[i]);863 printf(" "881 RTCM3Text("%s\n", hdata.data.unnamed[i]); 882 RTCM3Text(" " 864 883 "END OF HEADER\n"); 865 884 #endif … … 877 896 struct converttimeinfo cti; 878 897 879 if(!Parser->init) 880 { 881 HandleHeader(Parser); 882 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 } 883 910 } 884 911 if(r == 2 && !Parser->validwarning) 885 912 { 886 printf("No valid RINEX! All values are modulo 299792.458!"913 RTCM3Text("No valid RINEX! All values are modulo 299792.458!" 887 914 " COMMENT\n"); 888 915 Parser->validwarning = 1; … … 891 918 converttime(&cti, Parser->Data.week, 892 919 (int)floor(Parser->Data.timeofweek/1000.0)); 893 printf(" %02d %2d %2d %2d %2d %10.7f 0%3d",920 RTCM3Text(" %02d %2d %2d %2d %2d %10.7f 0%3d", 894 921 cti.year%100, cti.month, cti.day, cti.hour, cti.minute, cti.second 895 922 + fmod(Parser->Data.timeofweek/1000.0,1.0), Parser->Data.numsats); … … 897 924 { 898 925 if(Parser->Data.satellites[i] <= PRN_GPS_END) 899 printf("G%02d", Parser->Data.satellites[i]);926 RTCM3Text("G%02d", Parser->Data.satellites[i]); 900 927 else if(Parser->Data.satellites[i] >= PRN_GLONASS_START 901 928 && Parser->Data.satellites[i] <= PRN_GLONASS_END) 902 printf("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1));929 RTCM3Text("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1)); 903 930 else 904 printf("%3d", Parser->Data.satellites[i]);905 } 906 printf("\n");931 RTCM3Text("%3d", Parser->Data.satellites[i]); 932 } 933 RTCM3Text("\n"); 907 934 o = 12; 908 935 j = Parser->Data.numsats - 12; 909 936 while(j > 0) 910 937 { 911 printf(" ");938 RTCM3Text(" "); 912 939 for(i = o; i < o+12 && i < Parser->Data.numsats; ++i) 913 940 { 914 941 if(Parser->Data.satellites[i] <= PRN_GPS_END) 915 printf("G%02d", Parser->Data.satellites[i]);942 RTCM3Text("G%02d", Parser->Data.satellites[i]); 916 943 else if(Parser->Data.satellites[i] >= PRN_GLONASS_START 917 944 && Parser->Data.satellites[i] <= PRN_GLONASS_END) 918 printf("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1));945 RTCM3Text("R%02d", Parser->Data.satellites[i] - (PRN_GLONASS_START-1)); 919 946 else if(Parser->Data.satellites[i] >= PRN_WAAS_START 920 947 && Parser->Data.satellites[i] <= PRN_WAAS_END) 921 printf("S%02d", Parser->Data.satellites[i] - PRN_WAAS_START);948 RTCM3Text("S%02d", Parser->Data.satellites[i] - PRN_WAAS_START); 922 949 else 923 printf("%3d", Parser->Data.satellites[i]);924 } 925 printf("\n");950 RTCM3Text("%3d", Parser->Data.satellites[i]); 951 } 952 RTCM3Text("\n"); 926 953 j -= 12; 927 954 o += 12; … … 935 962 || isinf(Parser->Data.measdata[i][Parser->datapos[j]])) 936 963 { /* no or illegal data */ 937 printf(" ");964 RTCM3Text(" "); 938 965 } 939 966 else … … 953 980 snr = '0'+Parser->Data.snrL2[i]; 954 981 } 955 printf("%14.3f%c%c",982 RTCM3Text("%14.3f%c%c", 956 983 Parser->Data.measdata[i][Parser->datapos[j]],lli,snr); 957 984 } 958 985 if(j%5 == 4 || j == Parser->numdatatypes-1) 959 printf("\n");986 RTCM3Text("\n"); 960 987 } 961 988 } … … 965 992 966 993 #ifndef NO_RTCM3_MAIN 967 static char datestr[] = "$Date: 2006/11/0 3 11:50:11$";994 static char datestr[] = "$Date: 2006/11/08 17:11:08 $"; 968 995 969 996 /* The string, which is send as agent in HTTP request */ … … 1161 1188 if((err = geturl(optarg, args))) 1162 1189 { 1163 fprintf(stderr,"%s\n\n", err);1190 RTCM3Error("%s\n\n", err); 1164 1191 res = 0; 1165 1192 } … … 1183 1210 if(!res || help) 1184 1211 { 1185 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" 1186 1213 " -d " LONG_OPT("--data ") "the requested data set\n" 1187 1214 " -f " LONG_OPT("--headerfile ") "file for RINEX header information\n" … … 1202 1229 if(!stop) 1203 1230 { 1204 fprintf(stderr,"Stop signal number %d received. "1231 RTCM3Error("Stop signal number %d received. " 1205 1232 "Trying to terminate gentle.\n", sig); 1206 1233 stop = 1; … … 1217 1244 #endif /* __GNUC__ */ 1218 1245 { 1219 fprintf(stderr,"Programm forcefully terminated.\n");1246 RTCM3Error("Programm forcefully terminated.\n"); 1220 1247 exit(1); 1221 1248 } … … 1306 1333 if(i > MAXDATASIZE-40 && i < 0) /* second check for old glibc */ 1307 1334 { 1308 fprintf(stderr,"Requested data too long\n");1335 RTCM3Error("Requested data too long\n"); 1309 1336 exit(1); 1310 1337 } … … 1312 1339 if(i > MAXDATASIZE-5) 1313 1340 { 1314 fprintf(stderr,"Username and/or password too long\n");1341 RTCM3Error("Username and/or password too long\n"); 1315 1342 exit(1); 1316 1343 } … … 1332 1359 if(numbytes < 12 || strncmp("ICY 200 OK\r\n", buf, 12)) 1333 1360 { 1334 fprintf(stderr,"Could not get the requested data: ");1361 RTCM3Error("Could not get the requested data: "); 1335 1362 for(k = 0; k < numbytes && buf[k] != '\n' && buf[k] != '\r'; ++k) 1336 1363 { 1337 fprintf(stderr,"%c", isprint(buf[k]) ? buf[k] : '.');1338 } 1339 fprintf(stderr,"\n");1364 RTCM3Error("%c", isprint(buf[k]) ? buf[k] : '.'); 1365 } 1366 RTCM3Error("\n"); 1340 1367 exit(1); 1341 1368 } … … 1346 1373 int z; 1347 1374 for(z = 0; z < numbytes && !stop; ++z) 1348 HandleByte(&Parser, buf[z]); 1375 HandleByte(&Parser, (unsigned int) buf[z]); 1349 1376 } 1350 1377 } -
TabularUnified trunk/rtcm3torinex/rtcm3torinex.h ¶
r270 r318 4 4 /* 5 5 Converter for RTCM3 data to RINEX. 6 $Id: rtcm3torinex.h,v 1. 12006/11/02 13:34:00stoecker Exp $6 $Id: rtcm3torinex.h,v 1.2 2006/11/03 11:50:11 stoecker Exp $ 7 7 Copyright (C) 2005-2006 by Dirk Stoecker <stoecker@euronik.eu> 8 8 … … 130 130 int validwarning; 131 131 int init; 132 int startflags; 132 133 const char * headerfile; 133 134 }; 135 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 */ 134 143 135 144 void HandleHeader(struct RTCM3ParserData *Parser); 136 145 int RTCM3Parser(struct RTCM3ParserData *handle); 137 146 void HandleByte(struct RTCM3ParserData *Parser, unsigned int byte); 147 void PRINTFARG(1,2) RTCM3Error(const char *fmt, ...); 148 void PRINTFARG(1,2) RTCM3Text(const char *fmt, ...); 138 149 139 150 #endif /* RTCM3TORINEX_H */ -
TabularUnified trunk/rtcm3torinex/rtcm3torinex.txt ¶
r29 r318 2 2 3 3 The program rtcm3torinex is an real-time converter from NTRIP streamed RTCM3 4 data into the RINEX format. The generated RINEX is somewhat limited due to 5 the streaming character of the conversion: 4 data into the RINEX format. 5 6 RTCM3 defines a number of message types. Among them are the following: 7 8 Message 9 Type Contains information about 10 -------------------------------------------------------------------------- 11 1001 GPS L1 code and phase 12 1002 GPS L1 code and phase and ambiguities and carrier to noise ratio 13 1003 GPS L1 and L1 code and phase 14 1004 GPS L1 and L2 code and phase and ambiguities and carrier to noise ratio 15 1005 Station coordinates XZY for antenna reference point 16 1006 Station coordinates XYZ for antenna reference point and antenna height 17 1007 Antenna descriptor and ID 18 1008 Antenna serial number 19 1009 GLONASS L1 code and phase 20 1010 GLONASS L1 code and phase and ambiguities and carrier to noise ratio 21 1011 GLONASS L1 and L1 code and phase 22 1012 GLONASS L1 and L2 code and phase and ambiguities and carrier to noise ratio 23 1013 Modified julian date, leep second, configured message types and intervall 24 1014-1017 Network RTK (MAK) messages (under development) 25 1019 GPS Ephemeris (under development) 26 1020 GLONASS Ephemeris (under development) 27 4088-4095 Proprietary messages (under development) 28 29 Note that this version of rtcm3torinex only handles RTCM3 message types 1001, 30 1002, 1003, 1004, 1009, 1010, 1011 and 1012. 31 32 The generated RINEX is somewhat limited due to the streaming character of the 33 conversion: 34 6 35 - Header records can only represent data, which is known after receiving the 7 36 very first epoch. Data rate, position, number of observations and any such … … 10 39 the observables, which exist in the first epoch are outputted. If there 11 40 are new observables later on, these are ignored. 12 - Only known datatypes are interpreted. This means only GPS data at the41 - Only known message types are interpreted. This means only GPS data at the 13 42 moment. Send me new RTCM3 data files and data support can be improved. 14 43 See contact address at the end of this document. … … 32 61 must be used to specify the RTCM3 input data stream. If it is not given, you 33 62 will be shown the source table of the selected NTRIP caster. 63 64 Alternatively a single text of the form 65 "ntrip:mountpoint[/username[:password]][@server[:port]]" 66 can be used. Everything in brackets is optional. 34 67 35 68 Additionally the argument --headerfile can be used to provide additional header … … 56 89 You will not get corrupted RINEX files. 57 90 58 Contact me with your comments, suggestions, improvements, patches, ... 91 When compiling the program with older gcc versions running the `make' 92 command, you may receive an informative error message saying 59 93 60 Dirk Stöcker 61 EuroNav Service GmbH 62 http://www.euronav.de/ 63 stoecker@euronav.de 64 2006-01-12 94 rtcm3torinex.c: In function `signalhandler_alarm': 95 rtcm3torinex.c:1240: warning: `noreturn' function does return 96 97 This is most likely a compiler problem which only concerns the optimization 98 and is thus not critical. New compilers will not show this problem. 99 100 Program written by 101 102 Dirk Stoecker 103 Euronik GmbH 104 http://www.euronik.eu/ 105 106 for 107 108 Federal Agency for Cartography and Geodesy (BKG) 109 Richard-Strauss-Allee 11 110 D-60598 Frankfurt 111 http://igs.bkg.bund.de/index_ntrip.htm 112 113 Contact Dirk Stoecker [stoecker@euronik.eu] or [euref-ip@bkg.bund.de] 114 with your comments, suggestions, improvements, patches, ...
Note:
See TracChangeset
for help on using the changeset viewer.