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

Harlan Stenn stenn at whimsy.udel.edu
Sun Jan 9 06:54:49 UTC 2005


This BitKeeper patch contains the following changesets:
stenn at pogo.udel.edu|ChangeSet|20050109065012|41492
abe at pogo.udel.edu|ChangeSet|20041221130252|41500
abe at pogo.udel.edu|ChangeSet|20041222151217|41500
abe at pogo.udel.edu|ChangeSet|20041218045509|41550
abe at pogo.udel.edu|ChangeSet|20050107131442|41502

# This is a BitKeeper patch.  What follows are the unified diffs for the
# set of deltas contained in the patch.  The rest of the patch, the part
# that BitKeeper cares about, is below these diffs.
# ID:	stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
# User:	stenn
# Host:	whimsy.udel.edu
# Root:	/deacon/backroom/ntp-dev

#
#--- 1.50/BitKeeper/etc/logging_ok	2004-08-09 06:38:31 -04:00
#+++ 1.51/BitKeeper/etc/logging_ok	2004-12-17 23:55:08 -05:00
#@@ -1,4 +1,5 @@
# a115350 at y3111429.nh.ad.hydro.com
#+abe at pogo.udel.edu
# blk at frobozz.local
# blu at corwin.
# blu at jedi.east.sun.com
#
#--- 1.11/html/drivers/driver40.html	2004-11-21 21:32:56 -05:00
#+++ 1.12/html/drivers/driver40.html	2004-12-17 23:43:20 -05:00
#@@ -1,6 +1,6 @@
# <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
# 
#-<html>
#+<html lang ="en">
# 
#     <head>
#         <meta name="generator" content="HTML Tidy, see www.w3.org">
#@@ -11,14 +11,17 @@
#     <body>
#         <h3>JJY Receivers</h3>
#         <hr>
#+
#         <h4>Synopsis</h4>
#         Address: 127.127.40.<i>u</i><br>
#         Reference ID: <tt>JJY</tt><br>
#         Driver ID: <tt>JJY</tt><br>
#         Serial Port: <tt>/dev/jjy<i>u</i></tt>; 9600 baud, 8-bits, no parity, 1 stop bit
#+
#         <h4>Description</h4>
#         <p>This driver supports the following JJY receivers sold in Japan.</p>
#         <ul>
#+
#             <li>Tristate Ltd. JJY01 <a href="http://www.tristate.ne.jp/">http://www.tristate.ne.jp/</a> (Japanese only)<br>
#             <dl>
#                 <dt>Time code format
#@@ -43,9 +46,11 @@
#                 <br>
#                 <dt>NTP configuration ( ntp.conf )
#                 <dd>
#-                <p>server 127.127.40.X mode 1</p>
#+                <p>server &nbsp; 127.127.40.X &nbsp; mode 1</p>
#                 <br>
#             </dl>
#+</li>
#+
#             <li>C-DEX Co.,Ltd. JST2000 <a href="http://www.c-dex.co.jp/">http://www.c-dex.co.jp/</a> (Japanese only)<br>
#             <dl>
#                 <dt>Time code format
#@@ -65,16 +70,53 @@
#                 <br>
#                 <dt>NTP configuration ( ntp.conf )
#                 <dd>
#-                <p>server 127.127.40.X mode 2</p>
#+                <p>server &nbsp; 127.127.40.X &nbsp; mode 2</p>
#                 <br>
#             </dl>
#+</li>
#+
#+<li><p>Echo Keisokuki Co.,Ltd. LT-2000 <a href="http://www.clock.co.jp/">http://www.clock.co.jp/</a> (Japanese only)</p>
#+<dl>
#+<dt>Time code format</dt>
#+<dd><br>
#+<table summary="CommandAndReply">
#+<tr>
#+<td>Command</td><td>&nbsp;</td><td>Reply</td>
#+</tr>
#+<tr>
#+<td><code>C</code></td>
#+<td></td>
#+<td>( Mode 2 : Continuous ) </td>
#+</tr>
#+<tr>
#+<td></td>
#+<td></td>
#+<td><code>YYMMDDWHHMMSS&lt;ST1&gt;&lt;ST2&gt;&lt;ST3&gt;&lt;ST4&gt;&lt;CR&gt;</code></td>
#+</tr>
#+<tr>
#+<td><code>#</code></td>
#+<td></td>
#+<td>( Mode 1 : Request&Send )</td>
#+</tr>
#+</table>
#+<br>
#+</dd>
#+<dt>NTP configuration ( ntp.conf )</dt>
#+<dd>
#+<p>server &nbsp; 127.127.40.X &nbsp; mode 3</p>
#+</dd>
#+</dl>
#+</li>
#+
#         </ul>
#-        <p>JJY is the radio station which transmites the JST (Japan Standard Time) in long wave radio. The station JJY is operated by the National Institute of Information and Communications Technology. An operating announcement and some information are avaiable from <a href="http://www.crl.go.jp/">http://www.nict.go.jp/</a> (English and Japanese) and <a href="http://jjy.crl.go.jp/">http://jjy.nict.go.jp/</a> (English and Japanese)</p>
#+        <p>JJY is the radio station which transmites the JST (Japan Standard Time) in long wave radio. The station JJY is operated by the National Institute of Information and Communications Technology. An operating announcement and some information are avaiable from <a href="http://www.nict.go.jp/">http://www.nict.go.jp/</a> (English and Japanese) and <a href="http://jjy.nict.go.jp/">http://jjy.nict.go.jp/</a> (English and Japanese)</p>
#         <p>The user is expected to provide a symbolic link to an available serial port device. This is typically performed by a command such as:</p>
#         <p><tt>ln -s /dev/ttyS0 /dev/jjy0</tt></p>
#         <p>Windows NT does not support symbolic links to device files. COM<i>X</i>: is the unit used by the driver, based on the refclock unit number, where unit 1 corresponds to COM1: and unit 3 corresponds to COM3:</p>
#+
#         <h4>Monitor Data</h4>
#         <p>The driver writes each timecode as received to the <tt>clockstats</tt> file.</p>
#+
#         <h4>Fudge Factors</h4>
#         <dl>
#             <dt><tt>time1 <i>time</i></tt>
#
#--- 1.11/ntpd/refclock_jjy.c	2004-11-21 21:32:56 -05:00
#+++ 1.12/ntpd/refclock_jjy.c	2004-12-17 23:42:11 -05:00
#@@ -4,7 +4,7 @@
# 
# /**********************************************************************/
# /*                                                                    */
#-/*  Copyright (C) 2001, Takao Abe.  All rights reserved.              */
#+/*  Copyright (C) 2001-2004, Takao Abe.  All rights reserved.         */
# /*                                                                    */
# /*  Permission to use, copy, modify, and distribute this software     */
# /*  and its documentation for any purpose is hereby granted           */
#@@ -67,6 +67,9 @@
# /*             JJY-01 ( Firmware version 2.01 )                       */
# /*             Thanks to Andy Taki for testing under FreeBSD          */
# /*                                                                    */
#+/*  2004/11/28                                                        */
#+/*    [Add]    Support the Echo Keisokuki LT-2000 receiver            */
#+/*                                                                    */
# /**********************************************************************/
# 
# #ifdef HAVE_CONFIG_H
#@@ -112,6 +115,18 @@
# /*  <ENQ>1J<ETX>   <STX>JYYMMDD HHMMSSS<ETX>                          */
# /*                                                                    */
# /**********************************************************************/
#+/*                                                                    */
#+/*  The Echo Keisokuki Co. Ltd. JJY receiver LT2000                   */
#+/*                                                                    */
#+/*  Command        Response                 Remarks                   */
#+/*  ------------   ----------------------   ---------------------     */
#+/*  #                                       Mode 1 (Request&Send)     */
#+/*  T              YYMMDDWHHMMSS<BCC1><BCC2><CR>                      */
#+/*  C                                       Mode 2 (Continuous)       */
#+/*                 YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR>              */
#+/*                 <SUB>                    Second signal             */
#+/*                                                                    */
#+/**********************************************************************/
# 
# /*
#  * Interface definitions
#@@ -126,7 +141,8 @@
#  * JJY unit control structure
#  */
# struct jjyunit {
#-	char	unittype ;	/* UNITTYPE_XXXXXXXXXX */
#+	char	unittype ;          /* UNITTYPE_XXXXXXXXXX */
#+    short   operationmode ;     /* Echo Keisokuki LT-2000 : 1 or 2 */
# 	short	version ;
# 	short	linediscipline ;	/* LDISC_CLK or LDISC_RAW */
# 	int 	linecount ;
#@@ -143,6 +159,7 @@
# 
# #define	UNITTYPE_TRISTATE_JJY01	1
# #define	UNITTYPE_CDEX_JST2000  	2
#+#define	UNITTYPE_ECHOKEISOKUKI_LT2000  	3
# 
# /*
#  * Function prototypes
#@@ -152,9 +169,11 @@
# static	void	jjy_poll                    P((int, struct peer *));
# static	void	jjy_poll_tristate_jjy01     P((int, struct peer *));
# static	void	jjy_poll_cdex_jst2000       P((int, struct peer *));
#+static	void	jjy_poll_echokeisokuki_lt2000    P((int, struct peer *));
# static	void	jjy_receive                 P((struct recvbuf *));
# static	int 	jjy_receive_tristate_jjy01  P((struct recvbuf *));
# static	int 	jjy_receive_cdex_jst2000    P((struct recvbuf *));
#+static	int 	jjy_receive_echokeisokuki_lt2000 P((struct recvbuf *));
# 
# /*
#  * Transfer vector
#@@ -217,6 +236,7 @@
# 	case 0 :
# 	case 1 : iDiscipline = LDISC_CLK ; break ;
# 	case 2 : iDiscipline = LDISC_RAW ; break ;
#+	case 3 : iDiscipline = LDISC_CLK ; break ;
# 	default :
# 		msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode",
# 		          ntoa(&peer->srcadr), peer->ttl ) ;
#@@ -261,6 +281,18 @@
# 		up->unittype = UNITTYPE_CDEX_JST2000 ;
# 		up->lineexpect = 1 ;
# 		up->charexpect[0] = 15 ; /* <STX>JYYMMDD HHMMSSS<ETX> */
#+	case 3 :
#+		up->unittype = UNITTYPE_ECHOKEISOKUKI_LT2000 ;
#+		up->operationmode = 2 ;  /* Mode 2 : Continuous mode */
#+		up->lineexpect = 1 ;
#+        switch ( up->operationmode ) {
#+        case 1 :
#+			up->charexpect[0] = 15 ; /* YYMMDDWHHMMSS<BCC1><BCC2><CR> */
#+			break ;
#+		case 2 :
#+			up->charexpect[0] = 17 ; /* YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR> */
#+			break ;
#+		}
# 		break ;
# 	default :
# 		msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode",
#@@ -393,6 +425,10 @@
# 		rc = jjy_receive_cdex_jst2000 ( rbufp ) ;
# 		break ;
# 
#+	case UNITTYPE_ECHOKEISOKUKI_LT2000 :
#+		rc = jjy_receive_echokeisokuki_lt2000 ( rbufp ) ;
#+		break ;
#+
# 	default :
# 		rc = 0 ;
# 		break ;
#@@ -447,10 +483,10 @@
# 	}
# #ifdef DEBUG
# 	if ( debug ) {
#-		printf ( "jjy_receive (refclock_jjy.c) : %04d/%02d/%02d %02d:%02d:%02d JST   ", 
#-		          up->year, up->month, up->day, up->hour, up->minute, up->second ) ;
#-		printf ( "( %04d/%03d %02d:%02d:%02d UTC )\n",
#-		          pp->year, pp->day, pp->hour, pp->minute, pp->second ) ;
#+		printf ( "jjy_receive (refclock_jjy.c) : %04d/%02d/%02d %02d:%02d:%02d.%1d JST   ", 
#+		          up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond/100 ) ;
#+		printf ( "( %04d/%03d %02d:%02d:%02d.%1d UTC )\n",
#+		          pp->year, pp->day, pp->hour, pp->minute, pp->second, (int)(pp->nsec/100000000) ) ;
# 	}
# #endif
# 
#@@ -458,19 +494,19 @@
# 	 * Process the new sample in the median filter and determine the
# 	 * timecode timestamp.
# 	 */
#+
#+	sprintf ( sLogText, "%04d/%02d/%02d %02d:%02d:%02d.%1d JST",
#+	          up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond/100 ) ;
#+	record_clock_stats ( &peer->srcadr, sLogText ) ;
#+
# 	if ( ! refclock_process ( pp ) ) {
# 		refclock_report(peer, CEVNT_BADTIME);
#-		sprintf ( sLogText, "BAD TIME %04d/%02d/%02d %02d:%02d:%02d JST",
#-		          up->year, up->month, up->day, up->hour, up->minute, up->second ) ;
#-		record_clock_stats ( &peer->srcadr, sLogText ) ;
# 		return ;
# 	}
# 
#-	sprintf ( sLogText, "%04d/%02d/%02d %02d:%02d:%02d JST",
#-	          up->year, up->month, up->day, up->hour, up->minute, up->second ) ;
# 	pp->lastref = pp->lastrec;
# 	refclock_receive(peer);
#-	record_clock_stats ( &peer->srcadr, sLogText ) ;
#+
# }
# 
# /**************************************************************************************************/
#@@ -479,6 +515,8 @@
# jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
# {
# 
#+	static	char	*sFunctionName = "jjy_receive_tristate_jjy01" ;
#+
# 	struct jjyunit      *up ;
# 	struct refclockproc *pp ;
# 	struct peer         *peer;
#@@ -504,14 +542,24 @@
# 
# 	switch ( up->linecount ) {
# 
#-	case 1 : /* YYYY/MM/DD */
#+	case 1 : /* YYYY/MM/DD WWW */
# 
#-		if ( iLen < 10 ) {
#+		if ( iLen != 14 ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Reply length error ( up->linecount=%d  iLen=%d )\n", sFunctionName, up->linecount, iLen ) ;
#+	        }
#+#endif
# 			up->lineerror = 1 ;
# 			break ;
# 		}
# 		rc = sscanf ( pBuf, "%4d/%2d/%2d", &up->year, &up->month, &up->day ) ;
# 		if ( rc != 3 || up->year < 2000 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31 ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Date error ( up->linecount=%d )\n", sFunctionName, up->linecount ) ;
#+	        }
#+#endif
# 			up->lineerror = 1 ;
# 			break ;
# 		}
#@@ -521,7 +569,7 @@
# 		 * Following codes are moved from the function jjy_poll_tristate_jjy01 in this source.
# 		 * The Tristate JJY-01 ( Firmware version 1.01 ) accepts "time" and "stim" commands without any delay.
# 		 * But the JJY-01 ( Firmware version 2.01 ) does not accept these commands continuously,
#-		 * so this driver issues the second command "stim" after the reply of the first command "time".
#+		 * so this driver issues the second command "stim" after the reply of the first command "date".
# 		 */
# 
# 		/*
#@@ -532,7 +580,7 @@
# 		if ( up->version >= 100 ) {
# #ifdef DEBUG
# 			if ( debug ) {
#-				printf ( "jjy_receive_tristate_jjy01 (refclock_jjy.c) : send 'stim<CR><LF>'\n" ) ;
#+				printf ( "%s (refclock_jjy.c) : send 'stim<CR><LF>'\n", sFunctionName ) ;
# 			}
# #endif
# 			if ( write ( pp->io.fd, "stim\r\n",6 ) != 6  ) {
#@@ -541,7 +589,7 @@
# 		} else {
# #ifdef DEBUG
# 			if ( debug ) {
#-				printf ( "jjy_receive_tristate_jjy01 (refclock_jjy.c) : send 'time<CR><LF>'\n" ) ;
#+				printf ( "%s (refclock_jjy.c) : send 'time<CR><LF>'\n", sFunctionName ) ;
# 			}
# #endif
# 			if ( write ( pp->io.fd, "time\r\n",6 ) != 6  ) {
#@@ -554,12 +602,22 @@
# 
# 	case 2 : /* HH:MM:SS */
# 
#-		if ( iLen < 8 ) {
#+		if ( iLen != 8 ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Reply length error ( up->linecount=%d  iLen=%d )\n", sFunctionName, up->linecount, iLen ) ;
#+	        }
#+#endif
# 			up->lineerror = 1 ;
# 			break ;
# 		}
# 		rc = sscanf ( pBuf, "%2d:%2d:%2d", &up->hour, &up->minute, &up->second ) ;
# 		if ( rc != 3 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Time error ( up->linecount=%d )\n", sFunctionName, up->linecount ) ;
#+	        }
#+#endif
# 			up->lineerror = 1 ;
# 			break ;
# 		}
#@@ -591,6 +649,8 @@
# jjy_receive_cdex_jst2000 ( struct recvbuf *rbufp )
# {
# 
#+	static	char	*sFunctionName = "jjy_receive_cdex_jst2000" ;
#+
# 	struct jjyunit      *up ;
# 	struct refclockproc *pp ;
# 	struct peer         *peer;
#@@ -618,7 +678,12 @@
# 
# 	case 1 : /* JYYMMDD HHMMSSS */
# 
#-		if ( iLen < 15 ) {
#+		if ( iLen != 15 ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
#+	        }
#+#endif
# 			up->lineerror = 1 ;
# 			break ;
# 		}
#@@ -626,6 +691,12 @@
# 		              &up->year, &up->month, &up->day, &up->hour, &up->minute, &up->second, &up->msecond ) ;
# 		if ( rc != 7 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
# 		  || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d.%1d ]\n", sFunctionName,
#+						 rc, up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond ) ;
#+	        }
#+#endif
# 			up->lineerror = 1 ;
# 			break ;
# 		}
#@@ -645,6 +716,151 @@
# }
# 
# /**************************************************************************************************/
#+
#+static int
#+jjy_receive_echokeisokuki_lt2000 ( struct recvbuf *rbufp )
#+{
#+
#+	static	char	*sFunctionName = "jjy_receive_echokeisokuki_lt2000" ;
#+
#+	struct jjyunit      *up ;
#+	struct refclockproc *pp ;
#+	struct peer         *peer;
#+
#+	char	*pBuf ;
#+	int 	iLen ;
#+	int 	rc ;
#+    int     i, ibcc, ibcc1, ibcc2 ;
#+
#+	/*
#+	 * Initialize pointers and read the timecode and timestamp
#+	 */
#+	peer = (struct peer *) rbufp->recv_srcclock ;
#+	pp = peer->procptr ;
#+	up = (struct jjyunit *) pp->unitptr ;
#+
#+	if ( up->linediscipline == LDISC_RAW ) {
#+		pBuf = up->rawbuf ;
#+		iLen = up->charcount ;
#+	} else {
#+	    pBuf = pp->a_lastcode ;
#+	    iLen = pp->lencode ;
#+	}
#+
#+	switch ( up->linecount ) {
#+
#+	case 1 : /* YYMMDDWHHMMSS<BCC1><BCC2> or YYMMDDWHHMMSS<ST1><ST2><ST3><ST4> */
#+
#+		if ( ( up->operationmode == 1 && iLen != 15 ) || ( up->operationmode == 2 && iLen != 17 ) ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
#+	        }
#+#endif
#+			if ( up->operationmode == 1 ) {
#+#ifdef DEBUG
#+				if ( debug ) {
#+					printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
#+				}
#+#endif
#+				if ( write ( pp->io.fd, "#",1 ) != 1  ) {
#+					refclock_report ( peer, CEVNT_FAULT ) ;
#+				}
#+			}
#+			up->lineerror = 1 ;
#+			break ;
#+		}
#+
#+		if ( up->operationmode == 1 ) {
#+
#+        	for ( i = ibcc = 0 ; i < 13 ; i ++ ) ibcc ^= pBuf[i] ;
#+        	ibcc1 = 0x30 | ( ( ibcc >> 4 ) & 0xF ) ;
#+        	ibcc2 = 0x30 | ( ( ibcc      ) & 0xF ) ;
#+        	if ( pBuf[13] != ibcc1 || pBuf[14] != ibcc2 ) {
#+#ifdef DEBUG
#+	        	if ( debug >= 2 ) {
#+		        	printf ( "%s (refclock_jjy.c) : BCC error ( Recv=%02X,%02X / Calc=%02X,%02X)\n", sFunctionName, pBuf[13]&0xFF, pBuf[14]&0xFF, ibcc1, ibcc2 ) ;
#+	        	}
#+#endif
#+				up->lineerror = 1 ;
#+				break ;
#+			}
#+
#+        }
#+
#+		rc = sscanf ( pBuf, "%2d%2d%2d%*1d%2d%2d%2d",
#+                      &up->year, &up->month, &up->day, &up->hour, &up->minute, &up->second ) ;
#+		if ( rc != 6 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
#+		  || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
#+#ifdef DEBUG
#+	        if ( debug >= 2 ) {
#+		        printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d ]\n", sFunctionName,
#+						 rc, up->year, up->month, up->day, up->hour, up->minute, up->second ) ;
#+	        }
#+#endif
#+			up->lineerror = 1 ;
#+			break ;
#+		}
#+
#+		up->year += 2000 ;
#+
#+		if ( up->operationmode == 2 ) {
#+
#+			/* A time stamp comes on every 0.5 seccond in the mode 2 of the LT-2000. */
#+			up->msecond = 500 ;
#+			pp->second -- ;
#+			if ( pp->second < 0 ) {
#+				pp->second = 59 ;
#+				pp->minute -- ;
#+				if ( pp->minute < 0 ) {
#+					pp->minute = 59 ;
#+					pp->hour -- ;
#+					if ( pp->hour < 0 ) {
#+						pp->hour = 23 ;
#+						pp->day -- ;
#+						if ( pp->day < 1 ) {
#+							pp->year -- ;
#+							pp->day  = ymd2yd ( pp->year, 12, 31 ) ;
#+						}
#+					}
#+				}
#+			}
#+
#+			/* Switch from mode 2 to mode 1 in order to restraint of useless time stamp. */
#+#ifdef DEBUG
#+			if ( debug ) {
#+				printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
#+			}
#+#endif
#+			if ( write ( pp->io.fd, "#",1 ) != 1  ) {
#+				refclock_report ( peer, CEVNT_FAULT ) ;
#+			}
#+
#+		}
#+
#+		break ;
#+
#+	default : /*  Unexpected reply */
#+
#+#ifdef DEBUG
#+		if ( debug ) {
#+			printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
#+		}
#+#endif
#+		if ( write ( pp->io.fd, "#",1 ) != 1  ) {
#+			refclock_report ( peer, CEVNT_FAULT ) ;
#+		}
#+
#+		up->lineerror = 1 ;
#+		break ;
#+
#+	}
#+
#+	return 1 ;
#+
#+}
#+
#+/**************************************************************************************************/
# /*  jjy_poll - called by the transmit procedure                                                   */
# /**************************************************************************************************/
# static void
#@@ -686,6 +902,10 @@
# 		jjy_poll_cdex_jst2000 ( unit, peer ) ;
# 		break ;
# 
#+	case UNITTYPE_ECHOKEISOKUKI_LT2000 :
#+		jjy_poll_echokeisokuki_lt2000 ( unit, peer ) ;
#+		break ;
#+
# 	default :
# 		break ;
# 
#@@ -699,11 +919,9 @@
# jjy_poll_tristate_jjy01  ( int unit, struct peer *peer )
# {
# 
#-	struct jjyunit      *up;
# 	struct refclockproc *pp;
# 
# 	pp = peer->procptr;
#-	up = (struct jjyunit *) pp->unitptr ;
# 
# 	/*
# 	 * Send "date<CR><LF>" command
#@@ -742,6 +960,42 @@
# #endif
# 
# 	if ( write ( pp->io.fd, "\0051J\003", 4 ) != 4  ) {
#+		refclock_report ( peer, CEVNT_FAULT ) ;
#+	}
#+
#+}
#+
#+/**************************************************************************************************/
#+
#+static void
#+jjy_poll_echokeisokuki_lt2000 ( int unit, struct peer *peer )
#+{
#+
#+	struct jjyunit      *up;
#+	struct refclockproc *pp;
#+
#+	char	sCmd[2] ;
#+
#+	pp = peer->procptr;
#+	up = (struct jjyunit *) pp->unitptr ;
#+
#+	/*
#+	 * Send "T" or "C" command
#+	 */
#+
#+	switch ( up->operationmode ) {
#+	case 1 : sCmd[0] = 'T' ; break ;
#+	case 2 : sCmd[0] = 'C' ; break ;
#+	}
#+	sCmd[1] = 0 ;
#+
#+#ifdef DEBUG
#+	if ( debug ) {
#+		printf ( "jjy_poll_echokeisokuki_lt2000 (refclock_jjy.c) : send '%s'\n", sCmd ) ;
#+	}
#+#endif
#+
#+	if ( write ( pp->io.fd, sCmd, 1 ) != 1  ) {
# 		refclock_report ( peer, CEVNT_FAULT ) ;
# 	}
# 
#

# Diff checksum=2cf9f200


# Patch vers:	1.3
# Patch type:	REGULAR

== ChangeSet ==
stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
stenn at whimsy.udel.edu|ChangeSet|20041217094929|44180
D 1.1310 04/12/18 04:55:09+00:00 abe at pogo.udel.edu +3 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c 
K 41550
P ChangeSet
------------------------------------------------

0a0
> stenn at whimsy.udel.edu|html/driver40.htm|20010922063130|47507|eaacccf17f2618f4 abe at pogo.udel.edu|html/drivers/driver40.html|20041218044320|48814
> stenn at whimsy.udel.edu|ntpd/refclock_jjy.c|20011006060257|50701|bba9ea1577049c0c abe at pogo.udel.edu|ntpd/refclock_jjy.c|20041218044211|35680
> stenn at whimsy.udel.edu|BitKeeper/etc/logging_ok|20010815091324|19348|bebb84d857254496 abe at pogo.udel.edu|BitKeeper/etc/logging_ok|20041218045508|01621

abe at pogo.udel.edu|ChangeSet|20041218045509|41550
D 1.1311 04/12/21 13:02:52+00:00 abe at pogo.udel.edu +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge bk://www.ntp.org/home/bk/ntp-dev
c into pogo.udel.edu:/pogo/users/abe/ntp-dev-246
i stenn at whimsy.udel.edu|ChangeSet|20041221013618|44173
i stenn at whimsy.udel.edu|ChangeSet|20041221014157|44151
i stenn at whimsy.udel.edu|ChangeSet|20041221015434|44149
i stenn at whimsy.udel.edu|ChangeSet|20041221020108|44150
i stenn at whimsy.udel.edu|ChangeSet|20041221023416|44130
K 41500
M stenn at whimsy.udel.edu|ChangeSet|20041221023416|44130
P ChangeSet
------------------------------------------------


abe at pogo.udel.edu|ChangeSet|20041221130252|41500
D 1.1312 04/12/22 15:12:17+00:00 abe at pogo.udel.edu +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge bk://www.ntp.org/home/bk/ntp-dev
c into pogo.udel.edu:/pogo/users/abe/ntp-dev-246
i stenn at whimsy.udel.edu|ChangeSet|20041222053541|44130
K 41500
M stenn at whimsy.udel.edu|ChangeSet|20041222053541|44130
P ChangeSet
------------------------------------------------


abe at pogo.udel.edu|ChangeSet|20041222151217|41500
D 1.1313 05/01/07 13:14:42+00:00 abe at pogo.udel.edu +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge bk://www.ntp.org/home/bk/ntp-dev
c into pogo.udel.edu:/pogo/users/abe/ntp-dev-246
i stenn at whimsy.udel.edu|ChangeSet|20041227111513|44136
i stenn at whimsy.udel.edu|ChangeSet|20041228054627|44159
i stenn at pogo.udel.edu|ChangeSet|20050101111725|43895
i stenn at whimsy.udel.edu|ChangeSet|20050105061604|44132
K 41502
M stenn at whimsy.udel.edu|ChangeSet|20050105061604|44132
P ChangeSet
------------------------------------------------


abe at pogo.udel.edu|ChangeSet|20050107131442|41502
D 1.1314 05/01/09 01:50:12-05:00 stenn at pogo.udel.edu +0 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Merge bk://www.ntp.org/home/bk/ntp-dev
c into pogo.udel.edu:/pogo/users/abe/ntp-dev-246
i stenn at whimsy.udel.edu|ChangeSet|20050108061332|44128
i stenn at whimsy.udel.edu|ChangeSet|20050108072327|44122
K 41492
M stenn at whimsy.udel.edu|ChangeSet|20050108072327|44122
P ChangeSet
------------------------------------------------


== BitKeeper/etc/logging_ok ==
stenn at whimsy.udel.edu|BitKeeper/etc/logging_ok|20010815091324|19348|bebb84d857254496
stenn at poog.il.thewrittenword.com|BitKeeper/etc/logging_ok|20040809103831|65514
D 1.51 04/12/18 04:55:08+00:00 abe at pogo.udel.edu +1 -0
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
c Logging to logging at openlogging.org accepted
K 1621
O -rw-rw-r--
P BitKeeper/etc/logging_ok
------------------------------------------------

I1 1
abe at pogo.udel.edu

== html/drivers/driver40.html ==
stenn at whimsy.udel.edu|html/driver40.htm|20010922063130|47507|eaacccf17f2618f4
stenn at whimsy.udel.edu|html/drivers/driver40.html|20041122023256|57989
D 1.12 04/12/18 04:43:20+00:00 abe at pogo.udel.edu +46 -4
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
K 48814
O -rw-rw-r--
P html/drivers/driver40.html
------------------------------------------------

D3 1
I3 1
<html lang ="en">
I13 1
\
I18 1
\
I21 1
\
D46 1
I46 1
                <p>server &nbsp; 127.127.40.X &nbsp; mode 1</p>
I48 2
</li>
\
D68 1
I68 1
                <p>server &nbsp; 127.127.40.X &nbsp; mode 2</p>
I70 35
</li>
\
<li><p>Echo Keisokuki Co.,Ltd. LT-2000 <a href="http://www.clock.co.jp/">http://www.clock.co.jp/</a> (Japanese only)</p>
<dl>
<dt>Time code format</dt>
<dd><br>
<table summary="CommandAndReply">
<tr>
<td>Command</td><td>&nbsp;</td><td>Reply</td>
</tr>
<tr>
<td><code>C</code></td>
<td></td>
<td>( Mode 2 : Continuous ) </td>
</tr>
<tr>
<td></td>
<td></td>
<td><code>YYMMDDWHHMMSS&lt;ST1&gt;&lt;ST2&gt;&lt;ST3&gt;&lt;ST4&gt;&lt;CR&gt;</code></td>
</tr>
<tr>
<td><code>#</code></td>
<td></td>
<td>( Mode 1 : Request&Send )</td>
</tr>
</table>
<br>
</dd>
<dt>NTP configuration ( ntp.conf )</dt>
<dd>
<p>server &nbsp; 127.127.40.X &nbsp; mode 3</p>
</dd>
</dl>
</li>
\
D72 1
I72 1
        <p>JJY is the radio station which transmites the JST (Japan Standard Time) in long wave radio. The station JJY is operated by the National Institute of Information and Communications Technology. An operating announcement and some information are avaiable from <a href="http://www.nict.go.jp/">http://www.nict.go.jp/</a> (English and Japanese) and <a href="http://jjy.nict.go.jp/">http://jjy.nict.go.jp/</a> (English and Japanese)</p>
I75 1
\
I77 1
\

== ntpd/refclock_jjy.c ==
stenn at whimsy.udel.edu|ntpd/refclock_jjy.c|20011006060257|50701|bba9ea1577049c0c
stenn at whimsy.udel.edu|ntpd/refclock_jjy.c|20041122023256|11521
D 1.12 04/12/18 04:42:11+00:00 abe at pogo.udel.edu +275 -21
B stenn at whimsy.udel.edu|ChangeSet|19990526004811|57482|8983e65c737bb465
C
K 35680
O -rw-rw-r--
P ntpd/refclock_jjy.c
------------------------------------------------

D7 1
I7 1
/*  Copyright (C) 2001-2004, Takao Abe.  All rights reserved.         */
I69 3
/*  2004/11/28                                                        */
/*    [Add]    Support the Echo Keisokuki LT-2000 receiver            */
/*                                                                    */
I114 12
/*                                                                    */
/*  The Echo Keisokuki Co. Ltd. JJY receiver LT2000                   */
/*                                                                    */
/*  Command        Response                 Remarks                   */
/*  ------------   ----------------------   ---------------------     */
/*  #                                       Mode 1 (Request&Send)     */
/*  T              YYMMDDWHHMMSS<BCC1><BCC2><CR>                      */
/*  C                                       Mode 2 (Continuous)       */
/*                 YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR>              */
/*                 <SUB>                    Second signal             */
/*                                                                    */
/**********************************************************************/
D129 1
I129 2
	char	unittype ;          /* UNITTYPE_XXXXXXXXXX */
    short   operationmode ;     /* Echo Keisokuki LT-2000 : 1 or 2 */
I145 1
#define	UNITTYPE_ECHOKEISOKUKI_LT2000  	3
I154 1
static	void	jjy_poll_echokeisokuki_lt2000    P((int, struct peer *));
I157 1
static	int 	jjy_receive_echokeisokuki_lt2000 P((struct recvbuf *));
I219 1
	case 3 : iDiscipline = LDISC_CLK ; break ;
I263 12
	case 3 :
		up->unittype = UNITTYPE_ECHOKEISOKUKI_LT2000 ;
		up->operationmode = 2 ;  /* Mode 2 : Continuous mode */
		up->lineexpect = 1 ;
        switch ( up->operationmode ) {
        case 1 :
			up->charexpect[0] = 15 ; /* YYMMDDWHHMMSS<BCC1><BCC2><CR> */
			break ;
		case 2 :
			up->charexpect[0] = 17 ; /* YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR> */
			break ;
		}
I395 4
	case UNITTYPE_ECHOKEISOKUKI_LT2000 :
		rc = jjy_receive_echokeisokuki_lt2000 ( rbufp ) ;
		break ;
\
D450 4
I453 4
		printf ( "jjy_receive (refclock_jjy.c) : %04d/%02d/%02d %02d:%02d:%02d.%1d JST   ", 
		          up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond/100 ) ;
		printf ( "( %04d/%03d %02d:%02d:%02d.%1d UTC )\n",
		          pp->year, pp->day, pp->hour, pp->minute, pp->second, (int)(pp->nsec/100000000) ) ;
I460 5
\
	sprintf ( sLogText, "%04d/%02d/%02d %02d:%02d:%02d.%1d JST",
	          up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond/100 ) ;
	record_clock_stats ( &peer->srcadr, sLogText ) ;
\
D463 3
D469 2
D473 1
I473 1
\
I481 2
	static	char	*sFunctionName = "jjy_receive_tristate_jjy01" ;
\
D507 1
I507 1
	case 1 : /* YYYY/MM/DD WWW */
D509 1
I509 6
		if ( iLen != 14 ) {
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Reply length error ( up->linecount=%d  iLen=%d )\n", sFunctionName, up->linecount, iLen ) ;
	        }
#endif
I514 5
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Date error ( up->linecount=%d )\n", sFunctionName, up->linecount ) ;
	        }
#endif
D524 1
I524 1
		 * so this driver issues the second command "stim" after the reply of the first command "date".
D535 1
I535 1
				printf ( "%s (refclock_jjy.c) : send 'stim<CR><LF>'\n", sFunctionName ) ;
D544 1
I544 1
				printf ( "%s (refclock_jjy.c) : send 'time<CR><LF>'\n", sFunctionName ) ;
D557 1
I557 6
		if ( iLen != 8 ) {
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Reply length error ( up->linecount=%d  iLen=%d )\n", sFunctionName, up->linecount, iLen ) ;
	        }
#endif
I562 5
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Time error ( up->linecount=%d )\n", sFunctionName, up->linecount ) ;
	        }
#endif
I593 2
	static	char	*sFunctionName = "jjy_receive_cdex_jst2000" ;
\
D621 1
I621 6
		if ( iLen != 15 ) {
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
	        }
#endif
I628 6
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d.%1d ]\n", sFunctionName,
						 rc, up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond ) ;
	        }
#endif
I647 145
\
static int
jjy_receive_echokeisokuki_lt2000 ( struct recvbuf *rbufp )
{
\
	static	char	*sFunctionName = "jjy_receive_echokeisokuki_lt2000" ;
\
	struct jjyunit      *up ;
	struct refclockproc *pp ;
	struct peer         *peer;
\
	char	*pBuf ;
	int 	iLen ;
	int 	rc ;
    int     i, ibcc, ibcc1, ibcc2 ;
\
	/*
	 * Initialize pointers and read the timecode and timestamp
	 */
	peer = (struct peer *) rbufp->recv_srcclock ;
	pp = peer->procptr ;
	up = (struct jjyunit *) pp->unitptr ;
\
	if ( up->linediscipline == LDISC_RAW ) {
		pBuf = up->rawbuf ;
		iLen = up->charcount ;
	} else {
	    pBuf = pp->a_lastcode ;
	    iLen = pp->lencode ;
	}
\
	switch ( up->linecount ) {
\
	case 1 : /* YYMMDDWHHMMSS<BCC1><BCC2> or YYMMDDWHHMMSS<ST1><ST2><ST3><ST4> */
\
		if ( ( up->operationmode == 1 && iLen != 15 ) || ( up->operationmode == 2 && iLen != 17 ) ) {
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
	        }
#endif
			if ( up->operationmode == 1 ) {
#ifdef DEBUG
				if ( debug ) {
					printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
				}
#endif
				if ( write ( pp->io.fd, "#",1 ) != 1  ) {
					refclock_report ( peer, CEVNT_FAULT ) ;
				}
			}
			up->lineerror = 1 ;
			break ;
		}
\
		if ( up->operationmode == 1 ) {
\
        	for ( i = ibcc = 0 ; i < 13 ; i ++ ) ibcc ^= pBuf[i] ;
        	ibcc1 = 0x30 | ( ( ibcc >> 4 ) & 0xF ) ;
        	ibcc2 = 0x30 | ( ( ibcc      ) & 0xF ) ;
        	if ( pBuf[13] != ibcc1 || pBuf[14] != ibcc2 ) {
#ifdef DEBUG
	        	if ( debug >= 2 ) {
		        	printf ( "%s (refclock_jjy.c) : BCC error ( Recv=%02X,%02X / Calc=%02X,%02X)\n", sFunctionName, pBuf[13]&0xFF, pBuf[14]&0xFF, ibcc1, ibcc2 ) ;
	        	}
#endif
				up->lineerror = 1 ;
				break ;
			}
\
        }
\
		rc = sscanf ( pBuf, "%2d%2d%2d%*1d%2d%2d%2d",
                      &up->year, &up->month, &up->day, &up->hour, &up->minute, &up->second ) ;
		if ( rc != 6 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
		  || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
#ifdef DEBUG
	        if ( debug >= 2 ) {
		        printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d ]\n", sFunctionName,
						 rc, up->year, up->month, up->day, up->hour, up->minute, up->second ) ;
	        }
#endif
			up->lineerror = 1 ;
			break ;
		}
\
		up->year += 2000 ;
\
		if ( up->operationmode == 2 ) {
\
			/* A time stamp comes on every 0.5 seccond in the mode 2 of the LT-2000. */
			up->msecond = 500 ;
			pp->second -- ;
			if ( pp->second < 0 ) {
				pp->second = 59 ;
				pp->minute -- ;
				if ( pp->minute < 0 ) {
					pp->minute = 59 ;
					pp->hour -- ;
					if ( pp->hour < 0 ) {
						pp->hour = 23 ;
						pp->day -- ;
						if ( pp->day < 1 ) {
							pp->year -- ;
							pp->day  = ymd2yd ( pp->year, 12, 31 ) ;
						}
					}
				}
			}
\
			/* Switch from mode 2 to mode 1 in order to restraint of useless time stamp. */
#ifdef DEBUG
			if ( debug ) {
				printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
			}
#endif
			if ( write ( pp->io.fd, "#",1 ) != 1  ) {
				refclock_report ( peer, CEVNT_FAULT ) ;
			}
\
		}
\
		break ;
\
	default : /*  Unexpected reply */
\
#ifdef DEBUG
		if ( debug ) {
			printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
		}
#endif
		if ( write ( pp->io.fd, "#",1 ) != 1  ) {
			refclock_report ( peer, CEVNT_FAULT ) ;
		}
\
		up->lineerror = 1 ;
		break ;
\
	}
\
	return 1 ;
\
}
\
/**************************************************************************************************/
I688 4
	case UNITTYPE_ECHOKEISOKUKI_LT2000 :
		jjy_poll_echokeisokuki_lt2000 ( unit, peer ) ;
		break ;
\
D702 1
D706 1
I744 36
		refclock_report ( peer, CEVNT_FAULT ) ;
	}
\
}
\
/**************************************************************************************************/
\
static void
jjy_poll_echokeisokuki_lt2000 ( int unit, struct peer *peer )
{
\
	struct jjyunit      *up;
	struct refclockproc *pp;
\
	char	sCmd[2] ;
\
	pp = peer->procptr;
	up = (struct jjyunit *) pp->unitptr ;
\
	/*
	 * Send "T" or "C" command
	 */
\
	switch ( up->operationmode ) {
	case 1 : sCmd[0] = 'T' ; break ;
	case 2 : sCmd[0] = 'C' ; break ;
	}
	sCmd[1] = 0 ;
\
#ifdef DEBUG
	if ( debug ) {
		printf ( "jjy_poll_echokeisokuki_lt2000 (refclock_jjy.c) : send '%s'\n", sCmd ) ;
	}
#endif
\
	if ( write ( pp->io.fd, sCmd, 1 ) != 1  ) {

# Patch checksum=ee80af84


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