⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 87

📁 Unix/Linux 网络时间协议版本3 Network Time Protocol Version 3 (NTP) distribution for Unix systems
💻
📖 第 1 页 / 共 4 页
字号:
Forwarded: Wed, 12 Feb 1997 19:09:34 -0500Forwarded: "mills@udel.edu "Replied: Wed, 12 Feb 1997 19:08:47 -0500Replied: "Marc Brett <ltso@london.waii.com> Marc.Brett@phoenix.london.waii.com,Replied: Frank.Vance@phoenix.london.waii.com, leres@ee.lbl.gov"Received: from snow-white.ee.udel.edu by whimsy.udel.edu id aa10102;          12 Feb 97 14:48 GMTReceived: by diamond.waii.com; id IAA27406; Wed, 12 Feb 1997 08:48:09 -0600Received: from mail.wg.waii.com(137.144.128.17) by diamond.waii.com via smap (3.2)	id xma027391; Wed, 12 Feb 97 08:47:20 -0600Received: from merlin.london.waii.com (merlin.london.waii.com [136.250.33.1]) by mail1.wg.waii.com (8.7.5/8.7.3) with SMTP id IAA21980; Wed, 12 Feb 1997 08:47:16 -0600Received: from phoenix (phoenix.london.waii.com) by merlin.london.waii.com with SMTP id AA43837  (5.65c/IDA-1.4.4); Wed, 12 Feb 1997 14:47:11 GMTReceived: by phoenix (4.1/SMI-4.1)	id AA08374; Wed, 12 Feb 97 14:47:06 GMTFrom: Marc Brett <ltso@london.waii.com>Message-Id: <9702121447.AA08374@phoenix>Subject: MX4200 driver rewriteTo: stenn@whimsy.udel.eduDate: Wed, 12 Feb 1997 14:47:05 +0000 (GMT)Cc: Marc.Brett@phoenix.london.waii.com, Frank.Vance@phoenix.london.waii.com,     leres@ee.lbl.govX-Mailer: ELM [version 2.4 PL23]Mime-Version: 1.0Content-Type: text/plain; charset=US-ASCIIContent-Transfer-Encoding: 7bitHarlan,Here is the MX4200 (Type 9) driver rewritten into the "new style"driver format.  Along the way, there have been some major andminor enhancements.  These include:	1. Revamped I/O.  This uses what I presume are standard	   calls to NTP libraries: refclock_open, refclock_gtlin,	   and friends, rather than reading the passed buffer	   arguments.  This is working very well on my setup	   (SPARC IPX, SunOS 4.1.3, STREAMS support from	   ppsclock-1.6a1), but it has not been tested on	   any other machine.  Would be grateful for some	   assistance in this area (Craig?).	2. Reworked the filters slightly to examine the last	   64 time samples in a roll-along fashion.	3. Filled out the pp structure with proper data, so xntpdc	   clkbug 127.127.9.0 responds with reasonable values.	   The last 10 values are the minimum and maximum offsets,	   followed by the 8 survivors of the median filter algorithm.	4. Added position-averaging logic to filter out effects	   of GPS SA, and switch to time-only mode after 24 hours.	   This should improve the accuracy of the time samples	   marginally.	5. Numerous code reorganizations, tweaks, comments, etc.	   Incorporates all recent changes up to xntp3-5.89.5.	   Better to send the whole lot rather than diffs.There are three files to change.  include/mx4200.h had a minorerror in a definition which isn't even used.  html/driver9.htmlis the new documentation, and xntpd/refclock_mx4200.c is thenew code.  Diffs for the first 2, and the complete file for thelast.Best Regards,--Marc Brett              Marc.Brett@waii.comWestern Geophysical     Tel: +44 181 560 3160 ext. 4178*** include/mx4200.h.orig	Sat Jun 11 20:53:40 1994--- include/mx4200.h	Tue Feb 11 18:01:57 1997****************** 5,11 ****  #define PMVXG_S_SATHEALTH	2	/* satellite health control */  #define PMVXG_S_DIFFNAV		3	/* differential navigation control */  #define PMVXG_S_PORTCONF	7	/* control port configuration */! #define PMVXG_S_GETSELFTEST	3	/* self test (request results) */  #define PMVXG_S_RTCMCONF	16	/* RTCM port configuration */  #define PMVXG_S_PASSTHRU	17	/* equipment port pass-thru config */  #define PMVXG_S_RESTART		18	/* restart control */--- 5,11 ----  #define PMVXG_S_SATHEALTH	2	/* satellite health control */  #define PMVXG_S_DIFFNAV		3	/* differential navigation control */  #define PMVXG_S_PORTCONF	7	/* control port configuration */! #define PMVXG_S_GETSELFTEST	13	/* self test (request results) */  #define PMVXG_S_RTCMCONF	16	/* RTCM port configuration */  #define PMVXG_S_PASSTHRU	17	/* equipment port pass-thru config */  #define PMVXG_S_RESTART		18	/* restart control */*** html/driver9.html.orig.html	Thu Oct 10 18:20:39 1996--- html/driver9.html	Tue Feb 11 19:58:18 1997****************** 7,22 ****    <p><h4>Synopsis</h4>  ! <p>Address: 127.127.5.<var>u</var>  <br>Reference ID: GPS  <br>Driver ID: GPS-MX4200! <br>Serial Port: <code>/dev/gps<var>u</var></code>; 9600 baud, 8-bits,  no parity  <br>Features: <code>ppsclock</code> (required)    <p><h4>Description</h4>  ! <p>This driver supports the Magnavox MX4200 Navigation Receiver adapted  to precision timing applications. It requires the <code>ppsclock</code>  line discipline or streams module described in the <a  href="ldisc.html">Line Disciplines and Streams Drivers</a> page. It also--- 7,22 ----    <p><h4>Synopsis</h4>  ! <p>Address: 127.127.9.<var>u</var>  <br>Reference ID: GPS  <br>Driver ID: GPS-MX4200! <br>Serial Port: <code>/dev/gps<var>u</var></code>; 4800 baud, 8-bits,  no parity  <br>Features: <code>ppsclock</code> (required)    <p><h4>Description</h4>  ! <p>This driver supports the Magnavox MX 4200 Navigation Receiver adapted  to precision timing applications. It requires the <code>ppsclock</code>  line discipline or streams module described in the <a  href="ldisc.html">Line Disciplines and Streams Drivers</a> page. It also****************** 24,33 ****  the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a>  page.    <p><h4>Monitor Data</h4>  ! <p>No <code>filegen clockstats</code> monitor data are produced by this! driver.    <p><h4>Fudge Factors</h4>  --- 24,50 ----  the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a>  page.  + <p>This driver supports all compatible receivers such as the 6-channel+ MX 4200, MX 4200D, and the 12-channel MX 9212, MX 9012R, MX 9112.+ + <p>This driver assumes that the GPS antenna is in a fixed location.  The+ receiver is initially placed in a "Static, 3D Nav" mode, where latitude,+ longitude, elevation and time are calculated for a fixed station.  A+ DOP-weighted running average position is calculated from this data.+ After 24 hours, the receiver is placed into a "Known Position" mode,+ initialized with the calculated position, and then solves only for time.+ + <p>The requirement for a fixed installation precludes operation of+ this driver aboard moving ships, aircraft, or land vehicles.  Also,+ the position averaging algorithm does not take into account boundary+ conditions, so operation very near the international date line or the+ poles is not recomended.+   <p><h4>Monitor Data</h4>  ! <p>The driver writes each timecode as received to the! <code>clockstats</code> file.!     <p><h4>Fudge Factors</h4>  -rw-rw-r--  1 brett       45302 Feb 12 13:26 xntpd/refclock_mx4200.c/* * This software was developed by the Computer Systems Engineering group * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66. * * Copyright (c) 1992 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * 3. All advertising materials mentioning features or use of this software *    must display the following acknowledgement: *	This product includes software developed by the University of *	California, Lawrence Berkeley Laboratory. * 4. The name of the University may not be used to endorse or promote *    products derived from this software without specific prior *    written permission. * * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */#ifdef HAVE_CONFIG_H# include <config.h>#endif#if defined(REFCLOCK) && defined(MX4200) && defined(PPS)#include <stdio.h>#include <ctype.h>#include <sys/time.h>#include <errno.h>#include "ntpd.h"#include "ntp_io.h"#include "ntp_refclock.h"#include "ntp_unixtime.h"#include "ntp_stdlib.h"#include "mx4200.h"#if __STDC__#include <stdarg.h>#else#include <varargs.h>#endif /* __STDC__ */#ifdef PPS#include <sys/ppsclock.h>#endif /* PPS *//* * This driver supports the Magnavox Model MX 4200 GPS Receiver * adapted to precision timing applications.  It requires the * ppsclock line discipline or streams module described in the * Line Disciplines and Streams Drivers page. It also requires a * gadget box and 1-PPS level converter, such as described in the * Pulse-per-second (PPS) Signal Interfacing page. * * It's likely that other compatible Magnavox receivers such as the * MX 4200D, MX 9212, MX 9012R, MX 9112 will be supported by this code. *//* * GPS Definitions */#define	DEVICE		"/dev/gps%d"	/* device name and unit */#define	SPEED232	B4800		/* baud *//* * The number of raw samples which we acquire to derive a single estimate. * NSAMPLES ideally should not exceed the default poll interval 64. * NKEEP must be a power of 2 to simplify the averaging process. */#define NSAMPLES	64#define NKEEP		8#define REFCLOCKMAXDISPERSE (FP_SECOND/4) /* max sample dispersion *//* * Radio interface parameters */#define	PRECISION	(-18)	/* precision assumed (about 4 us) */#define	REFID	"GPS\0"		/* reference id */#define	DESCRIPTION	"Magnavox MX4200 GPS Receiver" /* who we are */#define	DEFFUDGETIME	0	/* default fudge time (ms) *//* * Position Averaging. * Reference: Dr. Thomas A. Clark's Totally Accurate Clock (TAC) files at * ftp://aleph.gsfc.nasa.gov/GPS/totally.accurate.clock/ */#define MAX_VEL_SQUARED	(1.0)	/* Maximum acceptable velocity (squared) (m/s)*/#define INTERVAL	1	/* Interval between position measurements (s) */#define AVGING_TIME	24	/* Number of hours to average */#define USUAL_EDOP	0.75	/* used for normalizing EDOP */#define USUAL_NDOP	0.75	/* used for normalizing NDOP */#define USUAL_VDOP	1.70	/* used for normalizing VDOP *//* * Imported from the ntp_timer module */extern u_long current_time;	/* current time (s) *//* * Imported from ntpd module */extern int debug;		/* global debug flag */#ifdef PPS/* * Imported from loop_filter module */extern int fdpps;		/* ppsclock file descriptor */#endif /* PPS *//* * Imported from perror(3) */extern int  sys_nerr;extern char *sys_errlist[];extern int  errno;/* * MX4200 unit control structure. */struct mx4200unit {	u_int  pollcnt;			/* poll message counter */	u_int  polled;			/* Hand in a time sample? */#ifdef PPS	u_int  lastserial;		/* last pps serial number */	struct ppsclockev ppsev;	/* PPS control structure */#endif /* PPS */	double avg_lat;			/* average latitude */	double avg_lon;			/* average longitude */	double avg_alt;			/* average height */	double filt_lat;		/* latitude filter length */	double filt_lon;		/* longitude filter length */	double filt_alt;		/* height filter length */	double edop;			/* EDOP (east DOP) */	double ndop;			/* NDOP (north DOP) */	double vdop;			/* VDOP (vertical DOP) */	u_int  moving;			/* are we moving? */	u_int  known;			/* position known yet? */	u_long clamp_time;		/* when to stop postion averaging */	int    coderecv;		/* total received samples */	int    nkeep;			/* number of samples to preserve */	int    rshift;			/* number of rshifts for division */	l_fp   filter[NSAMPLES];	/* offset filter */	l_fp   lastref;			/* last reference timestamp */};static char pmvxg[] = "PMVXG";/* * Function prototypes */static	int	mx4200_start	P((int, struct peer *));static	void	mx4200_shutdown	P((int, struct peer *));static	void	mx4200_receive	P((struct recvbuf *));static	void	mx4200_poll	P((int, struct peer *));static	char *	mx4200_parse_t	P((struct peer *));static	char *	mx4200_parse_p	P((struct peer *));static	char *	mx4200_parse_d	P((struct peer *));static	char *	mx4200_parse_s	P((struct peer *));static	char *	mx4200_offset	P((struct peer *));static	char *	mx4200_process	P((struct peer *));#ifdef QSORT_USES_VOID_P	int	mx4200_cmpl_fp	P((const void *, const void *));#else	int	mx4200_cmpl_fp	P((const l_fp *, const l_fp *));#endif /* not QSORT_USES_VOID_P */static	void	mx4200_config	P((struct peer *));static	void	mx4200_ref	P((struct peer *));static	void	mx4200_send	P((struct peer *, char *, ...));static	u_char	mx4200_cksum	P((char *, u_int));static	int	mx4200_jday	P((int, int, int));static	void	mx4200_debug	P((struct peer *, char *, ...));static	int	mx4200_pps	P((struct peer *));/* * Transfer vector */struct	refclock refclock_mx4200 = {	mx4200_start,		/* start up driver */	mx4200_shutdown,	/* shut down driver */	mx4200_poll,		/* transmit poll message */	noentry,		/* not used (old mx4200_control) */	noentry,		/* initialize driver (not used) */	noentry,		/* not used (old mx4200_buginfo) */	NOFLAGS			/* not used */};/* * mx4200_start - open the devices and initialize data for processing */static intmx4200_start(unit, peer)	int unit;	struct peer *peer;{	register struct mx4200unit *up;	struct refclockproc *pp;	int fd;	int i;	char gpsdev[20];	/*	 * Open serial port	 */	(void)sprintf(gpsdev, DEVICE, unit);#ifdef PPS	if (!(fd = refclock_open(gpsdev, SPEED232, LDISC_PPS)))#else	if (!(fd = refclock_open(gpsdev, SPEED232, 0)))#endif /* PPS */		return (0);	/*	 * Allocate unit structure	 */	if (!(up = (struct mx4200unit *) emalloc(sizeof(struct mx4200unit)))) {		(void) close(fd);		return (0);	}	memset((char *)up, 0, sizeof(struct mx4200unit));	pp = peer->procptr;	pp->io.clock_recv = mx4200_receive;	pp->io.srcclock = (caddr_t)peer;	pp->io.datalen = 0;	pp->io.fd = fd;	if (!io_addclock(&pp->io)) {		(void) close(fd);		free(up);		return (0);	}	pp->unitptr = (caddr_t)up;	/*	 * Initialize miscellaneous variables	 */	peer->precision = PRECISION;	pp->clockdesc = DESCRIPTION;	memcpy((char *)&pp->refid, REFID, 4);	up->pollcnt  = 2;	up->polled   = 0;	up->moving   = 0;	/* not moving */	up->known    = 0;	/* not moving */	up->avg_lat  = 0.0;	up->avg_lon  = 0.0;	up->avg_alt  = 0.0;	up->filt_lat = 0.0;	up->filt_lon = 0.0;	up->filt_alt = 0.0;	up->edop     = USUAL_EDOP;	up->ndop     = USUAL_NDOP;	up->vdop     = USUAL_VDOP;	up->clamp_time = current_time + (AVGING_TIME * 60 * 60);	up->coderecv = 0;	up->nkeep    = NKEEP;	if (up->nkeep > NSAMPLES) up->nkeep = NSAMPLES;	if (up->nkeep >=   1) up->rshift =  0;	if (up->nkeep >=   2) up->rshift =  1;	if (up->nkeep >=   4) up->rshift =  2;	if (up->nkeep >=   8) up->rshift =  3;	if (up->nkeep >=  16) up->rshift =  4;	if (up->nkeep >=  32) up->rshift =  5;	if (up->nkeep >=  64) up->rshift =  6;	up->nkeep =1;	i = up->rshift;	while (i > 0) {		up->nkeep *= 2;		i--;	}	/* Ensure the receiver is properly configured */	mx4200_config(peer);	return (1);}/* * mx4200_shutdown - shut down the clock */static voidmx4200_shutdown(unit, peer)	int unit;	struct peer *peer;{	register struct mx4200unit *up;	struct refclockproc *pp;	pp = peer->procptr;	up = (struct mx4200unit *)pp->unitptr;	io_closeclock(&pp->io);	free(up);}/* * mx4200_config - Configure the receiver */static voidmx4200_config(peer)	struct peer *peer;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -