1*cdfa2a7eSchristos /* $NetBSD: data_mbg.c,v 1.9 2020/05/25 20:47:25 christos Exp $ */
2abb0f93cSkardel
3abb0f93cSkardel /*
4abb0f93cSkardel * /src/NTP/REPOSITORY/ntp4-dev/libparse/data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
5abb0f93cSkardel *
6abb0f93cSkardel * data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
7abb0f93cSkardel *
82950cc38Schristos * $Created: Sun Jul 20 12:08:14 1997 $
9abb0f93cSkardel *
10abb0f93cSkardel * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
11abb0f93cSkardel *
12abb0f93cSkardel * Redistribution and use in source and binary forms, with or without
13abb0f93cSkardel * modification, are permitted provided that the following conditions
14abb0f93cSkardel * are met:
15abb0f93cSkardel * 1. Redistributions of source code must retain the above copyright
16abb0f93cSkardel * notice, this list of conditions and the following disclaimer.
17abb0f93cSkardel * 2. Redistributions in binary form must reproduce the above copyright
18abb0f93cSkardel * notice, this list of conditions and the following disclaimer in the
19abb0f93cSkardel * documentation and/or other materials provided with the distribution.
20abb0f93cSkardel * 3. Neither the name of the author nor the names of its contributors
21abb0f93cSkardel * may be used to endorse or promote products derived from this software
22abb0f93cSkardel * without specific prior written permission.
23abb0f93cSkardel *
24abb0f93cSkardel * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
25abb0f93cSkardel * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26abb0f93cSkardel * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27abb0f93cSkardel * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
28abb0f93cSkardel * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29abb0f93cSkardel * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
30abb0f93cSkardel * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
31abb0f93cSkardel * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
32abb0f93cSkardel * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
33abb0f93cSkardel * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
34abb0f93cSkardel * SUCH DAMAGE.
35abb0f93cSkardel *
36abb0f93cSkardel */
37abb0f93cSkardel
382950cc38Schristos #include <config.h>
39abb0f93cSkardel #ifdef PARSESTREAM
40abb0f93cSkardel #define NEED_BOPS
41abb0f93cSkardel #include "ntp_string.h"
42abb0f93cSkardel #else
43abb0f93cSkardel #include <stdio.h>
44abb0f93cSkardel #endif
45abb0f93cSkardel #include "ntp_types.h"
46abb0f93cSkardel #include "ntp_stdlib.h"
47abb0f93cSkardel #include "ntp_fp.h"
487476e6e4Schristos #include "ntp_calendar.h"
49abb0f93cSkardel #include "mbg_gps166.h"
50abb0f93cSkardel #include "binio.h"
51abb0f93cSkardel #include "ieee754io.h"
52abb0f93cSkardel
53abb0f93cSkardel static void get_mbg_tzname (unsigned char **, char *);
54abb0f93cSkardel static void mbg_time_status_str (char **, unsigned int, int);
55abb0f93cSkardel
56abb0f93cSkardel #if 0 /* no actual floats on Meinberg binary interface */
57abb0f93cSkardel static offsets_t mbg_float = { 1, 0, 3, 2, 0, 0, 0, 0 }; /* byte order for meinberg floats */
58abb0f93cSkardel #endif
59abb0f93cSkardel static offsets_t mbg_double = { 1, 0, 3, 2, 5, 4, 7, 6 }; /* byte order for meinberg doubles */
60abb0f93cSkardel static int32 rad2deg_i = 57;
61abb0f93cSkardel static u_int32 rad2deg_f = 0x4BB834C7; /* 57.2957795131 == 180/PI */
62abb0f93cSkardel
63abb0f93cSkardel void
put_mbg_header(unsigned char ** bufpp,GPS_MSG_HDR * headerp)64abb0f93cSkardel put_mbg_header(
65abb0f93cSkardel unsigned char **bufpp,
66abb0f93cSkardel GPS_MSG_HDR *headerp
67abb0f93cSkardel )
68abb0f93cSkardel {
697476e6e4Schristos put_lsb_short(bufpp, headerp->cmd);
707476e6e4Schristos put_lsb_short(bufpp, headerp->len);
717476e6e4Schristos put_lsb_short(bufpp, headerp->data_csum);
727476e6e4Schristos put_lsb_short(bufpp, headerp->hdr_csum);
73abb0f93cSkardel }
74abb0f93cSkardel
75abb0f93cSkardel void
get_mbg_sw_rev(unsigned char ** bufpp,SW_REV * sw_revp)76abb0f93cSkardel get_mbg_sw_rev(
77abb0f93cSkardel unsigned char **bufpp,
78abb0f93cSkardel SW_REV *sw_revp
79abb0f93cSkardel )
80abb0f93cSkardel {
817476e6e4Schristos sw_revp->code = get_lsb_uint16(bufpp);
82abb0f93cSkardel memcpy(sw_revp->name, *bufpp, sizeof(sw_revp->name));
83abb0f93cSkardel *bufpp += sizeof(sw_revp->name);
84abb0f93cSkardel }
85abb0f93cSkardel
86abb0f93cSkardel void
get_mbg_ascii_msg(unsigned char ** bufpp,ASCII_MSG * ascii_msgp)87abb0f93cSkardel get_mbg_ascii_msg(
88abb0f93cSkardel unsigned char **bufpp,
89abb0f93cSkardel ASCII_MSG *ascii_msgp
90abb0f93cSkardel )
91abb0f93cSkardel {
927476e6e4Schristos ascii_msgp->csum = (CSUM) get_lsb_short(bufpp);
937476e6e4Schristos ascii_msgp->valid = get_lsb_int16(bufpp);
94abb0f93cSkardel memcpy(ascii_msgp->s, *bufpp, sizeof(ascii_msgp->s));
95abb0f93cSkardel *bufpp += sizeof(ascii_msgp->s);
96abb0f93cSkardel }
97abb0f93cSkardel
98abb0f93cSkardel void
get_mbg_svno(unsigned char ** bufpp,SVNO * svnop)99abb0f93cSkardel get_mbg_svno(
100abb0f93cSkardel unsigned char **bufpp,
101abb0f93cSkardel SVNO *svnop
102abb0f93cSkardel )
103abb0f93cSkardel {
1047476e6e4Schristos *svnop = (SVNO) get_lsb_short(bufpp);
105abb0f93cSkardel }
106abb0f93cSkardel
107abb0f93cSkardel void
get_mbg_health(unsigned char ** bufpp,HEALTH * healthp)108abb0f93cSkardel get_mbg_health(
109abb0f93cSkardel unsigned char **bufpp,
110abb0f93cSkardel HEALTH *healthp
111abb0f93cSkardel )
112abb0f93cSkardel {
1137476e6e4Schristos *healthp = (HEALTH) get_lsb_short(bufpp);
114abb0f93cSkardel }
115abb0f93cSkardel
116abb0f93cSkardel void
get_mbg_cfg(unsigned char ** bufpp,CFG * cfgp)117abb0f93cSkardel get_mbg_cfg(
118abb0f93cSkardel unsigned char **bufpp,
119abb0f93cSkardel CFG *cfgp
120abb0f93cSkardel )
121abb0f93cSkardel {
1227476e6e4Schristos *cfgp = (CFG) get_lsb_short(bufpp);
123abb0f93cSkardel }
124abb0f93cSkardel
125abb0f93cSkardel void
get_mbg_tgps(unsigned char ** bufpp,T_GPS * tgpsp)126abb0f93cSkardel get_mbg_tgps(
127abb0f93cSkardel unsigned char **bufpp,
128abb0f93cSkardel T_GPS *tgpsp
129abb0f93cSkardel )
130abb0f93cSkardel {
1317476e6e4Schristos tgpsp->wn = get_lsb_uint16(bufpp);
132abb0f93cSkardel tgpsp->sec = get_lsb_long(bufpp);
133abb0f93cSkardel tgpsp->tick = get_lsb_long(bufpp);
134abb0f93cSkardel }
135abb0f93cSkardel
136abb0f93cSkardel void
get_mbg_tm(unsigned char ** buffpp,TM_GPS * tmp)137abb0f93cSkardel get_mbg_tm(
138abb0f93cSkardel unsigned char **buffpp,
1397476e6e4Schristos TM_GPS *tmp
140abb0f93cSkardel )
141abb0f93cSkardel {
1427476e6e4Schristos tmp->year = get_lsb_int16(buffpp);
143abb0f93cSkardel tmp->month = *(*buffpp)++;
144abb0f93cSkardel tmp->mday = *(*buffpp)++;
1457476e6e4Schristos tmp->yday = get_lsb_int16(buffpp);
146abb0f93cSkardel tmp->wday = *(*buffpp)++;
147abb0f93cSkardel tmp->hour = *(*buffpp)++;
1487476e6e4Schristos tmp->min = *(*buffpp)++;
1497476e6e4Schristos tmp->sec = *(*buffpp)++;
150abb0f93cSkardel tmp->frac = get_lsb_long(buffpp);
151abb0f93cSkardel tmp->offs_from_utc = get_lsb_long(buffpp);
1527476e6e4Schristos tmp->status = get_lsb_uint16(buffpp);
153abb0f93cSkardel }
154abb0f93cSkardel
155abb0f93cSkardel void
get_mbg_ttm(unsigned char ** buffpp,TTM * ttmp)156abb0f93cSkardel get_mbg_ttm(
157abb0f93cSkardel unsigned char **buffpp,
158abb0f93cSkardel TTM *ttmp
159abb0f93cSkardel )
160abb0f93cSkardel {
1617476e6e4Schristos ttmp->channel = get_lsb_int16(buffpp);
162abb0f93cSkardel get_mbg_tgps(buffpp, &ttmp->t);
163abb0f93cSkardel get_mbg_tm(buffpp, &ttmp->tm);
164abb0f93cSkardel }
165abb0f93cSkardel
166abb0f93cSkardel void
get_mbg_synth(unsigned char ** buffpp,SYNTH * synthp)167abb0f93cSkardel get_mbg_synth(
168abb0f93cSkardel unsigned char **buffpp,
169abb0f93cSkardel SYNTH *synthp
170abb0f93cSkardel )
171abb0f93cSkardel {
1727476e6e4Schristos synthp->freq = get_lsb_int16(buffpp);
1737476e6e4Schristos synthp->range = get_lsb_int16(buffpp);
1747476e6e4Schristos synthp->phase = get_lsb_int16(buffpp);
175abb0f93cSkardel }
176abb0f93cSkardel
177abb0f93cSkardel static void
get_mbg_tzname(unsigned char ** buffpp,char * tznamep)178abb0f93cSkardel get_mbg_tzname(
179abb0f93cSkardel unsigned char **buffpp,
180abb0f93cSkardel char *tznamep
181abb0f93cSkardel )
182abb0f93cSkardel {
1832950cc38Schristos strlcpy(tznamep, (char *)*buffpp, sizeof(TZ_NAME));
184abb0f93cSkardel *buffpp += sizeof(TZ_NAME);
185abb0f93cSkardel }
186abb0f93cSkardel
187abb0f93cSkardel void
get_mbg_tzdl(unsigned char ** buffpp,TZDL * tzdlp)188abb0f93cSkardel get_mbg_tzdl(
189abb0f93cSkardel unsigned char **buffpp,
190abb0f93cSkardel TZDL *tzdlp
191abb0f93cSkardel )
192abb0f93cSkardel {
193abb0f93cSkardel tzdlp->offs = get_lsb_long(buffpp);
194abb0f93cSkardel tzdlp->offs_dl = get_lsb_long(buffpp);
195abb0f93cSkardel get_mbg_tm(buffpp, &tzdlp->tm_on);
196abb0f93cSkardel get_mbg_tm(buffpp, &tzdlp->tm_off);
197abb0f93cSkardel get_mbg_tzname(buffpp, (char *)tzdlp->name[0]);
198abb0f93cSkardel get_mbg_tzname(buffpp, (char *)tzdlp->name[1]);
199abb0f93cSkardel }
200abb0f93cSkardel
201abb0f93cSkardel void
get_mbg_antinfo(unsigned char ** buffpp,ANT_INFO * antinfop)202abb0f93cSkardel get_mbg_antinfo(
203abb0f93cSkardel unsigned char **buffpp,
204abb0f93cSkardel ANT_INFO *antinfop
205abb0f93cSkardel )
206abb0f93cSkardel {
2077476e6e4Schristos antinfop->status = get_lsb_int16(buffpp);
208abb0f93cSkardel get_mbg_tm(buffpp, &antinfop->tm_disconn);
209abb0f93cSkardel get_mbg_tm(buffpp, &antinfop->tm_reconn);
210abb0f93cSkardel antinfop->delta_t = get_lsb_long(buffpp);
211abb0f93cSkardel }
212abb0f93cSkardel
213abb0f93cSkardel static void
mbg_time_status_str(char ** buffpp,unsigned int status,int size)214abb0f93cSkardel mbg_time_status_str(
215abb0f93cSkardel char **buffpp,
216abb0f93cSkardel unsigned int status,
217abb0f93cSkardel int size
218abb0f93cSkardel )
219abb0f93cSkardel {
220abb0f93cSkardel static struct state
221abb0f93cSkardel {
222abb0f93cSkardel int flag; /* bit flag */
223abb0f93cSkardel const char *string; /* bit name */
224abb0f93cSkardel } states[] =
225abb0f93cSkardel {
226abb0f93cSkardel { TM_UTC, "UTC CORR" },
227abb0f93cSkardel { TM_LOCAL, "LOCAL TIME" },
228abb0f93cSkardel { TM_DL_ANN, "DST WARN" },
229abb0f93cSkardel { TM_DL_ENB, "DST" },
230abb0f93cSkardel { TM_LS_ANN, "LEAP WARN" },
231abb0f93cSkardel { TM_LS_ENB, "LEAP SEC" },
232abb0f93cSkardel { 0, "" }
233abb0f93cSkardel };
234abb0f93cSkardel
235abb0f93cSkardel if (status)
236abb0f93cSkardel {
237abb0f93cSkardel char *start, *p;
238abb0f93cSkardel struct state *s;
239abb0f93cSkardel
240abb0f93cSkardel start = p = *buffpp;
241abb0f93cSkardel
242abb0f93cSkardel for (s = states; s->flag; s++)
243abb0f93cSkardel {
244abb0f93cSkardel if (s->flag & status)
245abb0f93cSkardel {
246abb0f93cSkardel if (p != *buffpp)
247abb0f93cSkardel {
2482950cc38Schristos strlcpy(p, ", ", size - (p - start));
249abb0f93cSkardel p += 2;
250abb0f93cSkardel }
2512950cc38Schristos strlcpy(p, s->string, size - (p - start));
252abb0f93cSkardel p += strlen(p);
253abb0f93cSkardel }
254abb0f93cSkardel }
255abb0f93cSkardel *buffpp = p;
256abb0f93cSkardel }
257abb0f93cSkardel }
258abb0f93cSkardel
259abb0f93cSkardel void
mbg_tm_str(char ** buffpp,TM_GPS * tmp,int size,int print_status)260abb0f93cSkardel mbg_tm_str(
261abb0f93cSkardel char **buffpp,
2627476e6e4Schristos TM_GPS *tmp,
2637476e6e4Schristos int size,
2647476e6e4Schristos int print_status
265abb0f93cSkardel )
266abb0f93cSkardel {
267abb0f93cSkardel char *s = *buffpp;
268abb0f93cSkardel
269abb0f93cSkardel snprintf(*buffpp, size, "%04d-%02d-%02d %02d:%02d:%02d.%07ld (%c%02d%02d) ",
270abb0f93cSkardel tmp->year, tmp->month, tmp->mday,
2717476e6e4Schristos tmp->hour, tmp->min, tmp->sec, (long) tmp->frac,
272abb0f93cSkardel (tmp->offs_from_utc < 0) ? '-' : '+',
273f8661471Sjoerg abs((int)tmp->offs_from_utc) / 3600,
274f8661471Sjoerg (abs((int)tmp->offs_from_utc) / 60) % 60);
275abb0f93cSkardel *buffpp += strlen(*buffpp);
276abb0f93cSkardel
2777476e6e4Schristos if (print_status)
278abb0f93cSkardel mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s));
279abb0f93cSkardel }
280abb0f93cSkardel
281abb0f93cSkardel void
mbg_tgps_str(char ** buffpp,T_GPS * tgpsp,int size)282abb0f93cSkardel mbg_tgps_str(
283abb0f93cSkardel char **buffpp,
284abb0f93cSkardel T_GPS *tgpsp,
285abb0f93cSkardel int size
286abb0f93cSkardel )
287abb0f93cSkardel {
288abb0f93cSkardel snprintf(*buffpp, size, "week %d + %ld days + %ld.%07ld sec",
2897476e6e4Schristos tgpsp->wn, (long) tgpsp->sec / SECSPERDAY,
2907476e6e4Schristos (long) tgpsp->sec % SECSPERDAY, (long) tgpsp->tick);
291abb0f93cSkardel *buffpp += strlen(*buffpp);
292abb0f93cSkardel }
293abb0f93cSkardel
294abb0f93cSkardel void
get_mbg_cfgh(unsigned char ** buffpp,CFGH * cfghp)295abb0f93cSkardel get_mbg_cfgh(
296abb0f93cSkardel unsigned char **buffpp,
297abb0f93cSkardel CFGH *cfghp
298abb0f93cSkardel )
299abb0f93cSkardel {
300abb0f93cSkardel int i;
301abb0f93cSkardel
3027476e6e4Schristos cfghp->csum = (CSUM) get_lsb_short(buffpp);
3037476e6e4Schristos cfghp->valid = get_lsb_int16(buffpp);
304abb0f93cSkardel get_mbg_tgps(buffpp, &cfghp->tot_51);
305abb0f93cSkardel get_mbg_tgps(buffpp, &cfghp->tot_63);
306abb0f93cSkardel get_mbg_tgps(buffpp, &cfghp->t0a);
307abb0f93cSkardel
3087476e6e4Schristos for (i = 0; i < N_SVNO_GPS; i++)
309abb0f93cSkardel {
310abb0f93cSkardel get_mbg_cfg(buffpp, &cfghp->cfg[i]);
311abb0f93cSkardel }
312abb0f93cSkardel
3137476e6e4Schristos for (i = 0; i < N_SVNO_GPS; i++)
314abb0f93cSkardel {
315abb0f93cSkardel get_mbg_health(buffpp, &cfghp->health[i]);
316abb0f93cSkardel }
317abb0f93cSkardel }
318abb0f93cSkardel
319abb0f93cSkardel void
get_mbg_utc(unsigned char ** buffpp,UTC * utcp)320abb0f93cSkardel get_mbg_utc(
321abb0f93cSkardel unsigned char **buffpp,
322abb0f93cSkardel UTC *utcp
323abb0f93cSkardel )
324abb0f93cSkardel {
3257476e6e4Schristos utcp->csum = (CSUM) get_lsb_short(buffpp);
3267476e6e4Schristos utcp->valid = get_lsb_int16(buffpp);
327abb0f93cSkardel
328abb0f93cSkardel get_mbg_tgps(buffpp, &utcp->t0t);
329abb0f93cSkardel
330abb0f93cSkardel if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A0, mbg_double) != IEEE_OK)
331abb0f93cSkardel {
332abb0f93cSkardel L_CLR(&utcp->A0);
333abb0f93cSkardel }
334abb0f93cSkardel
335abb0f93cSkardel if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A1, mbg_double) != IEEE_OK)
336abb0f93cSkardel {
337abb0f93cSkardel L_CLR(&utcp->A1);
338abb0f93cSkardel }
339abb0f93cSkardel
3407476e6e4Schristos utcp->WNlsf = get_lsb_uint16(buffpp);
3417476e6e4Schristos utcp->DNt = get_lsb_int16(buffpp);
342abb0f93cSkardel utcp->delta_tls = *(*buffpp)++;
343abb0f93cSkardel utcp->delta_tlsf = *(*buffpp)++;
344abb0f93cSkardel }
345abb0f93cSkardel
346abb0f93cSkardel void
get_mbg_lla(unsigned char ** buffpp,LLA lla)347abb0f93cSkardel get_mbg_lla(
348abb0f93cSkardel unsigned char **buffpp,
349abb0f93cSkardel LLA lla
350abb0f93cSkardel )
351abb0f93cSkardel {
352abb0f93cSkardel int i;
353abb0f93cSkardel
354abb0f93cSkardel for (i = LAT; i <= ALT; i++)
355abb0f93cSkardel {
356abb0f93cSkardel if (fetch_ieee754(buffpp, IEEE_DOUBLE, &lla[i], mbg_double) != IEEE_OK)
357abb0f93cSkardel {
358abb0f93cSkardel L_CLR(&lla[i]);
359abb0f93cSkardel }
360abb0f93cSkardel else
361abb0f93cSkardel if (i != ALT)
362abb0f93cSkardel { /* convert to degrees (* 180/PI) */
363abb0f93cSkardel mfp_mul(&lla[i].l_i, &lla[i].l_uf, lla[i].l_i, lla[i].l_uf, rad2deg_i, rad2deg_f);
364abb0f93cSkardel }
365abb0f93cSkardel }
366abb0f93cSkardel }
367abb0f93cSkardel
368abb0f93cSkardel void
get_mbg_xyz(unsigned char ** buffpp,XYZ xyz)369abb0f93cSkardel get_mbg_xyz(
370abb0f93cSkardel unsigned char **buffpp,
371abb0f93cSkardel XYZ xyz
372abb0f93cSkardel )
373abb0f93cSkardel {
374abb0f93cSkardel int i;
375abb0f93cSkardel
376abb0f93cSkardel for (i = XP; i <= ZP; i++)
377abb0f93cSkardel {
378abb0f93cSkardel if (fetch_ieee754(buffpp, IEEE_DOUBLE, &xyz[i], mbg_double) != IEEE_OK)
379abb0f93cSkardel {
380abb0f93cSkardel L_CLR(&xyz[i]);
381abb0f93cSkardel }
382abb0f93cSkardel }
383abb0f93cSkardel }
384abb0f93cSkardel
385abb0f93cSkardel static void
get_mbg_comparam(unsigned char ** buffpp,COM_PARM * comparamp)386abb0f93cSkardel get_mbg_comparam(
387abb0f93cSkardel unsigned char **buffpp,
388abb0f93cSkardel COM_PARM *comparamp
389abb0f93cSkardel )
390abb0f93cSkardel {
391e19314b7Schristos size_t i;
392abb0f93cSkardel
393abb0f93cSkardel comparamp->baud_rate = get_lsb_long(buffpp);
394abb0f93cSkardel for (i = 0; i < sizeof(comparamp->framing); i++)
395abb0f93cSkardel {
396abb0f93cSkardel comparamp->framing[i] = *(*buffpp)++;
397abb0f93cSkardel }
3987476e6e4Schristos comparamp->handshake = get_lsb_int16(buffpp);
399abb0f93cSkardel }
400abb0f93cSkardel
401abb0f93cSkardel void
get_mbg_portparam(unsigned char ** buffpp,PORT_PARM * portparamp)402abb0f93cSkardel get_mbg_portparam(
403abb0f93cSkardel unsigned char **buffpp,
404abb0f93cSkardel PORT_PARM *portparamp
405abb0f93cSkardel )
406abb0f93cSkardel {
407abb0f93cSkardel int i;
408abb0f93cSkardel
4097476e6e4Schristos for (i = 0; i < DEFAULT_N_COM; i++)
410abb0f93cSkardel {
411abb0f93cSkardel get_mbg_comparam(buffpp, &portparamp->com[i]);
412abb0f93cSkardel }
4137476e6e4Schristos for (i = 0; i < DEFAULT_N_COM; i++)
414abb0f93cSkardel {
415abb0f93cSkardel portparamp->mode[i] = *(*buffpp)++;
416abb0f93cSkardel }
417abb0f93cSkardel }
418abb0f93cSkardel
419abb0f93cSkardel #define FETCH_DOUBLE(src, addr) \
420abb0f93cSkardel if (fetch_ieee754(src, IEEE_DOUBLE, addr, mbg_double) != IEEE_OK) \
421abb0f93cSkardel { \
422abb0f93cSkardel L_CLR(addr); \
423abb0f93cSkardel }
424abb0f93cSkardel
425abb0f93cSkardel void
get_mbg_eph(unsigned char ** buffpp,EPH * ephp)426abb0f93cSkardel get_mbg_eph(
427abb0f93cSkardel unsigned char ** buffpp,
428abb0f93cSkardel EPH *ephp
429abb0f93cSkardel )
430abb0f93cSkardel {
4317476e6e4Schristos ephp->csum = (CSUM) get_lsb_short(buffpp);
4327476e6e4Schristos ephp->valid = get_lsb_int16(buffpp);
433abb0f93cSkardel
4347476e6e4Schristos ephp->health = (HEALTH) get_lsb_short(buffpp);
4357476e6e4Schristos ephp->IODC = (IOD) get_lsb_short(buffpp);
4367476e6e4Schristos ephp->IODE2 = (IOD) get_lsb_short(buffpp);
4377476e6e4Schristos ephp->IODE3 = (IOD) get_lsb_short(buffpp);
438abb0f93cSkardel
439abb0f93cSkardel get_mbg_tgps(buffpp, &ephp->tt);
440abb0f93cSkardel get_mbg_tgps(buffpp, &ephp->t0c);
441abb0f93cSkardel get_mbg_tgps(buffpp, &ephp->t0e);
442abb0f93cSkardel
443abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->sqrt_A);
444abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->e);
445abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->M0);
446abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->omega);
447abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->OMEGA0);
448abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->OMEGADOT);
449abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->deltan);
450abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->i0);
451abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->idot);
452abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->crc);
453abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->crs);
454abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->cuc);
455abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->cus);
456abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->cic);
457abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->cis);
458abb0f93cSkardel
459abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->af0);
460abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->af1);
461abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->af2);
462abb0f93cSkardel FETCH_DOUBLE(buffpp, &ephp->tgd);
463abb0f93cSkardel
4647476e6e4Schristos ephp->URA = get_lsb_uint16(buffpp);
465abb0f93cSkardel
466abb0f93cSkardel ephp->L2code = *(*buffpp)++;
467abb0f93cSkardel ephp->L2flag = *(*buffpp)++;
468abb0f93cSkardel }
469abb0f93cSkardel
470abb0f93cSkardel void
get_mbg_alm(unsigned char ** buffpp,ALM * almp)471abb0f93cSkardel get_mbg_alm(
472abb0f93cSkardel unsigned char **buffpp,
473abb0f93cSkardel ALM *almp
474abb0f93cSkardel )
475abb0f93cSkardel {
4767476e6e4Schristos almp->csum = (CSUM) get_lsb_short(buffpp);
4777476e6e4Schristos almp->valid = get_lsb_int16(buffpp);
478abb0f93cSkardel
4797476e6e4Schristos almp->health = (HEALTH) get_lsb_short(buffpp);
480abb0f93cSkardel get_mbg_tgps(buffpp, &almp->t0a);
481abb0f93cSkardel
482abb0f93cSkardel
483abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->sqrt_A);
484abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->e);
485abb0f93cSkardel
486abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->M0);
487abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->omega);
488abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->OMEGA0);
489abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->OMEGADOT);
490abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->deltai);
491abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->af0);
492abb0f93cSkardel FETCH_DOUBLE(buffpp, &almp->af1);
493abb0f93cSkardel }
494abb0f93cSkardel
495abb0f93cSkardel void
get_mbg_iono(unsigned char ** buffpp,IONO * ionop)496abb0f93cSkardel get_mbg_iono(
497abb0f93cSkardel unsigned char **buffpp,
498abb0f93cSkardel IONO *ionop
499abb0f93cSkardel )
500abb0f93cSkardel {
5017476e6e4Schristos ionop->csum = (CSUM) get_lsb_short(buffpp);
5027476e6e4Schristos ionop->valid = get_lsb_int16(buffpp);
503abb0f93cSkardel
504abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->alpha_0);
505abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->alpha_1);
506abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->alpha_2);
507abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->alpha_3);
508abb0f93cSkardel
509abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->beta_0);
510abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->beta_1);
511abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->beta_2);
512abb0f93cSkardel FETCH_DOUBLE(buffpp, &ionop->beta_3);
513abb0f93cSkardel }
514abb0f93cSkardel
515abb0f93cSkardel /*
516abb0f93cSkardel * data_mbg.c,v
517abb0f93cSkardel * Revision 4.8 2006/06/22 18:40:01 kardel
518abb0f93cSkardel * clean up signedness (gcc 4)
519abb0f93cSkardel *
520abb0f93cSkardel * Revision 4.7 2005/10/07 22:11:10 kardel
521abb0f93cSkardel * bounded buffer implementation
522abb0f93cSkardel *
523abb0f93cSkardel * Revision 4.6.2.1 2005/09/25 10:23:06 kardel
524abb0f93cSkardel * support bounded buffers
525abb0f93cSkardel *
526abb0f93cSkardel * Revision 4.6 2005/04/16 17:32:10 kardel
527abb0f93cSkardel * update copyright
528abb0f93cSkardel *
529abb0f93cSkardel * Revision 4.5 2004/11/14 15:29:41 kardel
530abb0f93cSkardel * support PPSAPI, upgrade Copyright to Berkeley style
531abb0f93cSkardel *
532abb0f93cSkardel * Revision 4.3 1999/02/21 12:17:42 kardel
533abb0f93cSkardel * 4.91f reconcilation
534abb0f93cSkardel *
535abb0f93cSkardel * Revision 4.2 1998/06/14 21:09:39 kardel
536abb0f93cSkardel * Sun acc cleanup
537abb0f93cSkardel *
538abb0f93cSkardel * Revision 4.1 1998/05/24 08:02:06 kardel
539abb0f93cSkardel * trimmed version log
540abb0f93cSkardel *
541abb0f93cSkardel * Revision 4.0 1998/04/10 19:45:33 kardel
542abb0f93cSkardel * Start 4.0 release version numbering
543abb0f93cSkardel */
544abb0f93cSkardel
545