[Git][NTPsec/ntpsec][master] Drop the dumbclock driver.

Eric S. Raymond gitlab at mg.gitlab.com
Mon Jan 30 05:35:02 UTC 2017


Eric S. Raymond pushed to branch master at NTPsec / ntpsec


Commits:
20b6dc79 by Eric S. Raymond at 2017-01-30T00:34:39-05:00
Drop the dumbclock driver.

It was an obvious dorm-room stunt that didn't correspond to any production
hardware, with terrible accuracy and a deedency on the system clock.

- - - - -


5 changed files:

- − docs/driver_dumbclock.txt
- docs/refclock.txt
- ntpd/refclock_conf.c
- − ntpd/refclock_dumbclock.c
- wafhelpers/refclock.py


Changes:

=====================================
docs/driver_dumbclock.txt deleted
=====================================
--- a/docs/driver_dumbclock.txt
+++ /dev/null
@@ -1,73 +0,0 @@
-= Dumb Clock =
-
-== Synopsis ==
-
-["verse",subs="normal"]
-Name: dumbclock
-Reference ID: DUMB
-Serial Port: /dev/dumbclock_u_; 9600bps 8N1
-
-== Deprecation warning ==
-
-This refclock is deprecated and obsolete. The NTPsec maintainers plan
-to remove it in a future release.  If you have a requirement for it,
-please make this known to us.
-
-== Description ==
-
-This driver supports a dumb ASCII clock that only emits localtime at a
-reliable interval. This has no provisions for leap seconds, quality
-codes, etc. It assumes output in the local time zone, and that the C
-library mktime()/localtime() routines will correctly convert back and
-forth between local and UTC.
-
-Most of this code is originally from refclock_wwvb.c (now
-refclock_spectracom.c) with thanks. It has been so mangled that wwvb is
-not a recognizable ancestor.
-
----------------------------
-Timecode format: hh:mm:ssCL
-hh:mm:ss - local time
-C - \r (carriage return)
-L - \n (newline)
----------------------------
-
-== Driver Options ==
-
-+time1+ 'time'::
-  Not used by this driver.
-+time2+ 'time'::
-  Not used by this driver.
-+stratum+ 'number'::
-  Specifies the driver stratum, in decimal from 0 to 15, with default 0.
-+refid+ 'string'::
-  Specifies the driver reference identifier, an ASCII string from one to
-  four characters, with default +DUMB+.
-+flag1 {0 | 1}+::
-  Not used by this driver.
-+flag2 {0 | 1}+::
-  Not used by this driver.
-+flag3 {0 | 1}+::
-  Not used by this driver.
-+flag4 {0 | 1}+::
-  Not used by this driver.
-+subtype+::
-  Not used by this driver.
-+mode+::
-  Enable verbose +clockstats+ recording if set.
-+path+ 'filename'::
-  Overrides the default device path.
-+ppspath+ 'filename'::
-  Not used by this driver.
-+baud+ 'number'::
-  Overrides the default baud rate.
-
-== Configuration Example ==
-
-----------------------------------------------------------------------------
-refclock dumbclock
-----------------------------------------------------------------------------
-
-'''''
-
-include::includes/footer.txt[]


=====================================
docs/refclock.txt
=====================================
--- a/docs/refclock.txt
+++ b/docs/refclock.txt
@@ -176,7 +176,6 @@ parse driver.
 |link:driver_trimble.html[trimble]      | T | Trimble Palisade/Thunderbolt/Acutime GPSes
 |link:driver_oncore.html[oncore]        | - | Motorola UT Oncore GPS
 |link:driver_jupiter.html[jupiter]      | D | Rockwell Jupiter GPS
-|link:driver_dumbclock.html[dumbclock]  | D | Dumb Clock
 |link:driver_jjy.html[jjy]              | T | JJY Receivers
 |link:driver_zyfer.html[zyfer]          | - | Zyfer GPStarplus Receiver
 |link:driver_neoclock.html[neoclock]    | - | NeoClock4X DCF77 / TDF Receiver


=====================================
ntpd/refclock_conf.c
=====================================
--- a/ntpd/refclock_conf.c
+++ b/ntpd/refclock_conf.c
@@ -101,12 +101,6 @@ extern	struct refclock refclock_jupiter;
 #define refclock_jupiter refclock_none
 #endif
 
-#if defined(CLOCK_DUMBCLOCK)
-extern struct refclock refclock_dumbclock;
-#else
-#define refclock_dumbclock refclock_none
-#endif
-
 #ifdef CLOCK_JJY
 extern	struct refclock	refclock_jjy;
 #else
@@ -175,7 +169,7 @@ struct refclock * const refclock_conf[] = {
 	&refclock_oncore,	/* 30 REFCLK_ONCORE */
 	&refclock_jupiter,	/* 31 REFCLK_GPS_JUPITER */
 	&refclock_none,		/* 32 was: REFCLK_CHRONOLOG */
-	&refclock_dumbclock,	/* 33 REFCLK_DUMBCLOCK */
+	&refclock_none,		/* 33 was: REFCLK_DUMBCLOCK */
 	&refclock_none,		/* 34 was: REFCLOCK_ULINK */
 	&refclock_none,		/* 35 was: REFCLOCK_PCF */
 	&refclock_none,		/* 36 was: REFCLOCK_WWV_AUDIO */


=====================================
ntpd/refclock_dumbclock.c deleted
=====================================
--- a/ntpd/refclock_dumbclock.c
+++ /dev/null
@@ -1,321 +0,0 @@
-/*
- * refclock_dumbclock - clock driver for a unknown time distribution system
- * that only provides hh:mm:ss (in local time, yet!).
- */
-
-#include <config.h>
-#include "ntpd.h"
-#include "ntp_io.h"
-#include "ntp_refclock.h"
-#include "ntp_calendar.h"
-#include "ntp_stdlib.h"
-#include "ntp_control.h"	/* for CTL_* clocktypes */
-
-#include <stdio.h>
-#include <ctype.h>
-
-/*
- * This driver supports a generic dumb clock that only outputs hh:mm:ss,
- * in local time, no less.
- *
- * Input format:
- *
- *	hh:mm:ss   <cr>
- *
- * hh:mm:ss -- what you'd expect, with a 24 hour clock.  (Heck, that's the only
- * way it could get stupider.)  We take time on the <cr>.
- *
- * The original source of this module was the WWVB module.
- */
-
-/*
- * Interface definitions
- */
-#define	DEVICE		"/dev/dumbclock%d" /* device name and unit */
-#define	SPEED232	B9600		/* uart speed (9600 baud) */
-#define	PRECISION	(-13)		/* precision assumed (about 100 us) */
-#define	REFID		"DUMB"		/* reference ID */
-#define	NAME		"DUMBCLOCK"	/* shortname */
-#define	DESCRIPTION	"Dumb clock"	/* WRU */
-
-
-/*
- * Insanity check.  Since the time is local, we need to make sure that
- * during midnight transitions, we can convert back to Unix time.  If
- * the conversion results in some number worse than this number of
- * seconds away, assume the next day and retry.
- */
-#define INSANE_SECONDS 3600
-
-/*
- * Dumb clock control structure
- */
-struct dumbclock_unit {
-	bool	  tcswitch;	/* timecode switch */
-	l_fp	  laststamp;	/* last receive timestamp */
-	uint8_t	  lasthour;	/* last hour (for monitor) */
-	uint8_t	  linect;	/* count ignored lines (for monitor */
-	struct tm ymd;		/* struct tm for y/m/d only */
-};
-
-/*
- * Function prototypes
- */
-static	bool	dumbclock_start		(int, struct peer *);
-static	void	dumbclock_shutdown	(int, struct peer *);
-static	void	dumbclock_receive	(struct recvbuf *);
-
-/*
- * Transfer vector
- */
-struct	refclock refclock_dumbclock = {
-	NAME,				     /* basename of driver */
-	dumbclock_start,		     /* start up driver */
-	dumbclock_shutdown,		     /* shut down driver */
-	noentry,			     /* poll the driver -- a nice fabrication */
-	noentry,			     /* control - not used */
-	noentry,			     /* init - not used */
-	noentry				     /* timer - not used */
-};
-
-
-/*
- * dumbclock_start - open the devices and initialize data for processing
- */
-static bool
-dumbclock_start(
-	int unit,
-	struct peer *peer
-	)
-{
-	register struct dumbclock_unit *up;
-	struct refclockproc *pp;
-	int fd;
-	char device[20];
-	struct tm *tm_time_p, tm;
-	time_t     now;
-
-	/*
-	 * Open serial port. Don't bother with CLK line discipline, since
-	 * it's not available.
-	 */
-	snprintf(device, sizeof(device), DEVICE, unit);
-	fd = refclock_open(peer->path ? peer->path : device,
-			   peer->baud ? peer->baud : SPEED232,
-			   0);
-	if (fd <= 0)
-		/* coverity[leaked_handle] */
-		return false;
-
-	/*
-	 * Allocate and initialize unit structure
-	 */
-	up = emalloc_zero(sizeof(*up));
-	pp = peer->procptr;
-	pp->unitptr = up;
-	pp->io.clock_recv = dumbclock_receive;
-	pp->io.srcclock = peer;
-	pp->io.datalen = 0;
-	pp->io.fd = fd;
-	if (!io_addclock(&pp->io)) {
-		close(fd);
-		pp->io.fd = -1;
-		free(up);
-		pp->unitptr = NULL;
-		return false;
-	}
-
-
-	time(&now);
-	tm_time_p = localtime_r(&now, &tm);
-	if (tm_time_p)
-		up->ymd = *tm_time_p;
-	else
-		return false;
-
-	/*
-	 * Initialize miscellaneous variables
-	 */
-	peer->precision = PRECISION;
-	pp->clockname = NAME;
-	pp->clockdesc = DESCRIPTION;
-	memcpy((char *)&pp->refid, REFID, REFIDLEN);
-	peer->sstclktype = CTL_SST_TS_LF;
-	return true;
-}
-
-
-/*
- * dumbclock_shutdown - shut down the clock
- */
-static void
-dumbclock_shutdown(
-	int unit,
-	struct peer *peer
-	)
-{
-	register struct dumbclock_unit *up;
-	struct refclockproc *pp;
-
-	UNUSED_ARG(unit);
-
-	pp = peer->procptr;
-	up = pp->unitptr;
-	if (-1 != pp->io.fd)
-		io_closeclock(&pp->io);
-	if (NULL != up)
-		free(up);
-}
-
-
-/*
- * dumbclock_receive - receive data from the serial interface
- */
-static void
-dumbclock_receive(
-	struct recvbuf *rbufp
-	)
-{
-	struct dumbclock_unit *up;
-	struct refclockproc *pp;
-	struct peer *peer;
-
-	l_fp	trtmp;		/* arrival timestamp */
-	int	hours;		/* hour-of-day */
-	int	minutes;	/* minutes-past-the-hour */
-	int	seconds;	/* seconds */
-	int	temp;		/* int temp */
-	int	got_good;	/* got a good time flag */
-
-	/*
-	 * Initialize pointers and read the timecode and timestamp
-	 */
-	peer = rbufp->recv_peer;
-	pp = peer->procptr;
-	up = pp->unitptr;
-	temp = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
-
-	if (temp == 0) {
-		if (!up->tcswitch) {
-			up->tcswitch = true;
-			up->laststamp = trtmp;
-		} else
-			up->tcswitch = false;
-		return;
-	}
-	pp->lencode = (u_short)temp;
-	pp->lastrec = up->laststamp;
-	up->laststamp = trtmp;
-	up->tcswitch = true;
-
-#ifdef DEBUG
-	if (debug)
-		printf("dumbclock: timecode %d %s\n",
-		       pp->lencode, pp->a_lastcode);
-#endif
-
-	/*
-	 * We get down to business. Check the timecode format...
-	 */
-	got_good=0;
-	if (sscanf(pp->a_lastcode,"%02d:%02d:%02d",
-		   &hours,&minutes,&seconds) == 3)
-	{
-	    struct tm *gmtp, mygm;
-	    struct tm *lt_p;
-	    struct tm tmbuf;
-	    time_t     asserted_time;	     /* the SPM time based on the composite time+date */
-	    struct tm  asserted_tm;	     /* the struct tm of the same */
-	    int        adjyear;
-	    int        adjmon;
-	    time_t     reality_delta;
-	    time_t     now;
-
-
-	    /*
-	     * Convert to GMT for sites that distribute localtime.  This
-	     * means we have to figure out what day it is.  Easier said
-	     * than done...
-	     */
-
-	    memset(&asserted_tm, 0, sizeof(asserted_tm));
-
-	    asserted_tm.tm_year  = up->ymd.tm_year;
-	    asserted_tm.tm_mon   = up->ymd.tm_mon;
-	    asserted_tm.tm_mday  = up->ymd.tm_mday;
-	    asserted_tm.tm_hour  = hours;
-	    asserted_tm.tm_min   = minutes;
-	    asserted_tm.tm_sec   = seconds;
-	    asserted_tm.tm_isdst = -1;
-
-	    asserted_time = mktime (&asserted_tm);
-	    time(&now);
-	    reality_delta = asserted_time - now;
-
-	    /*
-	     * We assume that if the time is grossly wrong, it's because we got the
-	     * year/month/day wrong.
-	     */
-	    if (reality_delta > INSANE_SECONDS)
-	    {
-		asserted_time -= SECSPERDAY; /* local clock behind real time */
-	    }
-	    else if (-reality_delta > INSANE_SECONDS)
-	    {
-		asserted_time += SECSPERDAY; /* local clock ahead of real time */
-	    }
-	    lt_p = localtime_r(&asserted_time, &tmbuf);
-	    if (lt_p)
-	    {
-		up->ymd = *lt_p;
-	    }
-	    else
-	    {
-		refclock_report (peer, CEVNT_FAULT);
-		return;
-	    }
-
-	    if ((gmtp = gmtime_r (&asserted_time, &mygm)) == NULL)
-	    {
-		refclock_report (peer, CEVNT_FAULT);
-		return;
-	    }
-	    adjyear = gmtp->tm_year+1900;
-	    adjmon  = gmtp->tm_mon+1;
-	    pp->day = ymd2yd (adjyear, adjmon, gmtp->tm_mday);
-	    pp->hour   = gmtp->tm_hour;
-	    pp->minute = gmtp->tm_min;
-	    pp->second = gmtp->tm_sec;
-#ifdef DEBUG
-	    if (debug)
-		printf ("time is %04d/%02d/%02d %02d:%02d:%02d UTC\n",
-			adjyear,adjmon,gmtp->tm_mday,pp->hour,pp->minute,
-			pp->second);
-#endif
-
-	    got_good=1;
-	}
-
-	if (!got_good)
-	{
-	    if (up->linect > 0)
-	    	up->linect--;
-	    else
-	    	refclock_report(peer, CEVNT_BADREPLY);
-	    return;
-	}
-
-	/*
-	 * Process the new sample in the median filter and determine the
-	 * timecode timestamp.
-	 */
-	if (!refclock_process(pp)) {
-		refclock_report(peer, CEVNT_BADTIME);
-		return;
-	}
-	pp->lastref = pp->lastrec;
-	refclock_receive(peer);
-	record_clock_stats(peer, pp->a_lastcode);
-	up->lasthour = (uint8_t)pp->hour;
-}
-


=====================================
wafhelpers/refclock.py
=====================================
--- a/wafhelpers/refclock.py
+++ b/wafhelpers/refclock.py
@@ -97,12 +97,6 @@ refclock_map = {
         "file":     "jupiter"
     },
 
-    "dumbclock": {
-        "descr":    "Dumb Clock",
-        "define":   "CLOCK_DUMBCLOCK",
-        "file":     "dumbclock"
-    },
-
     "jjy": {
         "descr":    "JJY Receivers",
         "define":   "CLOCK_JJY",



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/20b6dc79ba820575e7fc5f5ba008c0131e3e7ec1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170130/8b3960c5/attachment.html>


More information about the vc mailing list