154359Sroberto/* 2182007Sroberto * /src/NTP/REPOSITORY/ntp4-dev/include/mbg_gps166.h,v 4.7 2006/06/22 18:41:43 kardel RELEASE_20060622_A 354359Sroberto * 4182007Sroberto * mbg_gps166.h,v 4.7 2006/06/22 18:41:43 kardel RELEASE_20060622_A 5182007Sroberto * 654359Sroberto * $Created: Sun Jul 20 09:20:50 1997 $ 754359Sroberto * 8182007Sroberto * File GPSSERIO.H Copyright (c) by Meinberg Funkuhren (www.meinberg.de) 9182007Sroberto * 10182007Sroberto * Linkage to PARSE: 11182007Sroberto * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org> 12182007Sroberto * 13182007Sroberto * Redistribution and use in source and binary forms, with or without 14182007Sroberto * modification, are permitted provided that the following conditions 15182007Sroberto * are met: 16182007Sroberto * 1. Redistributions of source code must retain the above copyright 17182007Sroberto * notice, this list of conditions and the following disclaimer. 18182007Sroberto * 2. Redistributions in binary form must reproduce the above copyright 19182007Sroberto * notice, this list of conditions and the following disclaimer in the 20182007Sroberto * documentation and/or other materials provided with the distribution. 21182007Sroberto * 3. Neither the name of the author nor the names of its contributors 22182007Sroberto * may be used to endorse or promote products derived from this software 23182007Sroberto * without specific prior written permission. 24182007Sroberto * 25182007Sroberto * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 26182007Sroberto * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27182007Sroberto * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28182007Sroberto * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 29182007Sroberto * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30182007Sroberto * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31182007Sroberto * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32182007Sroberto * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33182007Sroberto * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34182007Sroberto * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35182007Sroberto * SUCH DAMAGE. 36182007Sroberto * 3754359Sroberto */ 3854359Sroberto#ifndef MBG_GPS166_H 3954359Sroberto#define MBG_GPS166_H 4054359Sroberto 4154359Sroberto 4254359Sroberto/***************************************************************************/ 4354359Sroberto/* */ 44182007Sroberto/* File: GPSSERIO.H 4.1 */ 4554359Sroberto/* */ 4654359Sroberto/* Project: Common C Library */ 4754359Sroberto/* */ 4854359Sroberto/* Compiler: Borland C++ */ 4954359Sroberto/* */ 5054359Sroberto/* Author: M. Burnicki, Meinberg Funkuhren */ 5154359Sroberto/* */ 5254359Sroberto/* */ 5354359Sroberto/* Description: */ 5454359Sroberto/* This file defines structures and codes to be used to access GPS166 */ 5554359Sroberto/* via its serial interface COM0. COM0 should be set to a high baud */ 5654359Sroberto/* rate, default is 19200. */ 5754359Sroberto/* */ 5854359Sroberto/* Standard GPS166 serial operation is to send a time string that is */ 5954359Sroberto/* compatible with Meinberg UA31 or PZF535 DCF77 radio remote clocks. */ 6054359Sroberto/* That string can be transmitted automatically once per second, once */ 6154359Sroberto/* per minute or on request per ASCII '?'. */ 6254359Sroberto/* */ 6354359Sroberto/* Parameter setup or parameter readout works using blocks of binary */ 6454359Sroberto/* data which have to be isolated from the standard string. A block of */ 6554359Sroberto/* data starts with a SOH code (ASCII Start Of Header, 0x01) followed */ 6654359Sroberto/* by a message header with constant length and a data portion with */ 6754359Sroberto/* variable length. The first field (cmd) of the message header holds */ 6854359Sroberto/* the command code rsp. the type of data to be transmitted. The next */ 6954359Sroberto/* field (len) gives the number of data bytes that are transmitted */ 7054359Sroberto/* after the header. This number ranges from 0 to sizeof( MSG_DATA ). */ 7154359Sroberto/* The third field (data_csum) holds a checksum of all data bytes and */ 7254359Sroberto/* the last field of the header finally holds the checksum of the. */ 7354359Sroberto/* header. */ 7454359Sroberto/* */ 7554359Sroberto/***************************************************************************/ 7654359Sroberto 7754359Sroberto/* the control codes defined below are to be or'ed with a command/type code */ 7854359Sroberto 7954359Sroberto#define GPS_REQACK 0x8000 /* to GPS166: request acknowledge */ 8054359Sroberto#define GPS_ACK 0x4000 /* from GPS166: acknowledge a command */ 8154359Sroberto#define GPS_NACK 0x2000 /* from GPS166: error receiving command */ 8254359Sroberto 8354359Sroberto#define GPS_CTRL_MSK 0xF000 /* masks control code from command */ 8454359Sroberto 8554359Sroberto 8654359Sroberto/* The codes below specify commands/types of data to be supplied to GPS166: */ 8754359Sroberto 8854359Sroberto/* GPS166 auto-message to host */ 8954359Sroberto/* � host request, GPS166 response */ 9054359Sroberto/* � � host download to GPS166 */ 9154359Sroberto/* � � � */ 9254359Srobertoenum { /* � � � */ 9354359Sroberto /* system data */ 9454359Sroberto GPS_AUTO_ON = 0x000, /* � � � X � enable auto-messages from GPS166 */ 9554359Sroberto GPS_AUTO_OFF, /* � � � X � disable auto-messages from GPS166 */ 9654359Sroberto GPS_SW_REV, /* � � X � � request software revision */ 9754359Sroberto GPS_STAT, /* � � X � � request status of buffered variables */ 9854359Sroberto GPS_TIME, /* � X � � X � current time or capture or init board time */ 9954359Sroberto GPS_POS_XYZ, /* � � X � X � current position in ECEF coords */ 10054359Sroberto GPS_POS_LLA, /* � � X � X � current position in geographic coords */ 10154359Sroberto GPS_TZDL, /* � � X � X � time zone / daylight saving */ 10254359Sroberto GPS_PORT_PARM, /* � � X � X � parameters of the serial ports */ 10354359Sroberto GPS_SYNTH, /* � � X � X � synthesizer's frequency and phase */ 10454359Sroberto GPS_ANT_INFO, /* � X � X � � time diff after antenna disconnect */ 10554359Sroberto GPS_UCAP, /* � X � X � � user capture */ 10654359Sroberto 10754359Sroberto /* GPS data */ 10854359Sroberto GPS_CFGH = 0x100, /* � � X � X � SVs' configuration and health codes */ 10954359Sroberto GPS_ALM, /* � � X � X � one SV's almanac */ 11054359Sroberto GPS_EPH, /* � � X � X � one SV's ephemeris */ 11154359Sroberto GPS_UTC, /* � � X � X � UTC correction parameters */ 11254359Sroberto GPS_IONO, /* � � X � X � ionospheric correction parameters */ 11354359Sroberto GPS_ASCII_MSG /* � � X � � the GPS ASCII message */ 11454359Sroberto}; 11554359Sroberto 11654359Sroberto/* 11754359Sroberto * modelled after GPSDEFS.H Revision 1.5 11854359Sroberto */ 11954359Sroberto/***************************************************************************/ 12054359Sroberto/* */ 12154359Sroberto/* File: GPSDEFS.H 4.1 */ 12254359Sroberto/* */ 12354359Sroberto/* Project: Common C Library */ 12454359Sroberto/* */ 12554359Sroberto/* Compiler: Borland C++ */ 12654359Sroberto/* */ 12754359Sroberto/* Author: M. Burnicki, Meinberg Funkuhren */ 12854359Sroberto/* */ 12954359Sroberto/* */ 13054359Sroberto/* Description: */ 13154359Sroberto/* General definitions to be used with GPS166 */ 13254359Sroberto/* GPS166 Rev. 1.23 or above */ 13354359Sroberto/* */ 13454359Sroberto/* Modifications: see file GPSLIB.TXT */ 13554359Sroberto/* */ 13654359Sroberto/***************************************************************************/ 13754359Sroberto#define _GPSDEFS_H 13854359Sroberto/* the type of various checksums */ 13954359Sroberto 14054359Sroberto#ifndef _CSUM_DEFINED 14154359Sroberto typedef unsigned short CSUM; 14254359Sroberto# define _CSUM_DEFINED 14354359Sroberto#endif 14454359Sroberto 14554359Sroberto/* the message header */ 14654359Sroberto 14754359Srobertotypedef struct { 14854359Sroberto unsigned short gps_cmd; 14954359Sroberto unsigned short gps_len; 15054359Sroberto unsigned short gps_data_csum; 15154359Sroberto unsigned short gps_hdr_csum; 15254359Sroberto} GPS_MSG_HDR; 15354359Sroberto 15454359Sroberto/* a struct used to hold the software revision information */ 15554359Sroberto 15654359Srobertotypedef struct { 15754359Sroberto unsigned short code; /* e.g. 0x0120 means rev. 1.20 */ 15854359Sroberto unsigned char name[17]; /* used to identify customized versions */ 15954359Sroberto} SW_REV; 16054359Sroberto 16154359Sroberto/* GPS ASCII message */ 16254359Sroberto 16354359Srobertotypedef struct { 16454359Sroberto CSUM csum; /* checksum of the remaining bytes */ 16554359Sroberto short valid; /* flag data are valid */ 16654359Sroberto char s[23]; /* 22 chars GPS ASCII message plus trailing zero */ 16754359Sroberto} ASCII_MSG; 16854359Sroberto 16954359Sroberto#define MIN_SVNO 1 /* min. SV number */ 17054359Sroberto#define MAX_SVNO 32 /* max. SV number */ 17154359Sroberto#define N_SVNO ( MAX_SVNO - MIN_SVNO + 1) /* number of possibly active SVs */ 17254359Sroberto 17354359Sroberto 17454359Srobertotypedef short SVNO; /* the number of a SV */ 17554359Srobertotypedef unsigned short HEALTH; /* a SV's health code */ 17654359Srobertotypedef unsigned short CFG; /* a SV's configuration code */ 17754359Srobertotypedef unsigned short IOD; /* Issue-Of-Data code */ 17854359Sroberto 17954359Sroberto/* Date and time referred to the linear time scale defined by GPS. */ 18054359Sroberto/* GPS time is defined by the number of weeks since midnight from */ 18154359Sroberto/* January 5, 1980 to January 6, 1980 plus the number of seconds of */ 18254359Sroberto/* the current week plus fractions of a second. GPS time differs from */ 18354359Sroberto/* UTC because UTC is corrected with leap seconds while GPS time scale */ 18454359Sroberto/* is continuous. */ 18554359Sroberto 18654359Srobertotypedef struct { 18754359Sroberto unsigned short wn; /* the week number since GPS has been installed */ 18854359Sroberto unsigned long sec; /* the second of that week */ 18954359Sroberto unsigned long tick; /* fractions of a second; scale: 1E-7 */ 19054359Sroberto} T_GPS; 19154359Sroberto 19254359Sroberto 19354359Sroberto/* Local date and time computed from GPS time. The current number */ 19454359Sroberto/* of leap seconds have to be added to get UTC from GPS time. */ 19554359Sroberto/* Additional corrections could have been made according to the */ 19654359Sroberto/* time zone/daylight saving parameters (TZDL, see below) defined */ 19754359Sroberto/* by the user. The status field can be checked to see which corrections */ 19854359Sroberto/* have been applied. */ 19954359Sroberto 20054359Sroberto#ifndef _TM_DEFINED 20154359Sroberto typedef struct { 20254359Sroberto short year; /* 0..9999 */ 20354359Sroberto char month; /* 1..12 */ 20454359Sroberto char mday; /* 1..31 */ 20554359Sroberto short yday; /* 1..366 */ 20654359Sroberto char wday; /* 0..6 == Sun..Sat */ 20754359Sroberto char hour; /* 0..23 */ 20854359Sroberto char minute; /* 0..59 */ 20954359Sroberto char second; /* 0..59 */ 21054359Sroberto long frac; /* fractions of a second, scale 1E-7 */ 21154359Sroberto long offs_from_utc; /* local time's offset from UTC */ 21254359Sroberto unsigned short status; /* flags */ 21354359Sroberto } TM; 21454359Sroberto 21554359Sroberto /* status flags used with conversion from GPS time to local time */ 21654359Sroberto 21754359Sroberto# define TM_UTC 0x01 /* UTC correction has been made */ 21854359Sroberto# define TM_LOCAL 0x02 /* UTC has been converted to local time */ 21954359Sroberto# define TM_DL_ANN 0x04 /* state of daylight saving is going to change */ 22054359Sroberto# define TM_DL_ENB 0x08 /* daylight saving is enabled */ 22154359Sroberto# define TM_LS_ANN 0x10 /* leap second will be inserted */ 22254359Sroberto# define TM_LS_ENB 0x20 /* current second is leap second */ 22354359Sroberto 22454359Sroberto# define _TM_DEFINED 22554359Sroberto#endif 22654359Sroberto 22754359Sroberto 22854359Sroberto/* the status flags below are defined starting with rev. 1.32 */ 22954359Sroberto 23054359Sroberto#define TM_ANT_DISCONN 0x1000 /* antenna currently disconnected */ 23154359Sroberto#define TM_SYN_FLAG 0x2000 /* TIME_SYN output is low */ 23254359Sroberto#define TM_NO_SYNC 0x4000 /* not sync'ed after reset */ 23354359Sroberto#define TM_NO_POS 0x8000 /* position not computed after reset, */ 23454359Sroberto /* LOCK LED off */ 23554359Sroberto 23654359Sroberto/* a struct used to transmit information on date and time */ 23754359Sroberto 23854359Srobertotypedef struct { 23954359Sroberto short channel; /* -1: the current time; 0, 1: capture 0, 1 */ 24054359Sroberto T_GPS t; /* time in GPS format */ 24154359Sroberto TM tm; /* that time converted to local time */ 24254359Sroberto} TTM; 24354359Sroberto 24454359Sroberto 24554359Sroberto 24654359Sroberto/* Two types of variables used to store a position. Type XYZ is */ 24754359Sroberto/* used with a position in earth centered, earth fixed (ECEF) */ 24854359Sroberto/* coordinates whereas type LLA holds such a position converted */ 24954359Sroberto/* to geographic coordinates as defined by WGS84 (World Geodetic */ 25054359Sroberto/* System from 1984). */ 25154359Sroberto 25254359Sroberto#ifndef _XYZ_DEFINED 25354359Sroberto /* sequence and number of components of a cartesian position */ 25454359Sroberto enum { XP, YP, ZP, N_XYZ }; 25554359Sroberto 25654359Sroberto /* a type of array holding a cartesian position */ 25754359Sroberto typedef l_fp XYZ[N_XYZ]; /* values are in [m] */ 25854359Sroberto 25954359Sroberto# define _XYZ_DEFINED 26054359Sroberto#endif 26154359Sroberto 26254359Sroberto 26354359Sroberto#ifndef _LLA_DEFINED 26454359Sroberto /* sequence and number of components of a geographic position */ 26554359Sroberto enum { LAT, LON, ALT, N_LLA }; /* latitude, longitude, altitude */ 26654359Sroberto 26754359Sroberto /* a type of array holding a geographic position */ 26854359Sroberto typedef l_fp LLA[N_LLA]; /* lon, lat in [rad], alt in [m] */ 26954359Sroberto 27054359Sroberto# define _LLA_DEFINED 27154359Sroberto#endif 27254359Sroberto 27354359Sroberto/* Synthesizer parameters. Synthesizer frequency is expressed as a */ 27454359Sroberto/* four digit decimal number (freq) to be multiplied by 0.1 Hz and an */ 27554359Sroberto/* base 10 exponent (range). If the effective frequency is less than */ 27654359Sroberto/* 10 kHz its phase is synchronized corresponding to the variable phase. */ 27754359Sroberto/* Phase may be in a range from -360� to +360� with a resolution of 0.1�, */ 27854359Sroberto/* so the resulting numbers to be stored are in a range of -3600 to +3600. */ 27954359Sroberto 28054359Sroberto/* Example: */ 28154359Sroberto/* Assume the value of freq is 2345 (decimal) and the value of phase is 900. */ 28254359Sroberto/* If range == 0 the effective frequency is 234.5 Hz with a phase of +90�. */ 28354359Sroberto/* If range == 1 the synthesizer will generate a 2345 Hz output frequency */ 28454359Sroberto/* and so on. */ 28554359Sroberto 28654359Sroberto/* Limitations: */ 28754359Sroberto/* If freq == 0 the synthesizer is disabled. If range == 0 the least */ 28854359Sroberto/* significant digit of freq is limited to 0, 3, 5 or 6. The resulting */ 28954359Sroberto/* frequency is shown in the examples below: */ 29054359Sroberto/* freq == 1230 --> 123.0 Hz */ 29154359Sroberto/* freq == 1233 --> 123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz) */ 29254359Sroberto/* freq == 1235 --> 123.5 Hz */ 29354359Sroberto/* freq == 1236 --> 123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz) */ 29454359Sroberto 29554359Sroberto/* If range == MAX_RANGE the value of freq must not exceed 1200, so the */ 29654359Sroberto/* output frequency is limited to 12 MHz. */ 29754359Sroberto 29854359Sroberto/* Phase will be ignored if the resulting frequency is greater or equal */ 29954359Sroberto/* to 10 kHz. */ 30054359Sroberto 30154359Sroberto#define MAX_SYNTH_FREQ 1200 /* if range == MAX_SYNTH_RANGE */ 30254359Sroberto#define MIN_SYNTH_RANGE 0 30354359Sroberto#define MAX_SYNTH_RANGE 5 30454359Sroberto#define MAX_SYNTH_PHASE 3600 30554359Sroberto 30654359Srobertotypedef struct { 30754359Sroberto short freq; /* four digits used; scale: 0.1; e.g. 1234 -> 123.4 Hz */ 30854359Sroberto short range; /* scale factor for freq; 0..MAX_SYNTH_RANGE */ 30954359Sroberto short phase; /* -MAX_SYNTH_PHASE..+MAX_SYNTH_PHASE; >0 -> pulses later */ 31054359Sroberto} SYNTH; 31154359Sroberto 31254359Sroberto 31354359Sroberto 31454359Sroberto/* Time zone/daylight saving parameters. */ 31554359Sroberto 31654359Sroberto/* the name of a time zone, 5 characters plus trailing zero */ 31754359Srobertotypedef char TZ_NAME[6]; 31854359Sroberto 31954359Srobertotypedef struct { 32054359Sroberto long offs; /* offset from UTC to local time [sec] */ 32154359Sroberto long offs_dl; /* additional offset if daylight saving enabled [sec] */ 32254359Sroberto TM tm_on; /* date/time when daylight saving starts */ 32354359Sroberto TM tm_off; /* date/time when daylight saving ends */ 32454359Sroberto TZ_NAME name[2]; /* names without and with daylight saving enabled */ 32554359Sroberto} TZDL; 32654359Sroberto 32754359Sroberto/* The constant below is defined beginning with software rev. 1.29. */ 32854359Sroberto/* If the year in tzdl.tmon and tzdl.tm_off is or'ed with that constant, */ 32954359Sroberto/* the receiver automatically generates daylight saving year by year. */ 33054359Sroberto/* See GPSLIB.TXT for more information. */ 33154359Sroberto 33254359Sroberto#define DL_AUTO_FLAG 0x8000 33354359Sroberto 33454359Sroberto/* Example: */ 33554359Sroberto/* for automatic daylight saving enable/disable in Central Europe, */ 33654359Sroberto/* the variables are to be set as shown below: */ 33754359Sroberto/* offs = 3600L one hour from UTC */ 33854359Sroberto/* offs_dl = 3600L one additional hour if daylight saving enabled */ 33954359Sroberto/* tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG ) */ 34054359Sroberto/* tm_off = first Sunday from Sept 24, 03:00:00h ( year |= DL_AUTO_FLAG ) */ 34154359Sroberto/* name[0] == "MEZ " name if daylight saving not enabled */ 34254359Sroberto/* name[1] == "MESZ " name if daylight saving is enabled */ 34354359Sroberto 34454359Sroberto 34554359Sroberto 34654359Sroberto 34754359Sroberto/* the structure below was defined in rev. 1.31. It reflects the status */ 34854359Sroberto/* of the antenna, the times of last disconnect/reconnect and the boards */ 34954359Sroberto/* clock offset after the phase of disconnection. */ 35054359Sroberto 35154359Srobertotypedef struct { 35254359Sroberto short status; /* current status of antenna */ 35354359Sroberto TM tm_disconn; /* time of antenna disconnect */ 35454359Sroberto TM tm_reconn; /* time of antenna reconnect */ 35554359Sroberto long delta_t; /* clock offset at reconnect time, units: TICKS_PER_SEC */ 35654359Sroberto} ANT_INFO; 35754359Sroberto 35854359Sroberto 35954359Sroberto/* the status field may be set to one of the values below: */ 36054359Sroberto 36154359Srobertoenum { 36254359Sroberto ANT_INVALID, /* struct not set yet because ant. has not been disconn. */ 36354359Sroberto ANT_DISCONN, /* ant. now disconn., tm_reconn and delta_t not set */ 36454359Sroberto ANT_RECONN /* ant. has been disconn. and reconn., all fields valid */ 36554359Sroberto}; 36654359Sroberto 36754359Sroberto 36854359Sroberto/* Summary of configuration and health data of all SVs. */ 36954359Sroberto 37054359Srobertotypedef struct { 37154359Sroberto CSUM csum; /* checksum of the remaining bytes */ 37254359Sroberto short valid; /* flag data are valid */ 37354359Sroberto 37454359Sroberto T_GPS tot_51; /* time of transmission, page 51 */ 37554359Sroberto T_GPS tot_63; /* time of transmission, page 63 */ 37654359Sroberto T_GPS t0a; /* complete reference time almanac */ 37754359Sroberto 37854359Sroberto CFG cfg[N_SVNO]; /* SV configuration from page 63 */ 37954359Sroberto HEALTH health[N_SVNO]; /* SV health from pages 51, 63 */ 38054359Sroberto} CFGH; 38154359Sroberto 38254359Sroberto 38354359Sroberto 38454359Sroberto/* UTC correction parameters */ 38554359Sroberto 38654359Srobertotypedef struct { 38754359Sroberto CSUM csum; /* checksum of the remaining bytes */ 38854359Sroberto short valid; /* flag data are valid */ 38954359Sroberto 39054359Sroberto T_GPS t0t; /* Reference Time UTC Parameters [sec] */ 39154359Sroberto l_fp A0; /* � Clock Correction Coefficient 0 [sec] */ 39254359Sroberto l_fp A1; /* � Clock Correction Coefficient 1 [sec/sec] */ 39354359Sroberto 39454359Sroberto ushort WNlsf; /* week number of nearest leap second */ 39554359Sroberto short DNt; /* the day number at the end of which LS is inserted */ 39654359Sroberto char delta_tls; /* */ 39754359Sroberto char delta_tlsf; /* */ 39854359Sroberto 39954359Sroberto} UTC; 40054359Sroberto 40154359Sroberto/* a struct used to hold the settings of a serial port */ 40254359Sroberto 40354359Sroberto#ifndef _COM_PARM_DEFINED 40454359Sroberto typedef long BAUD_RATE; 40554359Sroberto 40654359Sroberto /* indices used to identify a parameter in the framing string */ 40754359Sroberto enum { F_DBITS, F_PRTY, F_STBITS }; 40854359Sroberto 40954359Sroberto /* types of handshake */ 41054359Sroberto enum { HS_NONE, HS_XONXOFF, HS_RTSCTS }; 41154359Sroberto 41254359Sroberto typedef struct { 41354359Sroberto BAUD_RATE baud_rate; /* e.g. 19200L */ 41454359Sroberto char framing[4]; /* e.g. "8N1" */ 41554359Sroberto short handshake; /* a numeric value, only HS_NONE supported yet */ 41654359Sroberto } COM_PARM; 41754359Sroberto 41854359Sroberto#define _COM_PARM_DEFINED 41954359Sroberto#endif 42054359Sroberto 42154359Sroberto 42254359Sroberto 42354359Sroberto/* the codes below define what has to comes out of the serial ports */ 42454359Sroberto 42554359Srobertoenum { STR_ON_REQ, STR_PER_SEC, 42654359Sroberto STR_PER_MIN, N_STR_MODE_0, /* COM0 and COM1 */ 42754359Sroberto STR_UCAP = N_STR_MODE_0, 42854359Sroberto STR_UCAP_REQ, N_STR_MODE_1 /* COM1 only */ 42954359Sroberto }; 43054359Sroberto 43154359Sroberto 43254359Sroberto#define N_COM 2 /* the number of serial ports */ 43354359Sroberto 43454359Sroberto/* the structure used to store the modes of both serial ports */ 43554359Sroberto 43654359Srobertotypedef struct { 43754359Sroberto COM_PARM com[N_COM]; /* COM0 and COM1 settings */ 43854359Sroberto u_char mode[N_COM]; /* COM0 and COM1 output mode */ 43954359Sroberto} PORT_PARM; 44054359Sroberto 44154359Sroberto/* Ephemeris parameters of one specific SV. Needed to compute the position */ 44254359Sroberto/* of a satellite at a given time with high precision. Valid for an */ 44354359Sroberto/* interval of 4 to 6 hours from start of transmission. */ 44454359Sroberto 44554359Srobertotypedef struct { 44654359Sroberto CSUM csum; /* checksum of the remaining bytes */ 44754359Sroberto short valid; /* flag data are valid */ 44854359Sroberto 44954359Sroberto HEALTH health; /* health indication of transmitting SV [---] */ 45054359Sroberto IOD IODC; /* Issue Of Data, Clock */ 45154359Sroberto IOD IODE2; /* Issue of Data, Ephemeris (Subframe 2) */ 45254359Sroberto IOD IODE3; /* Issue of Data, Ephemeris (Subframe 3) */ 45354359Sroberto T_GPS tt; /* time of transmission */ 45454359Sroberto T_GPS t0c; /* Reference Time Clock [---] */ 45554359Sroberto T_GPS t0e; /* Reference Time Ephemeris [---] */ 45654359Sroberto 45754359Sroberto l_fp sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */ 45854359Sroberto l_fp e; /* Eccentricity [---] */ 45954359Sroberto l_fp M0; /* � Mean Anomaly at Ref. Time [rad] */ 46054359Sroberto l_fp omega; /* � Argument of Perigee [rad] */ 46154359Sroberto l_fp OMEGA0; /* � Longit. of Asc. Node of orbit plane [rad] */ 46254359Sroberto l_fp OMEGADOT; /* � Rate of Right Ascension [rad/sec] */ 46354359Sroberto l_fp deltan; /* � Mean Motion Diff. from computed value [rad/sec] */ 46454359Sroberto l_fp i0; /* � Inclination Angle [rad] */ 46554359Sroberto l_fp idot; /* � Rate of Inclination Angle [rad/sec] */ 46654359Sroberto l_fp crc; /* � Cosine Corr. Term to Orbit Radius [m] */ 46754359Sroberto l_fp crs; /* � Sine Corr. Term to Orbit Radius [m] */ 46854359Sroberto l_fp cuc; /* � Cosine Corr. Term to Arg. of Latitude [rad] */ 46954359Sroberto l_fp cus; /* � Sine Corr. Term to Arg. of Latitude [rad] */ 47054359Sroberto l_fp cic; /* � Cosine Corr. Term to Inclination Angle [rad] */ 47154359Sroberto l_fp cis; /* � Sine Corr. Term to Inclination Angle [rad] */ 47254359Sroberto 47354359Sroberto l_fp af0; /* � Clock Correction Coefficient 0 [sec] */ 47454359Sroberto l_fp af1; /* � Clock Correction Coefficient 1 [sec/sec] */ 47554359Sroberto l_fp af2; /* � Clock Correction Coefficient 2 [sec/sec�] */ 47654359Sroberto l_fp tgd; /* � estimated group delay differential [sec] */ 47754359Sroberto 47854359Sroberto u_short URA; /* predicted User Range Accuracy */ 47954359Sroberto 48054359Sroberto u_char L2code; /* code on L2 channel [---] */ 48154359Sroberto u_char L2flag; /* L2 P data flag [---] */ 48254359Sroberto 48354359Sroberto} EPH; 48454359Sroberto 48554359Sroberto/* Almanac parameters of one specific SV. A reduced precision set of */ 48654359Sroberto/* parameters used to check if a satellite is in view at a given time. */ 48754359Sroberto/* Valid for an interval of more than 7 days from start of transmission. */ 48854359Sroberto 48954359Srobertotypedef struct { 49054359Sroberto CSUM csum; /* checksum of the remaining bytes */ 49154359Sroberto short valid; /* flag data are valid */ 49254359Sroberto 49354359Sroberto HEALTH health; /* [---] */ 49454359Sroberto T_GPS t0a; /* Reference Time Almanac [sec] */ 49554359Sroberto 49654359Sroberto l_fp sqrt_A; /* Square Root of semi-major Axis [sqrt(m)] */ 49754359Sroberto l_fp e; /* Eccentricity [---] */ 49854359Sroberto 49954359Sroberto l_fp M0; /* � Mean Anomaly at Ref. Time [rad] */ 50054359Sroberto l_fp omega; /* � Argument of Perigee [rad] */ 50154359Sroberto l_fp OMEGA0; /* � Longit. of Asc. Node of orbit plane [rad] */ 50254359Sroberto l_fp OMEGADOT; /* � Rate of Right Ascension [rad/sec] */ 50354359Sroberto l_fp deltai; /* � [rad] */ 50454359Sroberto l_fp af0; /* � Clock Correction Coefficient 0 [sec] */ 50554359Sroberto l_fp af1; /* � Clock Correction Coefficient 1 [sec/sec] */ 50654359Sroberto} ALM; 50754359Sroberto 50854359Sroberto 50954359Sroberto/* ionospheric correction parameters */ 51054359Sroberto 51154359Srobertotypedef struct { 51254359Sroberto CSUM csum; /* checksum of the remaining bytes */ 51354359Sroberto short valid; /* flag data are valid */ 51454359Sroberto 51554359Sroberto l_fp alpha_0; /* Ionosph. Corr. Coeff. Alpha 0 [sec] */ 51654359Sroberto l_fp alpha_1; /* Ionosph. Corr. Coeff. Alpha 1 [sec/deg] */ 51754359Sroberto l_fp alpha_2; /* Ionosph. Corr. Coeff. Alpha 2 [sec/deg^2] */ 51854359Sroberto l_fp alpha_3; /* Ionosph. Corr. Coeff. Alpha 3 [sec/deg^3] */ 51954359Sroberto 52054359Sroberto l_fp beta_0; /* Ionosph. Corr. Coeff. Beta 0 [sec] */ 52154359Sroberto l_fp beta_1; /* Ionosph. Corr. Coeff. Beta 1 [sec/deg] */ 52254359Sroberto l_fp beta_2; /* Ionosph. Corr. Coeff. Beta 2 [sec/deg^2] */ 52354359Sroberto l_fp beta_3; /* Ionosph. Corr. Coeff. Beta 3 [sec/deg^3] */ 52454359Sroberto 52554359Sroberto} IONO; 52654359Sroberto 527182007Srobertovoid mbg_tm_str P((char **, TM *, int)); 528182007Srobertovoid mbg_tgps_str P((char **, T_GPS *, int)); 52954359Srobertovoid get_mbg_header P((unsigned char **, GPS_MSG_HDR *)); 53054359Srobertovoid put_mbg_header P((unsigned char **, GPS_MSG_HDR *)); 53154359Srobertovoid get_mbg_sw_rev P((unsigned char **, SW_REV *)); 53254359Srobertovoid get_mbg_ascii_msg P((unsigned char **, ASCII_MSG *)); 53354359Srobertovoid get_mbg_svno P((unsigned char **, SVNO *)); 53454359Srobertovoid get_mbg_health P((unsigned char **, HEALTH *)); 53554359Srobertovoid get_mbg_cfg P((unsigned char **, CFG *)); 53654359Srobertovoid get_mbg_tgps P((unsigned char **, T_GPS *)); 53754359Srobertovoid get_mbg_tm P((unsigned char **, TM *)); 53854359Srobertovoid get_mbg_ttm P((unsigned char **, TTM *)); 53954359Srobertovoid get_mbg_synth P((unsigned char **, SYNTH *)); 54054359Srobertovoid get_mbg_tzdl P((unsigned char **, TZDL *)); 54154359Srobertovoid get_mbg_antinfo P((unsigned char **, ANT_INFO *)); 54254359Srobertovoid get_mbg_cfgh P((unsigned char **, CFGH *)); 54354359Srobertovoid get_mbg_utc P((unsigned char **, UTC *)); 54454359Srobertovoid get_mbg_lla P((unsigned char **, LLA)); 54554359Srobertovoid get_mbg_xyz P((unsigned char **, XYZ)); 54654359Srobertovoid get_mbg_portparam P((unsigned char **, PORT_PARM *)); 54754359Srobertovoid get_mbg_eph P((unsigned char **, EPH *)); 54854359Srobertovoid get_mbg_alm P((unsigned char **, ALM *)); 54954359Srobertovoid get_mbg_iono P((unsigned char **, IONO *)); 55054359Sroberto 55154359Srobertounsigned long mbg_csum P((unsigned char *, unsigned int)); 55254359Sroberto 55354359Sroberto#endif 55454359Sroberto/* 555182007Sroberto * History: 556182007Sroberto * 55754359Sroberto * mbg_gps166.h,v 558182007Sroberto * Revision 4.7 2006/06/22 18:41:43 kardel 559182007Sroberto * clean up signedness (gcc 4) 560182007Sroberto * 561182007Sroberto * Revision 4.6 2005/10/07 22:11:56 kardel 562182007Sroberto * bounded buffer implementation 563182007Sroberto * 564182007Sroberto * Revision 4.5.2.1 2005/09/25 10:23:48 kardel 565182007Sroberto * support bounded buffers 566182007Sroberto * 567182007Sroberto * Revision 4.5 2005/06/25 10:58:45 kardel 568182007Sroberto * add missing log keywords 569182007Sroberto * 57054359Sroberto * Revision 4.1 1998/06/12 15:07:30 kardel 57154359Sroberto * fixed prototyping 57254359Sroberto * 57354359Sroberto * Revision 4.0 1998/04/10 19:50:42 kardel 57454359Sroberto * Start 4.0 release version numbering 57554359Sroberto * 57654359Sroberto * Revision 1.1 1998/04/10 19:27:34 kardel 57754359Sroberto * initial NTP VERSION 4 integration of PARSE with GPS166 binary support 57854359Sroberto * 57954359Sroberto * Revision 1.1 1997/10/06 20:55:38 kardel 58054359Sroberto * new parse structure 58154359Sroberto * 58254359Sroberto */ 583