diff options
Diffstat (limited to 'contrib/ntp/libparse/data_mbg.c')
-rw-r--r-- | contrib/ntp/libparse/data_mbg.c | 143 |
1 files changed, 73 insertions, 70 deletions
diff --git a/contrib/ntp/libparse/data_mbg.c b/contrib/ntp/libparse/data_mbg.c index 23ca75509180..0b3808c8ba64 100644 --- a/contrib/ntp/libparse/data_mbg.c +++ b/contrib/ntp/libparse/data_mbg.c @@ -43,6 +43,7 @@ #include "ntp_types.h" #include "ntp_stdlib.h" #include "ntp_fp.h" +#include "ntp_calendar.h" #include "mbg_gps166.h" #include "binio.h" #include "ieee754io.h" @@ -63,10 +64,10 @@ put_mbg_header( GPS_MSG_HDR *headerp ) { - put_lsb_short(bufpp, headerp->gps_cmd); - put_lsb_short(bufpp, headerp->gps_len); - put_lsb_short(bufpp, headerp->gps_data_csum); - put_lsb_short(bufpp, headerp->gps_hdr_csum); + put_lsb_short(bufpp, headerp->cmd); + put_lsb_short(bufpp, headerp->len); + put_lsb_short(bufpp, headerp->data_csum); + put_lsb_short(bufpp, headerp->hdr_csum); } void @@ -75,7 +76,7 @@ get_mbg_sw_rev( SW_REV *sw_revp ) { - sw_revp->code = get_lsb_short(bufpp); + sw_revp->code = get_lsb_uint16(bufpp); memcpy(sw_revp->name, *bufpp, sizeof(sw_revp->name)); *bufpp += sizeof(sw_revp->name); } @@ -86,8 +87,8 @@ get_mbg_ascii_msg( ASCII_MSG *ascii_msgp ) { - ascii_msgp->csum = get_lsb_short(bufpp); - ascii_msgp->valid = get_lsb_short(bufpp); + ascii_msgp->csum = (CSUM) get_lsb_short(bufpp); + ascii_msgp->valid = get_lsb_int16(bufpp); memcpy(ascii_msgp->s, *bufpp, sizeof(ascii_msgp->s)); *bufpp += sizeof(ascii_msgp->s); } @@ -98,7 +99,7 @@ get_mbg_svno( SVNO *svnop ) { - *svnop = get_lsb_short(bufpp); + *svnop = (SVNO) get_lsb_short(bufpp); } void @@ -107,7 +108,7 @@ get_mbg_health( HEALTH *healthp ) { - *healthp = get_lsb_short(bufpp); + *healthp = (HEALTH) get_lsb_short(bufpp); } void @@ -116,7 +117,7 @@ get_mbg_cfg( CFG *cfgp ) { - *cfgp = get_lsb_short(bufpp); + *cfgp = (CFG) get_lsb_short(bufpp); } void @@ -125,7 +126,7 @@ get_mbg_tgps( T_GPS *tgpsp ) { - tgpsp->wn = get_lsb_short(bufpp); + tgpsp->wn = get_lsb_uint16(bufpp); tgpsp->sec = get_lsb_long(bufpp); tgpsp->tick = get_lsb_long(bufpp); } @@ -133,20 +134,20 @@ get_mbg_tgps( void get_mbg_tm( unsigned char **buffpp, - TM *tmp + TM_GPS *tmp ) { - tmp->year = get_lsb_short(buffpp); + tmp->year = get_lsb_int16(buffpp); tmp->month = *(*buffpp)++; - tmp->mday = *(*buffpp)++; - tmp->yday = get_lsb_short(buffpp); - tmp->wday = *(*buffpp)++; - tmp->hour = *(*buffpp)++; - tmp->minute = *(*buffpp)++; - tmp->second = *(*buffpp)++; - tmp->frac = get_lsb_long(buffpp); + tmp->mday = *(*buffpp)++; + tmp->yday = get_lsb_int16(buffpp); + tmp->wday = *(*buffpp)++; + tmp->hour = *(*buffpp)++; + tmp->min = *(*buffpp)++; + tmp->sec = *(*buffpp)++; + tmp->frac = get_lsb_long(buffpp); tmp->offs_from_utc = get_lsb_long(buffpp); - tmp->status= get_lsb_short(buffpp); + tmp->status = get_lsb_uint16(buffpp); } void @@ -155,7 +156,7 @@ get_mbg_ttm( TTM *ttmp ) { - ttmp->channel = get_lsb_short(buffpp); + ttmp->channel = get_lsb_int16(buffpp); get_mbg_tgps(buffpp, &ttmp->t); get_mbg_tm(buffpp, &ttmp->tm); } @@ -166,9 +167,9 @@ get_mbg_synth( SYNTH *synthp ) { - synthp->freq = get_lsb_short(buffpp); - synthp->range = get_lsb_short(buffpp); - synthp->phase = get_lsb_short(buffpp); + synthp->freq = get_lsb_int16(buffpp); + synthp->range = get_lsb_int16(buffpp); + synthp->phase = get_lsb_int16(buffpp); } static void @@ -201,7 +202,7 @@ get_mbg_antinfo( ANT_INFO *antinfop ) { - antinfop->status = get_lsb_short(buffpp); + antinfop->status = get_lsb_int16(buffpp); get_mbg_tm(buffpp, &antinfop->tm_disconn); get_mbg_tm(buffpp, &antinfop->tm_reconn); antinfop->delta_t = get_lsb_long(buffpp); @@ -216,8 +217,8 @@ mbg_time_status_str( { static struct state { - int flag; /* bit flag */ - const char *string; /* bit name */ + int flag; /* bit flag */ + const char *string; /* bit name */ } states[] = { { TM_UTC, "UTC CORR" }, @@ -233,7 +234,7 @@ mbg_time_status_str( { char *start, *p; struct state *s; - + start = p = *buffpp; for (s = states; s->flag; s++) @@ -252,25 +253,27 @@ mbg_time_status_str( *buffpp = p; } } - + void mbg_tm_str( char **buffpp, - TM *tmp, - int size + TM_GPS *tmp, + int size, + int print_status ) { char *s = *buffpp; snprintf(*buffpp, size, "%04d-%02d-%02d %02d:%02d:%02d.%07ld (%c%02d%02d) ", tmp->year, tmp->month, tmp->mday, - tmp->hour, tmp->minute, tmp->second, tmp->frac, + tmp->hour, tmp->min, tmp->sec, (long) tmp->frac, (tmp->offs_from_utc < 0) ? '-' : '+', abs((int)tmp->offs_from_utc) / 3600, (abs((int)tmp->offs_from_utc) / 60) % 60); *buffpp += strlen(*buffpp); - mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s)); + if (print_status) + mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s)); } void @@ -281,8 +284,8 @@ mbg_tgps_str( ) { snprintf(*buffpp, size, "week %d + %ld days + %ld.%07ld sec", - tgpsp->wn, tgpsp->sec / 86400, - tgpsp->sec % 86400, tgpsp->tick); + tgpsp->wn, (long) tgpsp->sec / SECSPERDAY, + (long) tgpsp->sec % SECSPERDAY, (long) tgpsp->tick); *buffpp += strlen(*buffpp); } @@ -293,19 +296,19 @@ get_mbg_cfgh( ) { int i; - - cfghp->csum = get_lsb_short(buffpp); - cfghp->valid = get_lsb_short(buffpp); + + cfghp->csum = (CSUM) get_lsb_short(buffpp); + cfghp->valid = get_lsb_int16(buffpp); get_mbg_tgps(buffpp, &cfghp->tot_51); get_mbg_tgps(buffpp, &cfghp->tot_63); get_mbg_tgps(buffpp, &cfghp->t0a); - for (i = MIN_SVNO; i <= MAX_SVNO; i++) + for (i = 0; i < N_SVNO_GPS; i++) { get_mbg_cfg(buffpp, &cfghp->cfg[i]); } - - for (i = MIN_SVNO; i <= MAX_SVNO; i++) + + for (i = 0; i < N_SVNO_GPS; i++) { get_mbg_health(buffpp, &cfghp->health[i]); } @@ -317,23 +320,23 @@ get_mbg_utc( UTC *utcp ) { - utcp->csum = get_lsb_short(buffpp); - utcp->valid = get_lsb_short(buffpp); + utcp->csum = (CSUM) get_lsb_short(buffpp); + utcp->valid = get_lsb_int16(buffpp); get_mbg_tgps(buffpp, &utcp->t0t); - + if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A0, mbg_double) != IEEE_OK) { L_CLR(&utcp->A0); } - + if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A1, mbg_double) != IEEE_OK) { L_CLR(&utcp->A1); } - utcp->WNlsf = get_lsb_short(buffpp); - utcp->DNt = get_lsb_short(buffpp); + utcp->WNlsf = get_lsb_uint16(buffpp); + utcp->DNt = get_lsb_int16(buffpp); utcp->delta_tls = *(*buffpp)++; utcp->delta_tlsf = *(*buffpp)++; } @@ -345,7 +348,7 @@ get_mbg_lla( ) { int i; - + for (i = LAT; i <= ALT; i++) { if (fetch_ieee754(buffpp, IEEE_DOUBLE, &lla[i], mbg_double) != IEEE_OK) @@ -367,7 +370,7 @@ get_mbg_xyz( ) { int i; - + for (i = XP; i <= ZP; i++) { if (fetch_ieee754(buffpp, IEEE_DOUBLE, &xyz[i], mbg_double) != IEEE_OK) @@ -384,13 +387,13 @@ get_mbg_comparam( ) { size_t i; - + comparamp->baud_rate = get_lsb_long(buffpp); for (i = 0; i < sizeof(comparamp->framing); i++) { comparamp->framing[i] = *(*buffpp)++; } - comparamp->handshake = get_lsb_short(buffpp); + comparamp->handshake = get_lsb_int16(buffpp); } void @@ -400,12 +403,12 @@ get_mbg_portparam( ) { int i; - - for (i = 0; i < N_COM; i++) + + for (i = 0; i < DEFAULT_N_COM; i++) { get_mbg_comparam(buffpp, &portparamp->com[i]); } - for (i = 0; i < N_COM; i++) + for (i = 0; i < DEFAULT_N_COM; i++) { portparamp->mode[i] = *(*buffpp)++; } @@ -416,20 +419,20 @@ get_mbg_portparam( { \ L_CLR(addr); \ } - + void get_mbg_eph( unsigned char ** buffpp, EPH *ephp ) { - ephp->csum = get_lsb_short(buffpp); - ephp->valid = get_lsb_short(buffpp); - - ephp->health = get_lsb_short(buffpp); - ephp->IODC = get_lsb_short(buffpp); - ephp->IODE2 = get_lsb_short(buffpp); - ephp->IODE3 = get_lsb_short(buffpp); + ephp->csum = (CSUM) get_lsb_short(buffpp); + ephp->valid = get_lsb_int16(buffpp); + + ephp->health = (HEALTH) get_lsb_short(buffpp); + ephp->IODC = (IOD) get_lsb_short(buffpp); + ephp->IODE2 = (IOD) get_lsb_short(buffpp); + ephp->IODE3 = (IOD) get_lsb_short(buffpp); get_mbg_tgps(buffpp, &ephp->tt); get_mbg_tgps(buffpp, &ephp->t0c); @@ -456,7 +459,7 @@ get_mbg_eph( FETCH_DOUBLE(buffpp, &ephp->af2); FETCH_DOUBLE(buffpp, &ephp->tgd); - ephp->URA = get_lsb_short(buffpp); + ephp->URA = get_lsb_uint16(buffpp); ephp->L2code = *(*buffpp)++; ephp->L2flag = *(*buffpp)++; @@ -468,10 +471,10 @@ get_mbg_alm( ALM *almp ) { - almp->csum = get_lsb_short(buffpp); - almp->valid = get_lsb_short(buffpp); - - almp->health = get_lsb_short(buffpp); + almp->csum = (CSUM) get_lsb_short(buffpp); + almp->valid = get_lsb_int16(buffpp); + + almp->health = (HEALTH) get_lsb_short(buffpp); get_mbg_tgps(buffpp, &almp->t0a); @@ -493,8 +496,8 @@ get_mbg_iono( IONO *ionop ) { - ionop->csum = get_lsb_short(buffpp); - ionop->valid = get_lsb_short(buffpp); + ionop->csum = (CSUM) get_lsb_short(buffpp); + ionop->valid = get_lsb_int16(buffpp); FETCH_DOUBLE(buffpp, &ionop->alpha_0); FETCH_DOUBLE(buffpp, &ionop->alpha_1); |