[LinuxPPS] trying to get the atom clock to work

Folkert van Heusden folkert at vanheusden.com
Sun Jan 13 18:43:29 CET 2008


Hi,

Trying to get the atom reference clock to work. It seems it needs some
tweaks. So far I got it to open and setup pps only while running I see
constant overflows making ntp ignore the device. This is odd as the
system is synced to a reference clock as well.
Patch so far:

diff -uNrBbd ntp-4.2.4p4+dfsg.org/ntpd/refclock_atom.c ntp-4.2.4p4+dfsg/ntpd/refclock_atom.c
--- ntp-4.2.4p4+dfsg.org/ntpd/refclock_atom.c	2006-06-06 22:16:48.000000000 +0200
+++ ntp-4.2.4p4+dfsg/ntpd/refclock_atom.c	2008-01-13 18:33:25.000000000 +0100
@@ -176,6 +176,7 @@
 	 * not necessarily the port used for the associated radio.
 	 */
 	sprintf(device, DEVICE, unit);
+	msyslog(LOG_INFO, "ATOM: Opening device %s", device);
 	up->fddev = open(device, O_RDWR, 0777);
 	if (up->fddev <= 0) {
 		msyslog(LOG_ERR,
@@ -186,7 +187,8 @@
 	/*
 	 * Light off the PPSAPI interface.
 	 */
-	if (time_pps_create(up->fddev, &up->handle) < 0) {
+	msyslog(LOG_INFO, "ATOM: light of the ppsapi interface");
+	if (time_pps_create(pp -> io.fd, &up->handle) < 0) {
 		msyslog(LOG_ERR,
 		    "refclock_atom: time_pps_create failed: %m");
 		return (0);
@@ -275,7 +277,7 @@
 
 	pp = peer->procptr;
 	up = (struct ppsunit *)pp->unitptr;
-	if (up->handle == 0)
+	if (up->handle == -1)
 		return (0);
 
 	if (time_pps_getcap(up->handle, &capability) < 0) {
@@ -284,7 +286,7 @@
 		return (0);
 	}
 	memset(&up->pps_params, 0, sizeof(pps_params_t));
-	up->pps_params.api_version = PPS_API_VERS_1;
+	up->pps_params.api_version = PPS_API_VERS;
 	up->pps_params.mode = mode | PPS_TSFMT_TSPEC;
 	if (time_pps_setparams(up->handle, &up->pps_params) < 0) {
 		msyslog(LOG_ERR,
@@ -345,7 +347,7 @@
 	 */ 
 	pp = peer->procptr;
 	up = (struct ppsunit *)pp->unitptr;
-	if (up->handle == 0)
+	if (up->handle == -1)
 		return;
 
 	timeout.tv_sec = 0;
@@ -353,6 +355,7 @@
 	memcpy(&pps_info, &up->pps_info, sizeof(pps_info_t));
 	if (time_pps_fetch(up->handle, PPS_TSFMT_TSPEC, &up->pps_info,
 	    &timeout) < 0) {
+	    msyslog(LOG_INFO, "time_ppfs_fetch failed");
 		refclock_report(peer, CEVNT_FAULT);
 		return;
 	}
@@ -362,6 +365,7 @@
 		ts = up->pps_info.clear_timestamp;
 	} else {
 		refclock_report(peer, CEVNT_FAULT);
+	    msyslog(LOG_INFO, "neither PPS_CAPTUREASSERT nor PPS_CAPTURECLEAR are set");
 		return;
 	}
 
@@ -393,10 +397,15 @@
 		nsec -= NANOSECOND;
 	}
 	if (sec * NANOSECOND + nsec > NANOSECOND + RANGEGATE)
+	{
+	    msyslog(LOG_INFO, "range overflow %ld", sec * NANOSECOND + nsec);
 		return;
-
+	}
 	else if (sec * NANOSECOND + nsec < NANOSECOND - RANGEGATE)
+	{
+	    msyslog(LOG_INFO, "range underflow %ld", sec * NANOSECOND + nsec);
 		return;
+	}
 
 	pp->lastrec.l_ui = ts.tv_sec + JAN_1970;
 	dtemp = ts.tv_nsec * FRAC / 1e9;
@@ -411,6 +420,7 @@
 		sprintf(tbuf, "%.9f", dtemp);
 		record_clock_stats(&peer->srcadr, tbuf);
 	}
+	msyslog(LOG_INFO, "atom_timer: %lu %f %f\n", current_time, dtemp, pp->fudgetime1);
 #ifdef DEBUG
 	if (debug > 1)
 		printf("atom_timer: %lu %f %f\n", current_time,



Folkert van Heusden

-- 
MultiTail är en flexibel redskap för att fälja logfilar, utför av
commandoer, filtrera, ge färg, sammanfoga, o.s.v. följa.
http://www.vanheusden.com/multitail/
----------------------------------------------------------------------
Phone: +31-6-41278122, PGP-key: 1F28D8AE, www.vanheusden.com



More information about the LinuxPPS mailing list