Home| superdarn |src.lib|tk|oldfitcnx| OldFitCnxRead Index

OldFitCnxRead

Syntax
int OldFitCnxRead(int num,int *sock,struct RadarParm *prm, struct FitData *fit,int *flag, struct timeval *tmout);
Header
superdarn/oldfitcnx.h
Library
oldfitcnx
Description

The OldFitCnxRead function reads fitted ACF data from a remote server using the old transport protocol.

The argument sock is a pointer to an array of file descriptors associated with a set of connections. The argument num is the number of elements in the array.

When a block of data is received from one of the connections it is decoded and used to populate the appropriate members of the array of radar parameter blocks pointed to by the argument prm and the array of fit data structures pointed to by the argument fit.

The argument flag is a pointer to an array used to record whether a message read from a particular connection was successfully decoded. If no message was received for a connection, then the corresponding element of the array is set to zero. If a message was successfully decoded, the element is set to (1), and if an error occurred it is set to (-1).

The argument tout is a pointer that defines a time limit for the function. If no messages are received within the specified time, the function will return. If tout is a NULL pointer the function will wait indefinitely for a message to be received.

Returns
Returns zero on success. On error, (-1) is returned.
Errors
On error, (-1) is returned.
Example

Source Code: OldFitCnxRead.c

/* OldFitCnxRead
   =============
   Author: R.J.Barnes

Copyright (c) 2012 The Johns Hopkins University/Applied Physics Laboratory

This file is part of the Radar Software Toolkit (RST).

RST is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

Modifications:


*/


#include <stdio.h>
#include <stdlib.h>

#include "rtypes.h"
#include "connex.h"
#include "limit.h"
#include "rprm.h"
#include "fitdata.h"
#include "oldfitcnx.h"


struct RadarParm prm;
struct FitData fit;

int main(int argc,char *argv[]) {
  int sock;
  int port=0;
  char *host;
  int flag,status;

  host=argv[argc-2];
  port=atoi(argv[argc-1]);

  sock=ConnexOpen(host,port);
  if (sock<0) {
    fprintf(stderr,"Could not connect to host.'n");
    exit(-1);
  }
  do {
    status=OldFitCnxRead(1,&sock,&prm,&fit,&flag,NULL);
    if (status==-1) break;
    if (flag !=-1) fprintf(stdout,"%d-%d-%d %d:%d:%d %d %d'n",
              prm.time.yr,prm.time.mo,prm.time.dy,
	      prm.time.hr,prm.time.mt,prm.time.sc,prm.bmnum,prm.scan);

             

  } while(1);
  fprintf(stderr,"Connection failed.'n");
  return 0;
}