[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 19990313: LDM modification for TTAA00 K...
- Subject: Re: 19990313: LDM modification for TTAA00 K...
- Date: Mon, 22 Mar 1999 14:45:42 -0700 (MST)
Gilbert,
I attached the afos files from the ldm 5.0.0 release. I don't know if
they will compile or work for you.
Robb...
On Mon, 15 Mar 1999, Gilbert Sebenste wrote:
> On Sun, 14 Mar 1999, Robb Kambic wrote:
>
> > On Sat, 13 Mar 1999, Unidata Support wrote:
> >
> > >
> > > ------- Forwarded Message
> > >
> > > >From: Gilbert Sebenste <address@hidden>
> > > >Subject: To: Robb Kambic et al...
> > > >Organization: Northern Illinois University
> > > >Keywords: 199903132055.NAA24527 LDM
> > >
> > > Hi Robb,
> > >
> > > Is there anything I can modify in the LDM software to put the
> > > TTAA00 K... header back on the first line of the AFOS PIL?
> >
> > Gilbert,
> >
> > If I get you correctly, 5.0.0 created the extra wmo header part and 5.0.6
> > does not. I would use afos_message.{c,h} from 5.0.0 in the 5.0.6 release
> > and see if that works for you. I checked the cvs log files and 5.0.0 had
> > version 33 and 5.0.6 has version 37. It worth a try.
> >
> > I out of the office until Mar 22, keep me updated on your progress.
> >
> > Robb...
> >
> >
> > > Just curious. My AFOS feed was approved this week by the NWS, so I should
> > > be getting it Monday or Tuesday (if all goes well) when the firewall is
> > > removed.
> > >
> > > Gilbert
> > >
> > > *******************************************************************************
> > > Gilbert Sebenste
> > > ********
> > > Internet: address@hidden (My opinions only!) ******
> > > Staff Meteorologist, Northern Illinois University
> > > ****
> > > Work phone: 815-753-5492
> > > ***
> > > *******************************************************************************
> > >
> > >
> > >
> > > ------- End of Forwarded Message
> > >
> >
> > ===============================================================================
> > Robb Kambic Unidata Program Center
> > Software Engineer III Univ. Corp for Atmospheric
> > Research
> > address@hidden WWW: http://www.unidata.ucar.edu/
> > ===============================================================================
>
> Robb, Et al,
>
> Do you know where we could get a hold of the LDM 5.0.0 source code?
>
> Gilbert
>
> *******************************************************************************
> Gilbert Sebenste ********
> Internet: address@hidden (My opinions only!) ******
> Staff Meteorologist, Northern Illinois University ****
> Work phone: 815-753-5492 ***
> *******************************************************************************
>
>
===============================================================================
Robb Kambic Unidata Program Center
Software Engineer III Univ. Corp for Atmospheric Research
address@hidden WWW: http://www.unidata.ucar.edu/
===============================================================================
/*
* Copyright 1995, University Corporation for Atmospheric Research
* See ../COPYRIGHT file for copying and redistribution conditions.
*/
/* $Id: afos_message.c,v 1.33 1995/11/11 00:47:27 davis Exp $ */
/*
* Routines to handle AFOS messages.
* Thanks to NWS personell, who shared their ldm3 mods and
* other info.
* N.B. This module prepare without any supporting definitions
* or AFOS documentation.
*/
#include <ldmconfig.h>
#include <string.h>
#include <ctype.h>
#include "xbuf.h"
#include "tokens.h"
#include "afos_message.h"
#include "ulog.h"
static int seqno = 0;
static int zczc_missed = 0;
static int nnnn_missed = 0;
static int unrecognizable = 0;
void
afos_stats(void)
{
unotice(" AFOS Messages seen: %8d", seqno - unrecognizable);
unotice(" Errors: lone ZCZC: %8d", nnnn_missed);
unotice(" lone NNNN: %8d", zczc_missed);
unotice(" Unrecognizable: %8d", unrecognizable);
}
/*
* Set time stamp and hook up body of message
*/
static afos_message *
init_afos_message(
xbuf *buf, /* should be a clone ! */
afos_message *mess
)
{
mess->len = buf->cnt;
mess->msg = buf->get;
if( set_timestamp(&mess->arrival) != 0)
return NULL;
return mess;
}
/*
* skip up to the first Upper case char and get the rest of the line
*/
static int
nextUcaseLine(xbuf *buf, char *str, int maxlen)
{
int ch;
do{
ch = nextc(buf);
if(ch == EOB)
break;
}while(!isascii(ch) || !isupper(ch));
unnextc(buf,ch);
return( get_line(buf, str, maxlen) );
}
#define MIN_AFOS_MSG_LEN 14 /* wild ass guess */
static int
get_afos_message(xbuf *buf, afos_message *mess)
{
int zczc_missing = 0;
init_afos_message(buf, mess);
/* DEBUG */
if(mess->len < MIN_AFOS_MSG_LEN)
{
uerror("new_afos_message: length %d too short", mess->len);
goto err;
}
if(!hasSTR(buf, "ZCZC"))
{
/* not fatal, complain later */
zczc_missing = 1;
}
if(nextUcaseLine(buf, mess->ident, 12) == EOB) goto err;
{
/*
* Skip white space and (maybe) the next two bytes.
* What do they mean?
*/
int one;
int two;
do{
one = nextc(buf);
}while((isascii(one) && !isgraph(one)));
if(isascii(one))
unnextc(buf, one);
else
two = nextc(buf);
}
if(get_wmo_header(buf, mess->wmo_hdr) == NULL)
{
mess->wmo_hdr->TT[0] = 0;
mess->wmo_hdr->AA[0] = 0;
mess->wmo_hdr->ii = 0;
mess->wmo_hdr->CCCC[0] = 0;
mess->wmo_hdr->retransmit = ORIGINAL;
mess->wmo_hdr->retrans_seq = MESSAGE_TYPE_UNKNOWN;
}
else if(isascii(mess->wmo_hdr->TT[0]) &&
isupper(mess->wmo_hdr->TT[0]) && isupper(mess->wmo_hdr->TT[1]))
{
size_t len = strlen(mess->ident);
sprintf(&mess->ident[len],
" (%s)", s_wmo_header(mess->wmo_hdr));
}
if(zczc_missing)
{
uerror(" Missing ZCZC: %6s %03d %8d %s",
"AFOS",
seqno,
mess->len,
mess->ident);
}
if(memcmp(&mess->msg[mess->len -4], "NNNN", 4) != 0)
{
uerror(" Missing NNNN: %6s %03d %8d %s",
"AFOS",
seqno,
mess->len,
mess->ident);
/* Fatal, They will send it again */
return -1;
}
return 0;
err:
unrecognizable++;
uerror("Unrecognizable: %5s %03d %8d",
"AFOS",
seqno,
buf->cnt);
return -1;
}
extern void toClients(timestampt arrival,
unsigned seqno,
const char *ident,
unsigned len,
const char *buf);
static void
afos_send_buf(xbuf *buf, int backoff)
{
xbuf clone[1];
afos_message mess[1];
wmo_header_t wmo_hdr[1];
dtime time[1];
seqno++;
mess->wmo_hdr = wmo_hdr;
mess->wmo_hdr->time = time;
clone_xbuf(buf,clone, backoff);
if(get_afos_message(clone, mess) != 0)
return;
/* else, we got something */
toClients(mess->arrival,
seqno,
mess->ident,
mess->len, (char *)mess->msg);
}
int
afos_doavail(xbuf *buf)
{
int sent = 0;
int ch;
static enum afos_l_state {
GND,
Z_,
Z_C_,
Z_C_Z_,
N_,
N_N_,
N_N_N_
} lstate = GND;
static enum afos_state {
START,
HEADER_SEEN,
TRAILER_SEEN
} state = START;
while ((ch = nextc(buf)) != EOB)
{
switch (ch) {
case 'Z':
if(lstate == Z_C_)
lstate = Z_C_Z_;
else
lstate = Z_;
break;
case 'C':
if(lstate == Z_)
lstate = Z_C_;
else if(lstate == Z_C_Z_ )
{
/* Z_C_Z_C */
if(state == HEADER_SEEN)
{
/* missing trailer */
nnnn_missed++;
udebug("Missing NNNN trailer");
afos_send_buf(buf, 4);
sent = 1;
}
justify_xbuf(buf, 4);
state = HEADER_SEEN;
lstate = GND;
}
break;
case 'N':
switch (lstate) {
case N_N_N_ :
/* N_N_N_N */
if(state == TRAILER_SEEN)
{
/* missing header */
zczc_missed++;
udebug("Missing ZCZC header");
}
afos_send_buf(buf, 0);
sent = 1;
justify_xbuf(buf, 0);
state = TRAILER_SEEN;
lstate = GND;
break;
case N_N_ :
lstate = N_N_N_;
break;
case N_ :
lstate = N_N_;
break;
default :
lstate = N_;
break;
} /* lstate switch */
break;
default :
lstate = GND;
break;
} /* ch switch */
} /* input character loop */
return sent;
}
/*
* Copyright 1995, University Corporation for Atmospheric Research
* See ../COPYRIGHT file for copying and redistribution conditions.
*/
/* $Id: afos_message.h,v 1.25 1995/09/18 18:54:00 davis Exp $ */
#ifndef _AFOS_MESSAGE_H_
#define _AFOS_MESSAGE_H_
#include "timestamp.h"
#include "xbuf.h"
#include "wmo_header.h"
/* size of the buffer for 9 character AFOS header */
#define MAX_AFOS_HLEN 16 /* actually, its 9 + 1 */
#define MAX_WMO_HLEN 24 /* actually, its 22 +1 */
/*
* AFOS Message
*/
typedef struct {
timestampt arrival; /* arrival time */
char ident[MAX_AFOS_HLEN +MAX_WMO_HLEN + 4]; /* AFOS header and more */
wmo_header_t *wmo_hdr; /* optional */
unsigned char *msg; /* the whole message */
int len;
} afos_message;
extern void afos_stats(void);
extern int afos_doavail(xbuf *buf);
#endif /* _AFOS_MESSAGE_H_ */