Annotation of embedaddon/ntp/ntpd/refclock_palisade.h, revision 1.1

1.1     ! misho       1: /*
        !             2:  * This software was developed by the Software and Component Technologies
        !             3:  * group of Trimble Navigation, Ltd.
        !             4:  *
        !             5:  * Copyright (c) 1997, 1998, 1999, 2000   Trimble Navigation Ltd.
        !             6:  * All rights reserved.
        !             7:  *
        !             8:  * Redistribution and use in source and binary forms, with or without
        !             9:  * modification, are permitted provided that the following conditions
        !            10:  * are met:
        !            11:  * 1. Redistributions of source code must retain the above copyright
        !            12:  *    notice, this list of conditions and the following disclaimer.
        !            13:  * 2. Redistributions in binary form must reproduce the above copyright
        !            14:  *    notice, this list of conditions and the following disclaimer in the
        !            15:  *    documentation and/or other materials provided with the distribution.
        !            16:  * 3. All advertising materials mentioning features or use of this software
        !            17:  *    must display the following acknowledgement:
        !            18:  *    This product includes software developed by Trimble Navigation, Ltd.
        !            19:  * 4. The name of Trimble Navigation Ltd. may not be used to endorse or
        !            20:  *    promote products derived from this software without specific prior
        !            21:  *    written permission.
        !            22:  *
        !            23:  * THIS SOFTWARE IS PROVIDED BY TRIMBLE NAVIGATION LTD. ``AS IS'' AND
        !            24:  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
        !            25:  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
        !            26:  * ARE DISCLAIMED.  IN NO EVENT SHALL TRIMBLE NAVIGATION LTD. BE LIABLE
        !            27:  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
        !            28:  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
        !            29:  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
        !            30:  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
        !            31:  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
        !            32:  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
        !            33:  * SUCH DAMAGE.
        !            34:  */
        !            35: 
        !            36: /*
        !            37:  * refclock_palisade - clock driver for the Trimble Palisade GPS
        !            38:  * timing receiver
        !            39:  *
        !            40:  * For detailed information on this program, please refer to the html 
        !            41:  * Refclock 29 page accompanying the NTP distribution.
        !            42:  *
        !            43:  * for questions / bugs / comments, contact:
        !            44:  * sven_dietrich@trimble.com
        !            45:  *
        !            46:  * Sven-Thorsten Dietrich
        !            47:  * 645 North Mary Avenue
        !            48:  * Post Office Box 3642
        !            49:  * Sunnyvale, CA 94088-3642
        !            50:  *
        !            51:  */
        !            52: 
        !            53: #ifndef _REFCLOCK_PALISADE_H
        !            54: #define _REFCLOCK_PALISADE_H
        !            55: 
        !            56: #ifdef HAVE_CONFIG_H
        !            57: #include "config.h"
        !            58: #endif
        !            59: 
        !            60: #if defined HAVE_SYS_MODEM_H
        !            61: #include <sys/modem.h>
        !            62: #ifndef __QNXNTO__
        !            63: #define TIOCMSET MCSETA
        !            64: #define TIOCMGET MCGETA
        !            65: #define TIOCM_RTS MRTS
        !            66: #endif
        !            67: #endif
        !            68: 
        !            69: #ifdef HAVE_TERMIOS_H
        !            70: # ifdef TERMIOS_NEEDS__SVID3
        !            71: #  define _SVID3
        !            72: # endif
        !            73: # include <termios.h>
        !            74: # include <sys/stat.h>
        !            75: # ifdef TERMIOS_NEEDS__SVID3
        !            76: #  undef _SVID3
        !            77: # endif
        !            78: #endif
        !            79: 
        !            80: #ifdef HAVE_SYS_IOCTL_H
        !            81: #include <sys/ioctl.h>
        !            82: #endif
        !            83: 
        !            84: #include "ntpd.h"
        !            85: #include "ntp_io.h"
        !            86: #include "ntp_control.h"
        !            87: #include "ntp_refclock.h"
        !            88: #include "ntp_unixtime.h"
        !            89: #include "ntp_stdlib.h"
        !            90: 
        !            91: /*
        !            92:  * GPS Definitions
        !            93:  */
        !            94: #define        DESCRIPTION     "Trimble Palisade GPS" /* Long name */
        !            95: #define        PRECISION       (-20)   /* precision assumed (about 1 us) */
        !            96: #define        REFID           "GPS\0" /* reference ID */
        !            97: #define TRMB_MINPOLL    4      /* 16 seconds */
        !            98: #define TRMB_MAXPOLL   5       /* 32 seconds */
        !            99: 
        !           100: /*
        !           101:  * I/O Definitions
        !           102:  */
        !           103: #define        DEVICE          "/dev/palisade%d"       /* device name and unit */
        !           104: #define        SPEED232        B9600                   /* uart speed (9600 baud) */
        !           105: 
        !           106: /*
        !           107:  * TSIP Report Definitions
        !           108:  */
        !           109: #define LENCODE_8F0B   74      /* Length of TSIP 8F-0B Packet & header */
        !           110: #define LENCODE_NTP     22     /* Length of Palisade NTP Packet */
        !           111: 
        !           112: #define LENCODE_8FAC    68      /* Length of Thunderbolt 8F-AC Position Packet*/
        !           113: #define LENCODE_8FAB    17      /* Length of Thunderbolt Primary Timing Packet*/
        !           114: 
        !           115: /* Allowed Sub-Packet ID's */
        !           116: #define PACKET_8F0B    0x0B
        !           117: #define PACKET_NTP     0xAD
        !           118: 
        !           119: /* Thunderbolt Packets */
        !           120: #define PACKET_8FAC     0xAC   /* Supplementary Thunderbolt Time Packet */
        !           121: #define PACKET_8FAB     0xAB   /* Primary Thunderbolt Time Packet */
        !           122: #define PACKET_6D      0x6D    /* Supplementary Thunderbolt Tracking Stats */
        !           123: #define PACKET_41      0x41    /* Thunderbolt I dont know what this packet is, it's not documented on my manual*/
        !           124: 
        !           125: /* Acutime Packets */
        !           126: #define PACKET_41A      0x41    /* GPS time */
        !           127: #define PACKET_46       0x46    /* Receiver Health */
        !           128: 
        !           129: #define DLE 0x10
        !           130: #define ETX 0x03
        !           131: 
        !           132: /* parse states */
        !           133: #define TSIP_PARSED_EMPTY       0      
        !           134: #define TSIP_PARSED_FULL        1
        !           135: #define TSIP_PARSED_DLE_1       2
        !           136: #define TSIP_PARSED_DATA        3
        !           137: #define TSIP_PARSED_DLE_2       4
        !           138: 
        !           139: /* 
        !           140:  * Leap-Insert and Leap-Delete are encoded as follows:
        !           141:  *     PALISADE_UTC_TIME set   and PALISADE_LEAP_PENDING set: INSERT leap
        !           142:  */
        !           143: 
        !           144: #define PALISADE_LEAP_INPROGRESS 0x08 /* This is the leap flag                 */
        !           145: #define PALISADE_LEAP_WARNING    0x04 /* GPS Leap Warning (see ICD-200) */
        !           146: #define PALISADE_LEAP_PENDING    0x02 /* Leap Pending (24 hours)               */
        !           147: #define PALISADE_UTC_TIME        0x01 /* UTC time available                            */
        !           148: 
        !           149: #define mb(_X_) (up->rpt_buf[(_X_ + 1)]) /* shortcut for buffer access */
        !           150: 
        !           151: /* Conversion Definitions */
        !           152: #define GPS_PI                 (3.1415926535898)
        !           153: #define        R2D             (180.0/GPS_PI)
        !           154: 
        !           155: /*
        !           156:  * Structure for build data packets for send (thunderbolt uses it only)
        !           157:  * taken from Markus Prosch
        !           158:  */
        !           159: struct packettx
        !           160: {
        !           161:        short   size;
        !           162:        u_char *data;
        !           163: };
        !           164: 
        !           165: /*
        !           166:  * Palisade unit control structure.
        !           167:  */
        !           168: struct palisade_unit {
        !           169:        short           unit;           /* NTP refclock unit number */
        !           170:        int             polled;         /* flag to detect noreplies */
        !           171:        char            leap_status;    /* leap second flag */
        !           172:        char            rpt_status;     /* TSIP Parser State */
        !           173:        short           rpt_cnt;        /* TSIP packet length so far */
        !           174:        char            rpt_buf[BMAX];  /* packet assembly buffer */
        !           175:        int             type;           /* Clock mode type */
        !           176: };
        !           177: 
        !           178: /*
        !           179:  * Function prototypes
        !           180:  */
        !           181: 
        !           182: static int     palisade_start          (int, struct peer *);
        !           183: static void    palisade_shutdown       (int, struct peer *);
        !           184: static void    palisade_receive        (struct peer *);
        !           185: static void    palisade_poll           (int, struct peer *);
        !           186: static  void   palisade_io             (struct recvbuf *);
        !           187: int            palisade_configure      (int, struct peer *);
        !           188: int            TSIP_decode             (struct peer *);
        !           189: long           HW_poll                 (struct refclockproc *);
        !           190: float          getfloat                (u_char *); 
        !           191: double                 getdbl                  (u_char *);
        !           192: short                  getint                  (u_char *);
        !           193: long           getlong                 (u_char *);
        !           194: 
        !           195: 
        !           196: #ifdef PALISADE_SENDCMD_RESURRECTED
        !           197: static  void   sendcmd                 (struct packettx *buffer, int c);
        !           198: #endif
        !           199: static  void   sendsupercmd            (struct packettx *buffer, int c1, int c2);
        !           200: static  void   sendbyte                (struct packettx *buffer, int b);
        !           201: static  void   sendint                 (struct packettx *buffer, int a);
        !           202: static  int    sendetx                 (struct packettx *buffer, int fd);
        !           203: static  void   init_thunderbolt        (int fd);
        !           204: static  void   init_acutime            (int fd);
        !           205: #endif /* PALISADE_H */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>