1 /* $NetBSD: refclock_palisade.h,v 1.2 2003/12/04 16:23:37 drochner Exp $ */
4 * This software was developed by the Software and Component Technologies
5 * group of Trimble Navigation, Ltd.
7 * Copyright (c) 1997, 1998, 1999, 2000 Trimble Navigation Ltd.
10 * Redistribution and use in source and binary forms, with or without
11 * modification, are permitted provided that the following conditions
13 * 1. Redistributions of source code must retain the above copyright
14 * notice, this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright
16 * notice, this list of conditions and the following disclaimer in the
17 * documentation and/or other materials provided with the distribution.
18 * 3. All advertising materials mentioning features or use of this software
19 * must display the following acknowledgement:
20 * This product includes software developed by Trimble Navigation, Ltd.
21 * 4. The name of Trimble Navigation Ltd. may not be used to endorse or
22 * promote products derived from this software without specific prior
25 * THIS SOFTWARE IS PROVIDED BY TRIMBLE NAVIGATION LTD. ``AS IS'' AND
26 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
27 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
28 * ARE DISCLAIMED. IN NO EVENT SHALL TRIMBLE NAVIGATION LTD. BE LIABLE
29 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
30 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
31 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
32 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
33 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
34 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 * refclock_palisade - clock driver for the Trimble Palisade GPS
42 * For detailed information on this program, please refer to the html
43 * Refclock 29 page accompanying the NTP distribution.
45 * for questions / bugs / comments, contact:
46 * sven_dietrich@trimble.com
48 * Sven-Thorsten Dietrich
49 * 645 North Mary Avenue
50 * Post Office Box 3642
51 * Sunnyvale, CA 94088-3642
55 #ifndef _REFCLOCK_PALISADE_H
56 #define _REFCLOCK_PALISADE_H
62 #if defined HAVE_SYS_MODEM_H
63 #include <sys/modem.h>
65 #define TIOCMSET MCSETA
66 #define TIOCMGET MCGETA
67 #define TIOCM_RTS MRTS
72 # ifdef TERMIOS_NEEDS__SVID3
76 # ifdef TERMIOS_NEEDS__SVID3
81 #ifdef HAVE_SYS_IOCTL_H
82 #include <sys/ioctl.h>
87 #include "ntp_control.h"
88 #include "ntp_refclock.h"
89 #include "ntp_unixtime.h"
90 #include "ntp_stdlib.h"
95 #define DESCRIPTION "Trimble Palisade GPS" /* Long name */
96 #define PRECISION (-20) /* precision assumed (about 1 us) */
97 #define REFID "GPS\0" /* reference ID */
98 #define TRMB_MINPOLL 4 /* 16 seconds */
99 #define TRMB_MAXPOLL 5 /* 32 seconds */
104 #define DEVICE "/dev/palisade%d" /* device name and unit */
105 #define SPEED232 B9600 /* uart speed (9600 baud) */
108 * TSIP Report Definitions
110 #define LENCODE_8F0B 74 /* Length of TSIP 8F-0B Packet & header */
111 #define LENCODE_NTP 22 /* Length of Palisade NTP Packet */
113 /* Allowed Sub-Packet ID's */
114 #define PACKET_8F0B 0x0B
115 #define PACKET_NTP 0xAD
121 #define TSIP_PARSED_EMPTY 0
122 #define TSIP_PARSED_FULL 1
123 #define TSIP_PARSED_DLE_1 2
124 #define TSIP_PARSED_DATA 3
125 #define TSIP_PARSED_DLE_2 4
128 * Leap-Insert and Leap-Delete are encoded as follows:
129 * PALISADE_UTC_TIME set and PALISADE_LEAP_PENDING set: INSERT leap
132 #define PALISADE_LEAP_INPROGRESS 0x08 /* This is the leap flag */
133 #define PALISADE_LEAP_WARNING 0x04 /* GPS Leap Warning (see ICD-200) */
134 #define PALISADE_LEAP_PENDING 0x02 /* Leap Pending (24 hours) */
135 #define PALISADE_UTC_TIME 0x01 /* UTC time available */
137 #define mb(_X_) (up->rpt_buf[(_X_ + 1)]) /* shortcut for buffer access */
139 /* Conversion Definitions */
140 #define GPS_PI (3.1415926535898)
141 #define R2D (180.0/GPS_PI)
144 * Palisade unit control structure.
146 struct palisade_unit
{
147 short unit
; /* NTP refclock unit number */
148 int polled
; /* flag to detect noreplies */
149 char leap_status
; /* leap second flag */
150 char rpt_status
; /* TSIP Parser State */
151 short rpt_cnt
; /* TSIP packet length so far */
152 char rpt_buf
[BMAX
]; /* packet assembly buffer */
153 int type
; /* Clock mode type */
157 * Function prototypes
160 static int palisade_start
P((int, struct peer
*));
161 static void palisade_shutdown
P((int, struct peer
*));
162 static void palisade_receive
P((struct peer
*));
163 static void palisade_poll
P((int, struct peer
*));
164 static void palisade_io
P((struct recvbuf
*));
165 int palisade_configure
P((int, struct peer
*));
166 int TSIP_decode
P((struct peer
*));
167 long HW_poll
P((struct refclockproc
*));
168 float getfloat
P((u_char
*));
169 double getdbl
P((u_char
*));
170 short getint
P((u_char
*));
172 #endif /* PALISADE_H */