Changeset 44 in ntrip


Ignore:
Timestamp:
Jul 18, 2006, 10:55:30 AM (18 years ago)
Author:
stoecker
Message:

added bitrate

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ntripclient/NtripLinuxClient.c

    r43 r44  
    11/*
    22  Easy example NTRIP client for Linux/Unix.
    3   $Id: NtripLinuxClient.c,v 1.19 2006/07/04 08:05:45 stoecker Exp $
     3  $Id: NtripLinuxClient.c,v 1.20 2006/07/04 12:53:43 stoecker Exp $
    44  Copyright (C) 2003-2005 by Dirk Stoecker <soft@dstoecker.de>
    55   
     
    3232#include <netinet/in.h>
    3333#include <sys/socket.h>
     34#include <time.h>
    3435
    3536/* The string, which is send as agent in HTTP request */
     
    4041
    4142/* CVS revision and version */
    42 static char revisionstr[] = "$Revision: 1.19 $";
    43 static char datestr[]     = "$Date: 2006/07/04 08:05:45 $";
     43static char revisionstr[] = "$Revision: 1.20 $";
     44static char datestr[]     = "$Date: 2006/07/04 12:53:43 $";
    4445
    4546struct Args
     
    5051  const char *password;
    5152  const char *data;
     53  int         bitrate;
    5254};
    5355
     
    5860#define LONG_OPT(a) a
    5961static struct option opts[] = {
     62{ "bitrate",    no_argument,       0, 'b'},
    6063{ "data",       required_argument, 0, 'd'},
    6164{ "server",     required_argument, 0, 's'},
     
    6669{0,0,0,0}};
    6770#endif
    68 #define ARGOPT "-d:hp:r:s:u:"
     71#define ARGOPT "-d:bhp:r:s:u:"
    6972
    7073#ifdef __GNUC__
     
    164167  args->password = "";
    165168  args->data = 0;
     169  args->bitrate = 0;
    166170  help = 0;
    167171
     
    178182    case 'p': args->password = optarg; break;
    179183    case 'd': args->data = optarg; break;
     184    case 'b': args->bitrate = 1; break;
    180185    case 'h': help=1; break;
    181186    case 1:
     
    220225    " -r " LONG_OPT("--port     ") "the server port number (default 80)\n"
    221226    " -u " LONG_OPT("--user     ") "the user name\n"
     227    " -b " LONG_OPT("--bitrate  ") "output bitrate\n"
    222228    "or using an URL:\n%s ntrip:mountpoint[/username[:password]][@server[:port]]\n"
    223229    , revisionstr, datestr, argv[0], argv[0]);
     
    359365    {
    360366      int k = 0;
     367      int starttime = time(0);
     368      int lastout = starttime;
     369      int totalbytes = 0;
    361370
    362371      while((numbytes=recv(sockfd, buf, MAXDATASIZE-1, 0)) != -1)
     
    379388        else
    380389        {
     390          totalbytes += numbytes;
     391          if(totalbytes < 0) /* overflow */
     392          {
     393            totalbytes = 0;
     394            starttime = time(0);
     395            lastout = starttime;
     396          }
    381397          fwrite(buf, (size_t)numbytes, 1, stdout);
    382398          fflush(stdout);
     399          if(args.bitrate)
     400          {
     401            int t = time(0);
     402            if(t > lastout + 60)
     403            {
     404              lastout = t;
     405              fprintf(stderr, "Bitrate is %d/s (%d seconds accumulated).\n",
     406              totalbytes/(t-starttime), t-starttime);
     407            }
     408          }
    383409        }
    384410      }
Note: See TracChangeset for help on using the changeset viewer.