[ntp:bk-ntp-dev-send] BitKeeper diffs

Harlan Stenn stenn at whimsy.udel.edu
Sat Aug 5 20:31:58 UTC 2006


#### ChangeSet ####
2006-08-05 09:01:42+00:00, kardel at pogo.udel.edu 
  driver8.html:
    document additional Meinberg clock mode
    document optionally separate PPS device (/dev/refclockpps-{0..3})
  refclock_parse.c:
    support optionally separate PPS devices via /dev/refclockpps-{0..3}

==== html/drivers/driver8.html ====
2006-08-05 08:59:00+00:00, kardel at pogo.udel.edu +12 -9
  document additional Meinberg clock mode
  document optionally separate PPS device (/dev/refclockpps-{0..3})

--- 1.18/html/drivers/driver8.html	2006-08-05 16:32:02 -04:00
+++ 1.19/html/drivers/driver8.html	2006-08-05 16:32:02 -04:00
@@ -15,9 +15,10 @@
 		Address: 127.127.8.<i>u</i><br>
 		Reference ID: <tt>PARSE</tt><br>
 		Driver ID: <tt>GENERIC</tt><br>
-		Serial Port: <tt>/dev/refclock-<i>u</i></tt>; TTY mode according to clock type
+		Serial Port: <tt>/dev/refclock-<i>u</i></tt>; TTY mode according to clock type<br>
+                PPS device: <tt>/dev/refclockpps-<i>u</i></tt>; alternate PPS device (if not available via the serial port)
 		<h4>Description</h4>
-		The PARSE driver supports 17 different clockes types/configurations. PARSE is actually a multi clock driver.<br>
+		The PARSE driver supports 19 different clock types/configurations. PARSE is actually a multi clock driver.<br>
 		<br>
 		<p>The actual receiver status is mapped into various synchronization states generally used by receivers. The driver is configured to interpret the time codes of DCF C51, PZF535, PZF509, GPS16x, Trimble SV6 GPS, ELV DCF7000, Schmid, Wharton 400A and low cost receivers (see list below).</p>
 		<p>The reference clock support in ntp contains the necessary configuration tables for those receivers. In addition to supporting several different clock types and 4 devices, the generation a a PPS signal is also provided as an configuration option. The PPS configuration option uses the receiver generated time stamps for feeding the PPS loopfilter control for much finer clock synchronization.</p>
@@ -26,12 +27,10 @@
 		<h4>ntpq (8)</h4>
 		<h5>timecode variable</h5>
 		<p>The ntpq program can read clock variables command list several variables. These hold the following information: refclock_time is the local time with the offset to UTC (format HHMM). The currently active receiver flags are listed in refclock_status. Additional feature flags of the receiver are optionally listed in parentheses. The actual time code is listed in timecode. A qualification of the decoded time code format is following in refclock_format. The last piece of information is the overall running time and the accumulated times for the clock event states in refclock_states. When PPS information is present additional variable are available. refclock_ppstime lists then the PPS timestamp and refclock_ppsskew lists the difference between RS232 derived timestamp and the PPS timestamp.</p>
-		<p>Currently, eighteen clock types (devices /dev/refclock-0 - /dev/refclock-3) are supported by the PARSE driver.<br>
+		<p>Currently, nineteen clock types (devices /dev/refclock-0 - /dev/refclock-3) are supported by the PARSE driver.<br>
 			A note on the implementations:</p>
 		<ul>
-			<li>These implementations where mainly done <b><i>WITHOUT</i></b> actual access to the hardware. Thus not all implementations provide full support. The development was done with the help of many kind souls who had the hardware and where so kind to borrow me their time an patience during the development and debugging cycle. Thus for continued support and quality direct access to the receivers is a big help. Nevertheless i am not prepared to buy these reference clocks - donations to <a href="http://www4.informatik.uni-erlangen.de/%7ekardel">me</a> (<a href="mailto:kardel <AT> acm.org">kardel 
-					<AT>
-					ntp.org</a>) are welcome as long as they work within Europe 8-).
+			<li>These implementations where mainly done <b><i>WITHOUT</i></b> actual access to the hardware. Thus not all implementations provide full support. The development was done with the help of many kind souls who had the hardware and where so kind to borrow me their time an patience during the development and debugging cycle. Thus for continued support and quality direct access to the receivers is a big help. Nevertheless i am not prepared to buy these reference clocks - donations to (<a href="mailto:kardel <AT> ntp.org">kardel &lt;AT&gt; ntp.org</a>) are welcome as long as they work within Europe 8-).
 				<p>Verified implementations are:</p>
 				<ul>
 					<li>RAWDCF variants
@@ -99,10 +98,13 @@
 				<p><b><tt>RAWDCF receiver (DTR=low/RTS=high) </tt></b></p>
 			<li><b><tt>server 127.127.8.0-3 mode 17</tt></b>
 				<p><b><tt>VARITEXT Receiver (MSF) </tt></b></p>
+			<li><b><tt>server 127.127.8.0-3 mode 18</tt></b>
+				<p><b><tt><a href="http://www.meinberg.de">Meinberg </a><a href="http://www.meinberg.de/english/products/gps167.htm">GPS166/GPS167 receiver</a> (GPS / &lt;&lt;1us) without additional data communication (version, GPS status etc) for multi drop, heterogenous multi client operation</tt></b><br>
+				</p>
 		</ul>
 		<p>Actual data formats and set-up requirements of the various clocks can be found in <a href="../parsedata.html">NTP PARSE clock data formats</a>.</p>
 		<p>The reference clock support carefully monitors the state transitions of the receiver. All state changes and exceptional events such as loss of time code transmission are logged via the syslog facility. Every hour a summary of the accumulated times for the clock states is listed via syslog.</p>
-		<p>PPS support is only available when the receiver is completely synchronized. The receiver is believed to deliver correct time for an additional period of time after losing synchronizations, unless a disruption in time code transmission is detected (possible power loss). The trust period is dependent on the receiver oscillator and thus a function of clock type. This is one of the parameters in the clockinfo field of the reference clock implementation. This parameter cannot be configured by ntpdc.</p>
+		<p>PPS support is only available when the receiver is completely synchronized. The receiver is believed to deliver correct time for an additional period of time after losing synchronizations, unless a disruption in time code transmission is detected (possible power loss). The trust period is dependent on the receiver oscillator and thus a function of clock type.</p>
 		<br>
 		<p>For the Meinberg GPS166/GPS167 receiver is also a special firmware release available (Uni-Erlangen). This release should be used for proper operation.</p>
 		<p>The raw DCF77 pulses can be fed via a level converter directly into Pin 3 (Rx) of the Sun. The telegrams will be decoded an used for synchronization. AM DCF77 receivers are running as low as $25. The accuracy is dependent on the receiver and is somewhere between 2ms (expensive) to 10ms (cheap). Upon bad signal reception of DCF77 synchronizations will cease as no backup oscillator is available as usually found in other reference clock receivers. So it is important to have a good place for the DCF77 antenna. For transmitter shutdowns you are out of luck unless you have other NTP servers with alternate time sources available.</p>
@@ -111,6 +113,7 @@
 		<h4>Hardware PPS support<br>
 		</h4>
 		<p>For PPS to be used you MUST add 128 to the mode parameter.</p>
+                <p>If the PPS signal is fed in on device different from the device providing the serial communication (/dev/refclock-{0..3}) this device is configured as /dev/refclockpps-{0..3}. This allows to feed in PPS information e.g. via the parallel port (if supported by the underlying operation system) and handle the communication via the serial port.</p> 
 		<h4>Monitor Data</h4>
 		<p>Clock states statistics are written hourly the the syslog service. Online information can be found by examining the clock variable via the ntpq cv command.<br>
 			Some devices have quite extensive addtional information (GPS16x, Trimble). The driver reads out much of the internal GPS data<br>
@@ -219,7 +222,7 @@
 		</dl>
 		<span style="font-weight: bold;">Note about auxiliary SUN STREAMS modules (SunOS and Solaris):</span><br>
 		<dl>
-			<dt>The timecode of these receivers used to be sampled via a STREAMS module in the kernel (The STREAMS module has been designed for use with SUN Systems under SunOS 4.1.x or Solaris 2.3 - 2.8. It can be linked directly into the kernel or loaded via the loadable driver mechanism). This STREAMS module can be adapted to be able to convert different time code formats. Today the PPSAPI mechanism can be used. There is no real need for the STREAMS modules any more.<br>
+			<dt>The timecode of these receivers can be sampled via a STREAMS module in the kernel (The STREAMS module has been designed for use with SUN Systems under SunOS 4.1.x or Solaris 2.3 - 2.8. It can be linked directly into the kernel or loaded via the loadable driver mechanism). This STREAMS module can be adapted to be able to convert different time code formats. Today usually the PPSAPI mechanism is used.<br>
 		</dl>
 		<h4>Making your own PARSE clocks</h4>
 		<p>The parse clock mechanismis deviated from the way other ntp reference clocks work. For a short description how to build parse reference clocks see <a href="../parsenew.html">making PARSE clocks</a></p>
@@ -229,4 +232,4 @@
 		<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
 	</body>
 
-</html>
\ No newline at end of file
+</html>

==== ntpd/refclock_parse.c ====
2006-08-05 08:58:19+00:00, kardel at pogo.udel.edu +57 -29
  support optionally separate PPS devices via /dev/refclockpps-{0..3}

--- 1.45/ntpd/refclock_parse.c	2006-08-05 16:32:02 -04:00
+++ 1.46/ntpd/refclock_parse.c	2006-08-05 16:32:02 -04:00
@@ -1,7 +1,7 @@
 /*
- * /src/NTP/REPOSITORY/ntp4-dev/ntpd/refclock_parse.c,v 4.76 2006/06/22 18:40:47 kardel RELEASE_20060622_A
+ * /src/NTP/REPOSITORY/ntp4-dev/ntpd/refclock_parse.c,v 4.77 2006/08/05 07:44:49 kardel RELEASE_20060805_A
  *
- * refclock_parse.c,v 4.76 2006/06/22 18:40:47 kardel RELEASE_20060622_A
+ * refclock_parse.c,v 4.77 2006/08/05 07:44:49 kardel RELEASE_20060805_A
  *
  * generic reference clock driver for several DCF/GPS/MSF/... receivers
  *
@@ -182,7 +182,7 @@
 #include "ieee754io.h"
 #include "recvbuff.h"
 
-static char rcsid[] = "refclock_parse.c,v 4.76 2006/06/22 18:40:47 kardel RELEASE_20060622_A";
+static char rcsid[] = "refclock_parse.c,v 4.77 2006/08/05 07:44:49 kardel RELEASE_20060805_A";
 
 /**===========================================================================
  ** external interface to ntp mechanism
@@ -208,6 +208,7 @@ struct	refclock refclock_parse = {
  */
 #define	MAXUNITS	4	/* maximum number of "PARSE" units permitted */
 #define PARSEDEVICE	"/dev/refclock-%d" /* device to open %d is unit number */
+#define PARSEPPSDEVICE	"/dev/refclockpps-%d" /* optional pps device to open %d is unit number */
 
 #undef ABS
 #define ABS(_X_) (((_X_) < 0) ? -(_X_) : (_X_))
@@ -396,6 +397,7 @@ struct parseunit
         double        ppsphaseadjust;   /* phase adjustment of PPS time stamp */
         u_long        lastmissed;       /* time (ntp) when poll didn't get data (powerup heuristic) */
 	u_long        ppsserial;        /* magic cookie for ppsclock serials (avoids stale ppsclock data) */
+	int	      ppsfd;	        /* fd to ise for PPS io */
 #ifdef HAVE_PPSAPI
         pps_handle_t  ppshandle;        /* store PPSAPI handle */
         pps_params_t  ppsparams;        /* current PPS parameters */
@@ -1628,8 +1630,8 @@ ppsclock_init(
 	 * now push the parse streams module
 	 * it will ensure exclusive access to the device
 	 */
-	if (ioctl(parse->generic->io.fd, I_PUSH, (caddr_t)m1) == -1 &&
-	    ioctl(parse->generic->io.fd, I_PUSH, (caddr_t)m2) == -1)
+	if (ioctl(parse->ppsfd, I_PUSH, (caddr_t)m1) == -1 &&
+	    ioctl(parse->ppsfd, I_PUSH, (caddr_t)m2) == -1)
 	{
 		if (errno != EINVAL)
 		{
@@ -1640,7 +1642,7 @@ ppsclock_init(
 	}
 	if (!local_init(parse))
 	{
-		(void)ioctl(parse->generic->io.fd, I_POP, (caddr_t)0);
+		(void)ioctl(parse->ppsfd, I_POP, (caddr_t)0);
 		return 0;
 	}
 
@@ -2110,7 +2112,7 @@ local_input(
 #ifdef TIOCDCDTIMESTAMP
 				struct timeval dcd_time;
 				
-				if (ioctl(rbufp->fd, TIOCDCDTIMESTAMP, &dcd_time) != -1)
+				if (ioctl(parse->ppsfd, TIOCDCDTIMESTAMP, &dcd_time) != -1)
 				{
 					l_fp tstmp;
 					
@@ -2124,7 +2126,7 @@ local_input(
 						{
 							printf(
 							       "parse: local_receive: fd %d DCDTIMESTAMP %s\n",
-							       rbufp->fd,
+							       parse->ppsfd,
 							       lfptoa(&tstmp, 6));
 							printf(" sigio %s\n",
 							       lfptoa(&ts.fp, 6));
@@ -2142,10 +2144,10 @@ local_input(
 				    struct ppsclockev ev;
 
 #ifdef HAVE_CIOGETEV
-				    if (ioctl(parse->generic->io.fd, CIOGETEV, (caddr_t)&ev) == 0)
+				    if (ioctl(parse->ppsfd, CIOGETEV, (caddr_t)&ev) == 0)
 #endif
 #ifdef HAVE_TIOCGPPSEV
-				      if (ioctl(parse->generic->io.fd, TIOCGPPSEV, (caddr_t)&ev) == 0)
+				    if (ioctl(parse->ppsfd, TIOCGPPSEV, (caddr_t)&ev) == 0)
 #endif
 					{
 					  if (ev.serial != parse->ppsserial)
@@ -2170,11 +2172,10 @@ local_input(
 				  }
 #endif
 #endif /* TIOCDCDTIMESTAMP */
-#endif /* HAVE_PPSAPI */
+#endif /* !HAVE_PPSAPI */
 			}
-
-  			if (count)
-  			{	/* simulate receive */
+			if (count)
+			{	/* simulate receive */
 				buf = get_free_recv_buffer();
 				if (buf != NULL) {
 					memmove((caddr_t)buf->recv_buffer,
@@ -2189,8 +2190,8 @@ local_input(
 					buf->X_from_where = rbufp->X_from_where;
 					add_full_recv_buffer(buf);
 				}
-  				parse_iodone(&parse->parseio);
-  			}
+				parse_iodone(&parse->parseio);
+			}
 			else
 			{
 				memmove((caddr_t)rbufp->recv_buffer,
@@ -2589,6 +2590,8 @@ parse_shutdown(
 		(void)time_pps_destroy(parse->ppshandle);
 	}
 #endif
+	if (parse->generic->io.fd != parse->ppsfd && parse->ppsfd != -1)
+		(void)close(parse->ppsfd);  /* close separate PPS source */
 
 	/*
 	 * print statistics a last time and
@@ -2650,7 +2653,7 @@ parse_hardpps(
 				CLK_UNIT(parse->peer));
 		} else {
 		        NLOG(NLOG_CLOCKINFO)
-		                msyslog(LOG_INFO, "PARSE receiver #%d: HARDPPS %sabled",
+		                msyslog(LOG_INFO, "PARSE receiver #%d: kernel PPS synchronisation %sabled",
 					CLK_UNIT(parse->peer), (mode == PARSE_HARDPPS_ENABLE) ? "en" : "dis");
 			/*
 			 * tell the rest, that we have a kernel PPS source, iff we ever enable HARDPPS
@@ -2767,6 +2770,7 @@ parse_start(
 #endif
 	struct parseunit * parse;
 	char parsedev[sizeof(PARSEDEVICE)+20];
+	char parseppsdev[sizeof(PARSEPPSDEVICE)+20];
 	parsectl_t tmp_ctl;
 	u_int type;
 
@@ -2794,6 +2798,7 @@ parse_start(
 	 * Unit okay, attempt to open the device.
 	 */
 	(void) snprintf(parsedev, sizeof(parsedev), PARSEDEVICE, unit);
+	(void) snprintf(parseppsdev, sizeof(parsedev), PARSEPPSDEVICE, unit);
 
 #ifndef O_NOCTTY
 #define O_NOCTTY 0
@@ -2831,6 +2836,7 @@ parse_start(
 	parse->timedata.parse_status = (unsigned short)~0;	/* be sure to mark initial status change */
 	parse->lastmissed     = 0;	/* assume got everything */
 	parse->ppsserial      = 0;
+	parse->ppsfd	      = -1;
 	parse->localdata      = (void *)0;
 	parse->localstate     = 0;
 	parse->kv             = (struct ctl_var *)0;
@@ -2921,13 +2927,29 @@ parse_start(
 		tio.c_cflag     |= parse_clockinfo[type].cl_speed;
 #endif
 
+		/*
+		 * set up pps device
+		 * if the PARSEPPSDEVICE can be opened that will be used
+		 * for PPS else PARSEDEVICE will be used
+		 */
+		parse->ppsfd = open(parseppsdev, O_RDWR | O_NOCTTY
+#ifdef O_NONBLOCK
+				    | O_NONBLOCK
+#endif
+				    , 0777);
+
+		if (parse->ppsfd == -1)
+		{
+			parse->ppsfd = fd232;
+		}
+
 /*
  * Linux PPS - the old way
  */
 #if defined(HAVE_TIO_SERIAL_STUFF)		/* Linux hack: define PPS interface */
 		{
 			struct serial_struct	ss;
-			if (ioctl(fd232, TIOCGSERIAL, &ss) < 0 ||
+			if (ioctl(parse->ppsfd, TIOCGSERIAL, &ss) < 0 ||
 			    (
 #ifdef ASYNC_LOW_LATENCY
 			     ss.flags |= ASYNC_LOW_LATENCY,
@@ -2937,8 +2959,8 @@ parse_start(
 			     ss.flags |= ASYNC_PPS_CD_NEG,
 #endif
 #endif
-			     ioctl(fd232, TIOCSSERIAL, &ss)) < 0) {
-				msyslog(LOG_NOTICE, "refclock_parse: TIOCSSERIAL fd %d, %m", fd232);
+			     ioctl(parse->ppsfd, TIOCSSERIAL, &ss)) < 0) {
+				msyslog(LOG_NOTICE, "refclock_parse: TIOCSSERIAL fd %d, %m", parse->ppsfd);
 				msyslog(LOG_NOTICE,
 					"refclock_parse: optional PPS processing not available");
 			} else {
@@ -2960,7 +2982,7 @@ parse_start(
 		    {
 			int i = 1;
 		    
-			if (ioctl(fd232, TIOCSPPS, (caddr_t)&i) == 0)
+			if (ioctl(parse->ppsfd, TIOCSPPS, (caddr_t)&i) == 0)
 			    {
 				parse->flags |= PARSE_PPSCLOCK;
 			    }
@@ -2974,7 +2996,7 @@ parse_start(
 		parse->hardppsstate = PARSE_HARDPPS_DISABLE;
 		if (CLK_PPS(parse->peer))
 		{
-		  if (time_pps_create(fd232, &parse->ppshandle) < 0) 
+		  if (time_pps_create(parse->ppsfd, &parse->ppshandle) < 0) 
 		    {
 		      msyslog(LOG_NOTICE, "PARSE receiver #%d: parse_start: could not set up PPS: %m", CLK_UNIT(parse->peer));
 		    }
@@ -3099,13 +3121,14 @@ parse_start(
 	NLOG(NLOG_CLOCKINFO)
 		{
 			/* conditional if clause for conditional syslog */
-			msyslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" (device %s) added",
+			msyslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" (I/O device %s, PPS device %s) added",
 				CLK_UNIT(parse->peer),
-				parse->parse_type->cl_description, parsedev);
+				parse->parse_type->cl_description, parsedev,
+				(parse->ppsfd != parse->generic->io.fd) ? parseppsdev : parsedev);
 
-			msyslog(LOG_INFO, "PARSE receiver #%d: Stratum %d, %sPPS support, trust time %s, precision %d",
+			msyslog(LOG_INFO, "PARSE receiver #%d: Stratum %d, trust time %s, precision %d",
 				CLK_UNIT(parse->peer),
-				parse->peer->stratum, CLK_PPS(parse->peer) ? "" : "no ",
+				parse->peer->stratum,
 				l_mktime(parse->maxunsync), parse->peer->precision);
 
 			msyslog(LOG_INFO, "PARSE receiver #%d: rootdelay %.6f s, phase adjustment %.6f s, PPS phase adjustment %.6f s, %s IO handling",
@@ -3117,13 +3140,15 @@ parse_start(
 
 			msyslog(LOG_INFO, "PARSE receiver #%d: Format recognition: %s", CLK_UNIT(parse->peer),
 				parse->parse_type->cl_format);
-                        msyslog(LOG_INFO, "PARSE receiver #%d: %sPPS ioctl support%s", CLK_UNIT(parse->peer),
-				(parse->flags & PARSE_PPSCLOCK) ? "" : "NO ",
+                        msyslog(LOG_INFO, "PARSE receiver #%d: %sPPS support%s", CLK_UNIT(parse->peer),
+				CLK_PPS(parse->peer) ? "" : "NO ",
+				CLK_PPS(parse->peer) ?
 #ifdef PPS_METHOD
-				" (interface is " PPS_METHOD ")"
+				" (implementation " PPS_METHOD ")"
 #else
 				""
 #endif
+				: ""
 				);
 		}
 
@@ -5682,6 +5707,9 @@ int refclock_parse_bs;
  * History:
  *
  * refclock_parse.c,v
+ * Revision 4.77  2006/08/05 07:44:49  kardel
+ * support optionally separate PPS devices via /dev/refclockpps-{0..3}
+ *
  * Revision 4.76  2006/06/22 18:40:47  kardel
  * clean up signedness (gcc 4)
  *


More information about the bk-ntp-dev-send mailing list