Changeset 283 in ntrip for trunk/BNC


Ignore:
Timestamp:
Nov 8, 2006, 5:08:32 PM (18 years ago)
Author:
mervart
Message:

* empty log message *

Location:
trunk/BNC/RTCM3
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/RTCM3/rtcm3.cpp

    r248 r283  
    8787            }
    8888            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]];
    9190              obs->SNR1 = _Parser.Data.snrL1[ii];
    9291            }
    9392            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]];
    9694              obs->SNR2 = _Parser.Data.snrL2[ii];
    9795            }
  • trunk/BNC/RTCM3/rtcm3torinex.cpp

    r131 r283  
    11/*
    22  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.
    2110
    2211  This program is free software; you can redistribute it and/or modify
     
    3524  or read http://www.gnu.org/licenses/gpl.txt
    3625*/
    37 
    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
    4826
    4927#include <ctype.h>
     
    5836#include <unistd.h>
    5937
    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
    6448
    6549#include "rtcm3torinex.h"
     
    6751/* CVS revision and version */
    6852static 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_MAIN
    73 
    74 struct Args
    75 {
    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_OPTS
    86 #define LONG_OPT(a)
    87 #else
    88 #define LONG_OPT(a) a
    89 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 #endif
    99 #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   do
    117   {
    118 #ifdef NO_LONG_OPTS
    119     switch((getoptr = getopt(argc, argv, ARGOPT)))
    120 #else
    121     switch((getoptr = getopt_long(argc, argv, ARGOPT, opts, 0)))
    122 #endif
    123     {
    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 #endif
    165 
    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       else
    199         *(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       else
    207         *(out++) = encodingTable[inbuf [2] & 0x3F];
    208     }
    209     bytes += 4;
    210   }
    211   if(out-buf < size)
    212     *out = 0;
    213   return bytes;
    214 }
    21553
    21654static uint32_t CRC24(long size, const unsigned char *buf)
     
    405243            }
    406244          }
     245          gnss->measdata[num][le] /= GPS_WAVELENGTH_L1;
    407246          if(type == 1003 || type == 1004)
    408247          {
     
    452291              }
    453292            }
     293            gnss->measdata[num][le] /= GPS_WAVELENGTH_L2;
    454294          }
    455295        }
     
    547387    struct tm * t2;
    548388
     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
    549400    str = getenv("USER");
    550401    if(!str) str = "";
     
    642493    struct converttimeinfo cti;
    643494    converttime(&cti, Parser->Data.week,
    644                 int(floor(Parser->Data.timeofweek/1000.0)));
     495    (int)floor(Parser->Data.timeofweek/1000.0));
    645496    hdata.data.named.timeoffirstobs = buffer;
    646497      i = 1+snprintf(buffer, buffersize,
     
    739590  }
    740591
    741 
    742 #ifndef NO_RTCM3_MAIN
    743592  for(i = 0; i < hdata.numheaders; ++i)
    744593    printf("%s\n", hdata.data.unnamed[i]);
    745594  printf("                                                            "
    746595  "END OF HEADER\n");
    747 #endif
    748 }
    749 
    750 #ifndef NO_RTCM3_MAIN
    751 
    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);
    768596}
    769597
     
    792620
    793621      converttime(&cti, Parser->Data.week,
    794       floor(Parser->Data.timeofweek/1000.0));
     622      (int)floor(Parser->Data.timeofweek/1000.0));
    795623      printf(" %02d %2d %2d %2d %2d %10.7f  0%3d",
    796624      cti.year%100, cti.month, cti.day, cti.hour, cti.minute, cti.second
     
    863691}
    864692
     693#ifndef NO_RTCM3_MAIN
     694static 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
     701static 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 */
     710static 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
     750static int stop = 0;
     751
     752struct 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
     767static 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
     779static 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 */
     844static 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__
     857static __attribute__ ((noreturn)) void signalhandler_alarm(
     858int sig __attribute__((__unused__)))
     859#else /* __GNUC__ */
     860static void signalhandler_alarm(int sig)
     861#endif /* __GNUC__ */
     862{
     863  fprintf(stderr, "Programm forcefully terminated.\n");
     864  exit(1);
     865}
     866
    865867int main(int argc, char **argv)
    866868{
     
    10041006  return 0;
    10051007}
    1006 
    1007 #endif   // NO_RTCM3_MAIN
     1008#endif /* NO_RTCM3_MAIN */
Note: See TracChangeset for help on using the changeset viewer.