1ef64b99roberto/*
27a6072eroberto * /src/NTP/REPOSITORY/ntp4-dev/libparse/data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
37a6072eroberto *
47a6072eroberto * data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
5ef64b99roberto *
6ef64b99roberto * $Created: Sun Jul 20 12:08:14 1997 $
7ef64b99roberto *
87a6072eroberto * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
97a6072eroberto *
107a6072eroberto * Redistribution and use in source and binary forms, with or without
117a6072eroberto * modification, are permitted provided that the following conditions
127a6072eroberto * are met:
137a6072eroberto * 1. Redistributions of source code must retain the above copyright
147a6072eroberto *    notice, this list of conditions and the following disclaimer.
157a6072eroberto * 2. Redistributions in binary form must reproduce the above copyright
167a6072eroberto *    notice, this list of conditions and the following disclaimer in the
177a6072eroberto *    documentation and/or other materials provided with the distribution.
187a6072eroberto * 3. Neither the name of the author nor the names of its contributors
197a6072eroberto *    may be used to endorse or promote products derived from this software
207a6072eroberto *    without specific prior written permission.
217a6072eroberto *
227a6072eroberto * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
237a6072eroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
247a6072eroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
257a6072eroberto * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
267a6072eroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
277a6072eroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
287a6072eroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
297a6072eroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
307a6072eroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
317a6072eroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
327a6072eroberto * SUCH DAMAGE.
337a6072eroberto *
34ef64b99roberto */
35ef64b99roberto
36047f369cy#include <config.h>
37ef64b99roberto#ifdef PARSESTREAM
38ef64b99roberto#define NEED_BOPS
39ef64b99roberto#include "ntp_string.h"
40ef64b99roberto#else
41ef64b99roberto#include <stdio.h>
42ef64b99roberto#endif
43ef64b99roberto#include "ntp_types.h"
44ef64b99roberto#include "ntp_stdlib.h"
45ef64b99roberto#include "ntp_fp.h"
46f63afe2cy#include "ntp_calendar.h"
47ef64b99roberto#include "mbg_gps166.h"
48ef64b99roberto#include "binio.h"
49ef64b99roberto#include "ieee754io.h"
50ef64b99roberto
51d54cfbdrobertostatic void get_mbg_tzname (unsigned char **, char *);
52d54cfbdrobertostatic void mbg_time_status_str (char **, unsigned int, int);
53ef64b99roberto
54ef64b99roberto#if 0				/* no actual floats on Meinberg binary interface */
55ef64b99robertostatic offsets_t mbg_float  = { 1, 0, 3, 2, 0, 0, 0, 0 }; /* byte order for meinberg floats */
56ef64b99roberto#endif
57ef64b99robertostatic offsets_t mbg_double = { 1, 0, 3, 2, 5, 4, 7, 6 }; /* byte order for meinberg doubles */
58ef64b99robertostatic int32   rad2deg_i = 57;
59ef64b99robertostatic u_int32 rad2deg_f = 0x4BB834C7; /* 57.2957795131 == 180/PI */
60ef64b99roberto
61ef64b99robertovoid
62ef64b99robertoput_mbg_header(
63ef64b99roberto	unsigned char **bufpp,
64ef64b99roberto	GPS_MSG_HDR *headerp
65ef64b99roberto	)
66ef64b99roberto{
67f63afe2cy  put_lsb_short(bufpp, headerp->cmd);
68f63afe2cy  put_lsb_short(bufpp, headerp->len);
69f63afe2cy  put_lsb_short(bufpp, headerp->data_csum);
70f63afe2cy  put_lsb_short(bufpp, headerp->hdr_csum);
71ef64b99roberto}
72ef64b99roberto
73ef64b99robertovoid
74ef64b99robertoget_mbg_sw_rev(
75ef64b99roberto	unsigned char **bufpp,
76ef64b99roberto	SW_REV *sw_revp
77ef64b99roberto	)
78ef64b99roberto{
79f63afe2cy  sw_revp->code = get_lsb_uint16(bufpp);
80ef64b99roberto  memcpy(sw_revp->name, *bufpp, sizeof(sw_revp->name));
81ef64b99roberto  *bufpp += sizeof(sw_revp->name);
82ef64b99roberto}
83ef64b99roberto
84ef64b99robertovoid
85ef64b99robertoget_mbg_ascii_msg(
86ef64b99roberto	unsigned char **bufpp,
87ef64b99roberto	ASCII_MSG *ascii_msgp
88ef64b99roberto	)
89ef64b99roberto{
90f63afe2cy  ascii_msgp->csum  = (CSUM) get_lsb_short(bufpp);
91f63afe2cy  ascii_msgp->valid = get_lsb_int16(bufpp);
92ef64b99roberto  memcpy(ascii_msgp->s, *bufpp, sizeof(ascii_msgp->s));
93ef64b99roberto  *bufpp += sizeof(ascii_msgp->s);
94ef64b99roberto}
95ef64b99roberto
96ef64b99robertovoid
97ef64b99robertoget_mbg_svno(
98ef64b99roberto	unsigned char **bufpp,
99ef64b99roberto	SVNO *svnop
100ef64b99roberto	)
101ef64b99roberto{
102f63afe2cy  *svnop = (SVNO) get_lsb_short(bufpp);
103ef64b99roberto}
104ef64b99roberto
105ef64b99robertovoid
106ef64b99robertoget_mbg_health(
107ef64b99roberto	unsigned char **bufpp,
108ef64b99roberto	HEALTH *healthp
109ef64b99roberto	)
110ef64b99roberto{
111f63afe2cy  *healthp = (HEALTH) get_lsb_short(bufpp);
112ef64b99roberto}
113ef64b99roberto
114ef64b99robertovoid
115ef64b99robertoget_mbg_cfg(
116ef64b99roberto	unsigned char **bufpp,
117ef64b99roberto	CFG *cfgp
118ef64b99roberto	)
119ef64b99roberto{
120f63afe2cy  *cfgp = (CFG) get_lsb_short(bufpp);
121ef64b99roberto}
122ef64b99roberto
123ef64b99robertovoid
124ef64b99robertoget_mbg_tgps(
125ef64b99roberto	unsigned char **bufpp,
126ef64b99roberto	T_GPS *tgpsp
127ef64b99roberto	)
128ef64b99roberto{
129f63afe2cy  tgpsp->wn = get_lsb_uint16(bufpp);
130ef64b99roberto  tgpsp->sec = get_lsb_long(bufpp);
131ef64b99roberto  tgpsp->tick = get_lsb_long(bufpp);
132ef64b99roberto}
133ef64b99roberto
134ef64b99robertovoid
135ef64b99robertoget_mbg_tm(
136ef64b99roberto	unsigned char **buffpp,
137f63afe2cy	TM_GPS *tmp
138ef64b99roberto	)
139ef64b99roberto{
140f63afe2cy  tmp->year = get_lsb_int16(buffpp);
141ef64b99roberto  tmp->month = *(*buffpp)++;
142f63afe2cy  tmp->mday = *(*buffpp)++;
143f63afe2cy  tmp->yday = get_lsb_int16(buffpp);
144f63afe2cy  tmp->wday = *(*buffpp)++;
145f63afe2cy  tmp->hour = *(*buffpp)++;
146f63afe2cy  tmp->min = *(*buffpp)++;
147f63afe2cy  tmp->sec = *(*buffpp)++;
148f63afe2cy  tmp->frac = get_lsb_long(buffpp);
149ef64b99roberto  tmp->offs_from_utc = get_lsb_long(buffpp);
150f63afe2cy  tmp->status = get_lsb_uint16(buffpp);
151ef64b99roberto}
152ef64b99roberto
153ef64b99robertovoid
154ef64b99robertoget_mbg_ttm(
155ef64b99roberto	unsigned char **buffpp,
156ef64b99roberto	TTM *ttmp
157ef64b99roberto	)
158ef64b99roberto{
159f63afe2cy  ttmp->channel = get_lsb_int16(buffpp);
160ef64b99roberto  get_mbg_tgps(buffpp, &ttmp->t);
161ef64b99roberto  get_mbg_tm(buffpp, &ttmp->tm);
162ef64b99roberto}
163ef64b99roberto
164ef64b99robertovoid
165ef64b99robertoget_mbg_synth(
166ef64b99roberto	unsigned char **buffpp,
167ef64b99roberto	SYNTH *synthp
168ef64b99roberto	)
169ef64b99roberto{
170f63afe2cy  synthp->freq  = get_lsb_int16(buffpp);
171f63afe2cy  synthp->range = get_lsb_int16(buffpp);
172f63afe2cy  synthp->phase = get_lsb_int16(buffpp);
173ef64b99roberto}
174ef64b99roberto
175ef64b99robertostatic void
176ef64b99robertoget_mbg_tzname(
177ef64b99roberto	unsigned char **buffpp,
178ef64b99roberto	char *tznamep
179ef64b99roberto	)
180ef64b99roberto{
181047f369cy  strlcpy(tznamep, (char *)*buffpp, sizeof(TZ_NAME));
182ef64b99roberto  *buffpp += sizeof(TZ_NAME);
183ef64b99roberto}
184ef64b99roberto
185ef64b99robertovoid
186ef64b99robertoget_mbg_tzdl(
187ef64b99roberto	unsigned char **buffpp,
188ef64b99roberto	TZDL *tzdlp
189ef64b99roberto	)
190ef64b99roberto{
191ef64b99roberto  tzdlp->offs = get_lsb_long(buffpp);
192ef64b99roberto  tzdlp->offs_dl = get_lsb_long(buffpp);
193ef64b99roberto  get_mbg_tm(buffpp, &tzdlp->tm_on);
194ef64b99roberto  get_mbg_tm(buffpp, &tzdlp->tm_off);
195ef64b99roberto  get_mbg_tzname(buffpp, (char *)tzdlp->name[0]);
196ef64b99roberto  get_mbg_tzname(buffpp, (char *)tzdlp->name[1]);
197ef64b99roberto}
198ef64b99roberto
199ef64b99robertovoid
200ef64b99robertoget_mbg_antinfo(
201ef64b99roberto	unsigned char **buffpp,
202ef64b99roberto	ANT_INFO *antinfop
203ef64b99roberto	)
204ef64b99roberto{
205f63afe2cy  antinfop->status = get_lsb_int16(buffpp);
206ef64b99roberto  get_mbg_tm(buffpp, &antinfop->tm_disconn);
207ef64b99roberto  get_mbg_tm(buffpp, &antinfop->tm_reconn);
208ef64b99roberto  antinfop->delta_t = get_lsb_long(buffpp);
209ef64b99roberto}
210ef64b99roberto
211ef64b99robertostatic void
212ef64b99robertombg_time_status_str(
2137a6072eroberto	char **buffpp,
2147a6072eroberto	unsigned int status,
2157a6072eroberto	int size
216ef64b99roberto	)
217ef64b99roberto{
2187a6072eroberto	static struct state
2197a6072eroberto	{
220f63afe2cy		int         flag;       /* bit flag */
221f63afe2cy		const char *string;     /* bit name */
2227a6072eroberto	} states[] =
2237a6072eroberto		  {
2247a6072eroberto			  { TM_UTC,    "UTC CORR" },
2257a6072eroberto			  { TM_LOCAL,  "LOCAL TIME" },
2267a6072eroberto			  { TM_DL_ANN, "DST WARN" },
2277a6072eroberto			  { TM_DL_ENB, "DST" },
2287a6072eroberto			  { TM_LS_ANN, "LEAP WARN" },
2297a6072eroberto			  { TM_LS_ENB, "LEAP SEC" },
2307a6072eroberto			  { 0, "" }
2317a6072eroberto		  };
2327a6072eroberto
2337a6072eroberto	if (status)
2347a6072eroberto	{
2357a6072eroberto		char *start, *p;
2367a6072eroberto		struct state *s;
237f63afe2cy
2387a6072eroberto		start = p = *buffpp;
239ef64b99roberto
2407a6072eroberto		for (s = states; s->flag; s++)
241ef64b99roberto		{
2427a6072eroberto			if (s->flag & status)
2437a6072eroberto			{
2447a6072eroberto				if (p != *buffpp)
2457a6072eroberto				{
246047f369cy					strlcpy(p, ", ", size - (p - start));
2477a6072eroberto					p += 2;
2487a6072eroberto				}
249047f369cy				strlcpy(p, s->string, size - (p - start));
2507a6072eroberto				p += strlen(p);
2517a6072eroberto			}
252ef64b99roberto		}
2537a6072eroberto		*buffpp = p;
254ef64b99roberto	}
255ef64b99roberto}
256f63afe2cy
257ef64b99robertovoid
258ef64b99robertombg_tm_str(
2597a6072eroberto	char **buffpp,
260f63afe2cy	TM_GPS *tmp,
261f63afe2cy	int size,
262f63afe2cy	int print_status
263ef64b99roberto	)
264ef64b99roberto{
2657a6072eroberto	char *s = *buffpp;
2667a6072eroberto
2677a6072eroberto	snprintf(*buffpp, size, "%04d-%02d-%02d %02d:%02d:%02d.%07ld (%c%02d%02d) ",
2687a6072eroberto		 tmp->year, tmp->month, tmp->mday,
269f63afe2cy		 tmp->hour, tmp->min, tmp->sec, (long) tmp->frac,
2707a6072eroberto		 (tmp->offs_from_utc < 0) ? '-' : '+',
271bdc155dcy		 abs((int)tmp->offs_from_utc) / 3600,
272bdc155dcy		 (abs((int)tmp->offs_from_utc) / 60) % 60);
2737a6072eroberto	*buffpp += strlen(*buffpp);
2747a6072eroberto
275f63afe2cy	if (print_status)
276f63afe2cy		mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s));
277ef64b99roberto}
278ef64b99roberto
279ef64b99robertovoid
280ef64b99robertombg_tgps_str(
2817a6072eroberto	char **buffpp,
2827a6072eroberto	T_GPS *tgpsp,
2837a6072eroberto	int size
284ef64b99roberto	)
285ef64b99roberto{
2867a6072eroberto	snprintf(*buffpp, size, "week %d + %ld days + %ld.%07ld sec",
287f63afe2cy		 tgpsp->wn, (long) tgpsp->sec / SECSPERDAY,
288f63afe2cy		 (long) tgpsp->sec % SECSPERDAY, (long) tgpsp->tick);
2897a6072eroberto	*buffpp += strlen(*buffpp);
290ef64b99roberto}
291ef64b99roberto
292ef64b99robertovoid
293ef64b99robertoget_mbg_cfgh(
294ef64b99roberto	unsigned char **buffpp,
295ef64b99roberto	CFGH *cfghp
296ef64b99roberto	)
297ef64b99roberto{
298ef64b99roberto  int i;
299f63afe2cy
300f63afe2cy  cfghp->csum = (CSUM) get_lsb_short(buffpp);
301f63afe2cy  cfghp->valid = get_lsb_int16(buffpp);
302ef64b99roberto  get_mbg_tgps(buffpp, &cfghp->tot_51);
303ef64b99roberto  get_mbg_tgps(buffpp, &cfghp->tot_63);
304ef64b99roberto  get_mbg_tgps(buffpp, &cfghp->t0a);
305ef64b99roberto
306f63afe2cy  for (i = 0; i < N_SVNO_GPS; i++)
307ef64b99roberto    {
308ef64b99roberto      get_mbg_cfg(buffpp, &cfghp->cfg[i]);
309ef64b99roberto    }
310f63afe2cy
311f63afe2cy  for (i = 0; i < N_SVNO_GPS; i++)
312ef64b99roberto    {
313ef64b99roberto      get_mbg_health(buffpp, &cfghp->health[i]);
314ef64b99roberto    }
315ef64b99roberto}
316ef64b99roberto
317ef64b99robertovoid
318ef64b99robertoget_mbg_utc(
319ef64b99roberto	unsigned char **buffpp,
320ef64b99roberto	UTC *utcp
321ef64b99roberto	)
322ef64b99roberto{
323f63afe2cy  utcp->csum  = (CSUM) get_lsb_short(buffpp);
324f63afe2cy  utcp->valid = get_lsb_int16(buffpp);
325ef64b99roberto
326ef64b99roberto  get_mbg_tgps(buffpp, &utcp->t0t);
327f63afe2cy
328ef64b99roberto  if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A0, mbg_double) != IEEE_OK)
329ef64b99roberto    {
330ef64b99roberto      L_CLR(&utcp->A0);
331ef64b99roberto    }
332f63afe2cy
333ef64b99roberto  if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A1, mbg_double) != IEEE_OK)
334ef64b99roberto    {
335ef64b99roberto      L_CLR(&utcp->A1);
336ef64b99roberto    }
337ef64b99roberto
338f63afe2cy  utcp->WNlsf      = get_lsb_uint16(buffpp);
339f63afe2cy  utcp->DNt        = get_lsb_int16(buffpp);
340ef64b99roberto  utcp->delta_tls  = *(*buffpp)++;
341ef64b99roberto  utcp->delta_tlsf = *(*buffpp)++;
342ef64b99roberto}
343ef64b99roberto
344ef64b99robertovoid
345ef64b99robertoget_mbg_lla(
346ef64b99roberto	unsigned char **buffpp,
347ef64b99roberto	LLA lla
348ef64b99roberto	)
349ef64b99roberto{
350ef64b99roberto  int i;
351f63afe2cy
352ef64b99roberto  for (i = LAT; i <= ALT; i++)
353ef64b99roberto    {
354ef64b99roberto      if  (fetch_ieee754(buffpp, IEEE_DOUBLE, &lla[i], mbg_double) != IEEE_OK)
355ef64b99roberto	{
356ef64b99roberto	  L_CLR(&lla[i]);
357ef64b99roberto	}
358ef64b99roberto      else
359ef64b99roberto	if (i != ALT)
360ef64b99roberto	  {			/* convert to degrees (* 180/PI) */
361ef64b99roberto	    mfp_mul(&lla[i].l_i, &lla[i].l_uf, lla[i].l_i, lla[i].l_uf, rad2deg_i, rad2deg_f);
362ef64b99roberto	  }
363ef64b99roberto    }
364ef64b99roberto}
365ef64b99roberto
366ef64b99robertovoid
367ef64b99robertoget_mbg_xyz(
368ef64b99roberto	unsigned char **buffpp,
369ef64b99roberto	XYZ xyz
370ef64b99roberto	)
371ef64b99roberto{
372ef64b99roberto  int i;
373f63afe2cy
374ef64b99roberto  for (i = XP; i <= ZP; i++)
375ef64b99roberto    {
376ef64b99roberto      if  (fetch_ieee754(buffpp, IEEE_DOUBLE, &xyz[i], mbg_double) != IEEE_OK)
377ef64b99roberto	{
378ef64b99roberto	  L_CLR(&xyz[i]);
379ef64b99roberto	}
380ef64b99roberto    }
381ef64b99roberto}
382ef64b99roberto
383ef64b99robertostatic void
384ef64b99robertoget_mbg_comparam(
385ef64b99roberto	unsigned char **buffpp,
386ef64b99roberto	COM_PARM *comparamp
387ef64b99roberto	)
388ef64b99roberto{
389bdc155dcy  size_t i;
390f63afe2cy
391ef64b99roberto  comparamp->baud_rate = get_lsb_long(buffpp);
392ef64b99roberto  for (i = 0; i < sizeof(comparamp->framing); i++)
393ef64b99roberto    {
394ef64b99roberto      comparamp->framing[i] = *(*buffpp)++;
395ef64b99roberto    }
396f63afe2cy  comparamp->handshake = get_lsb_int16(buffpp);
397ef64b99roberto}
398ef64b99roberto
399ef64b99robertovoid
400ef64b99robertoget_mbg_portparam(
401ef64b99roberto	unsigned char **buffpp,
402ef64b99roberto	PORT_PARM *portparamp
403ef64b99roberto	)
404ef64b99roberto{
405ef64b99roberto  int i;
406f63afe2cy
407f63afe2cy  for (i = 0; i < DEFAULT_N_COM; i++)
408ef64b99roberto    {
409ef64b99roberto      get_mbg_comparam(buffpp, &portparamp->com[i]);
410ef64b99roberto    }
411f63afe2cy  for (i = 0; i < DEFAULT_N_COM; i++)
412ef64b99roberto    {
413ef64b99roberto      portparamp->mode[i] = *(*buffpp)++;
414ef64b99roberto    }
415ef64b99roberto}
416ef64b99roberto
417ef64b99roberto#define FETCH_DOUBLE(src, addr)							\
418ef64b99roberto	if  (fetch_ieee754(src, IEEE_DOUBLE, addr, mbg_double) != IEEE_OK)	\
419ef64b99roberto	{									\
420ef64b99roberto	  L_CLR(addr);								\
421ef64b99roberto	}
422f63afe2cy
423ef64b99robertovoid
424ef64b99robertoget_mbg_eph(
425ef64b99roberto	unsigned char ** buffpp,
426ef64b99roberto	EPH *ephp
427ef64b99roberto	)
428ef64b99roberto{
429f63afe2cy  ephp->csum   = (CSUM) get_lsb_short(buffpp);
430f63afe2cy  ephp->valid  = get_lsb_int16(buffpp);
431f63afe2cy
432f63afe2cy  ephp->health = (HEALTH) get_lsb_short(buffpp);
433f63afe2cy  ephp->IODC   = (IOD) get_lsb_short(buffpp);
434f63afe2cy  ephp->IODE2  = (IOD) get_lsb_short(buffpp);
435f63afe2cy  ephp->IODE3  = (IOD) get_lsb_short(buffpp);
436ef64b99roberto
437ef64b99roberto  get_mbg_tgps(buffpp, &ephp->tt);
438ef64b99roberto  get_mbg_tgps(buffpp, &ephp->t0c);
439ef64b99roberto  get_mbg_tgps(buffpp, &ephp->t0e);
440ef64b99roberto
441ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->sqrt_A);
442ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->e);
443ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->M0);
444ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->omega);
445ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->OMEGA0);
446ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->OMEGADOT);
447ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->deltan);
448ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->i0);
449ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->idot);
450ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->crc);
451ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->crs);
452ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->cuc);
453ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->cus);
454ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->cic);
455ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->cis);
456ef64b99roberto
457ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->af0);
458ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->af1);
459ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->af2);
460ef64b99roberto  FETCH_DOUBLE(buffpp, &ephp->tgd);
461ef64b99roberto
462f63afe2cy  ephp->URA = get_lsb_uint16(buffpp);
463ef64b99roberto
464ef64b99roberto  ephp->L2code = *(*buffpp)++;
465ef64b99roberto  ephp->L2flag = *(*buffpp)++;
466ef64b99roberto}
467ef64b99roberto
468ef64b99robertovoid
469ef64b99robertoget_mbg_alm(
470ef64b99roberto	unsigned char **buffpp,
471ef64b99roberto	ALM *almp
472ef64b99roberto	)
473ef64b99roberto{
474f63afe2cy  almp->csum   = (CSUM) get_lsb_short(buffpp);
475f63afe2cy  almp->valid  = get_lsb_int16(buffpp);
476f63afe2cy
477f63afe2cy  almp->health = (HEALTH) get_lsb_short(buffpp);
478ef64b99roberto  get_mbg_tgps(buffpp, &almp->t0a);
479ef64b99roberto
480ef64b99roberto
481ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->sqrt_A);
482ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->e);
483ef64b99roberto
484ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->M0);
485ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->omega);
486ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->OMEGA0);
487ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->OMEGADOT);
488ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->deltai);
489ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->af0);
490ef64b99roberto  FETCH_DOUBLE(buffpp, &almp->af1);
491ef64b99roberto}
492ef64b99roberto
493ef64b99robertovoid
494ef64b99robertoget_mbg_iono(
495ef64b99roberto	unsigned char **buffpp,
496ef64b99roberto	IONO *ionop
497ef64b99roberto	)
498ef64b99roberto{
499f63afe2cy  ionop->csum   = (CSUM) get_lsb_short(buffpp);
500f63afe2cy  ionop->valid  = get_lsb_int16(buffpp);
501ef64b99roberto
502ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->alpha_0);
503ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->alpha_1);
504ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->alpha_2);
505ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->alpha_3);
506ef64b99roberto
507ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->beta_0);
508ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->beta_1);
509ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->beta_2);
510ef64b99roberto  FETCH_DOUBLE(buffpp, &ionop->beta_3);
511ef64b99roberto}
512ef64b99roberto
513ef64b99roberto/*
514ef64b99roberto * data_mbg.c,v
5157a6072eroberto * Revision 4.8  2006/06/22 18:40:01  kardel
5167a6072eroberto * clean up signedness (gcc 4)
5177a6072eroberto *
5187a6072eroberto * Revision 4.7  2005/10/07 22:11:10  kardel
5197a6072eroberto * bounded buffer implementation
5207a6072eroberto *
5217a6072eroberto * Revision 4.6.2.1  2005/09/25 10:23:06  kardel
5227a6072eroberto * support bounded buffers
5237a6072eroberto *
5247a6072eroberto * Revision 4.6  2005/04/16 17:32:10  kardel
5257a6072eroberto * update copyright
5267a6072eroberto *
5277a6072eroberto * Revision 4.5  2004/11/14 15:29:41  kardel
5287a6072eroberto * support PPSAPI, upgrade Copyright to Berkeley style
5297a6072eroberto *
530ef64b99roberto * Revision 4.3  1999/02/21 12:17:42  kardel
531ef64b99roberto * 4.91f reconcilation
532ef64b99roberto *
533ef64b99roberto * Revision 4.2  1998/06/14 21:09:39  kardel
534ef64b99roberto * Sun acc cleanup
535ef64b99roberto *
536ef64b99roberto * Revision 4.1  1998/05/24 08:02:06  kardel
537ef64b99roberto * trimmed version log
538ef64b99roberto *
539ef64b99roberto * Revision 4.0  1998/04/10 19:45:33  kardel
540ef64b99roberto * Start 4.0 release version numbering
541ef64b99roberto */
542ef64b99roberto
543