Changeset 45 in ntrip for trunk


Ignore:
Timestamp:
Jul 27, 2006, 11:54:39 AM (18 years ago)
Author:
stoecker
Message:

some changes regarding SISNET

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripserver/NtripLinuxServer.c

    r34 r45  
    4141 */
    4242
    43 /* $Id: NtripLinuxServer.c,v 1.15 2006/04/27 09:44:27 stoecker Exp $
     43/* $Id: NtripLinuxServer.c,v 1.16 2006/05/24 10:12:52 stoecker Exp $
    4444 * Changes - Version 0.7
    4545 * Sep 22 2003  Steffen Tschirpke <St.Tschirpke@actina.de>
     
    7777 *
    7878 * Changes - Version 0.14
    79  * Apr 27 2006  Dirk Stoecker <soft@dstoecker.de>
     79 * May 16 2006  Andrea Stuerze <andrea.stuerze@bkg.bund.de>
     80 *           - bug fix in base64_encode-function
     81 *
     82 * Changes - Version 0.15
     83 * Jun 02 2006  Georg Weber <georg.weber@bkg.bund.de>
     84 *           - modification for SISNeT 3.1 protocol
     85 *
     86 * Changes - Version 0.16
     87 * Jul 06 2006 Andrea Stuerze <andrea.stuerze@bkg.bund.de>
     88 *           - more flexible caster's response
     89 *
     90 * Changes - Version 0.17
     91 * Jul 27 2006  Dirk Stoecker <soft@dstoecker.de>
    8092 *           - fixed some problems with caster download
     93 *           - some minor cosmetic changes
    8194 *
    8295 */
     
    108121CASTER = 6};
    109122
    110 #define VERSION         "NTRIP NtripServerLinux/0.13"
     123#define VERSION         "NTRIP NtripServerLinux/0.17"
    111124#define BUFSZ           1024
    112125
     
    129142static const char *filepath    = "/dev/stdin";
    130143static enum MODE mode          = INFILE;
    131 static int sisnetv3            = 0;
     144static int sisnet              = 31;
    132145static int gpsfd               = -1;
    133146
    134147/* Forward references */
    135148static int openserial(const char * tty, int blocksz, int baud);
    136 static void send_receive_loop(int sock, int fd, int sisnet);
     149static void send_receive_loop(int sock, int fd);
    137150static void usage(int);
    138151static int encode(char *buf, int size, const char *user, const char *pwd);
     
    227240      break;
    228241    case 'V':
    229       if(!strcmp("3.0", optarg)) sisnetv3 = 1;
    230       else if(strcmp("2.1", optarg))
     242      if(!strcmp("3.0", optarg)) sisnet = 30;
     243      else if(!strcmp("3.1", optarg)) sisnet = 31;
     244      else if(!strcmp("2.1", optarg)) sisnet = 20;
     245      else
    231246      {
    232247        fprintf(stderr, "ERROR: unknown SISNeT version %s\n", optarg);
    233248        usage(-2);
    234249      }
     250      break;
    235251    case 'b':                  /* serial ttyin speed */
    236252      ttybaud = atoi(optarg);
     
    341357  case INFILE:
    342358    {
    343       gpsfd = open(filepath, O_RDONLY);
    344       if(!gpsfd)
     359      if((gpsfd = open(filepath, O_RDONLY)) < 0)
    345360      {
    346361        perror("ERROR: opening input file");
     
    406421      inport, stream_name ? "stream = " : "", stream_name ? stream_name : "",
    407422      initfile ? ", initfile = " : "", initfile ? initfile : "",
    408       bindmode ? " binding mode" : "");
     423      bindmode ? "binding mode" : "");
    409424
    410425      if(bindmode)
     
    533548      char buffer[1024];
    534549
    535       i = snprintf(buffer, sizeof(buffer), sisnetv3 ? "AUTH,%s,%s\r\n"
     550      i = snprintf(buffer, sizeof(buffer), sisnet >= 30 ? "AUTH,%s,%s\r\n"
    536551        : "AUTH,%s,%s", sisnetuser, sisnetpassword);
    537552      if((send(gpsfd, buffer, (size_t)i, 0)) != i)
     
    540555        exit(1);
    541556      }
    542       i = sisnetv3 ? 7 : 5;
     557      i = sisnet >= 30 ? 7 : 5;
    543558      if((j = recv(gpsfd, buffer, i, 0)) != i && strncmp("*AUTH", buffer, 5))
    544559      {
     
    553568        fprintf(stderr, "\n");
    554569        exit(1);
     570      }
     571      if(sisnet >= 31)
     572      {
     573        if((send(gpsfd, "START\r\n", 7, 0)) != i)
     574        {
     575          perror("ERROR: sending start command");
     576          exit(1);
     577        }
    555578      }
    556579    }
     
    615638    nBufferBytes = recv(sock_id, szSendBuffer, sizeof(szSendBuffer), 0);
    616639    szSendBuffer[nBufferBytes] = '\0';
    617     if(strcmp(szSendBuffer, "OK\r\n"))
     640    if(!strstr(szSendBuffer, "OK"))
    618641    {
    619642      char *a;
     
    629652    }
    630653    printf("connection successfull\n");
    631     send_receive_loop(sock_id, gpsfd, mode == SISNET);
     654    send_receive_loop(sock_id, gpsfd);
    632655  }
    633656  exit(0);
    634657}
    635658
    636 static void send_receive_loop(int sock, int fd, int sisnet)
     659static void send_receive_loop(int sock, int fd)
    637660{
    638661  char buffer[BUFSZ] = { 0 };
     
    647670    if(!nBufferBytes)
    648671    {
    649       if(sisnet)
     672      if(mode == SISNET && sisnet <= 30)
    650673      {
    651674        int i;
     
    655678        select(0, 0, 0, 0, &tv);
    656679        memcpy(sisnetbackbuffer, buffer, sizeof(sisnetbackbuffer));
    657         i = (sisnetv3 ? 5 : 3);
     680        i = (sisnet >= 30 ? 5 : 3);
    658681        if((send(gpsfd, "MSG\r\n", i, 0)) != i)
    659682        {
     
    667690      {
    668691        printf("WARNING: no data received from input\n");
     692        sleep(3);
    669693        continue;
    670694      }
     
    676700      /* we can compare the whole buffer, as the additional bytes
    677701         remain unchanged */
    678       if(sisnet && !memcmp(sisnetbackbuffer, buffer, sizeof(sisnetbackbuffer)))
     702      if(mode == SISNET && !memcmp(sisnetbackbuffer, buffer, sizeof(sisnetbackbuffer)))
    679703      {
    680704        nBufferBytes = 0;
     
    885909  fprintf(stderr, "    -u username\n");
    886910  fprintf(stderr, "    -l password\n");
    887   fprintf(stderr, "    -V version [2.1 or 3.0] (default: 2.1)\n");
     911  fprintf(stderr, "    -V version [2.1, 3.0 or 3.1] (default: 3.1)\n");
    888912  fprintf(stderr, "  Mode = caster:\n");
    889913  fprintf(stderr, "    -P SourceCaster port (default: %d)\n", NTRIP_PORT);
Note: See TracChangeset for help on using the changeset viewer.