+---
+
+* Updated JJY reference clock driver from Takao abe
+
---
(4.2.4p7-RC5) 2009/05/02 Released by Harlan Stenn <stenn@ntp.org>
<head>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
<meta name="generator" content="HTML Tidy, see www.w3.org">
+ <meta http-equiv="Content-Script-Type" content="text/javascript">
<title>JJY Receivers</title>
+ <link rev="made" href="http://www.bea.hi-ho.ne.jp/abetakao/">
+ <link rel="start" href="http://www.eecis.udel.edu/~mills/ntp/html/refclock.html">
<link href="scripts/style.css" type="text/css" rel="stylesheet">
</head>
<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
+ Address: 127.127.40.<em>u</em><br>
+ Reference ID: <code>JJY</code><br>
+ Driver ID: <code>JJY</code><br>
+ Serial Port: <code>/dev/jjy<em>u</em></code>; 9600|4800(See corresponding receiver) 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
+ <dt>NTP configuration ( ntp.conf )</dt>
+ <dd>
+ <p>server 127.127.40.X mode 1</p>
+ <br>
+ </dd>
+ <dt>RS-232C</dt>
+ <dd>
+ <p>9600 Baud</p>
+ <br>
+ </dd>
+ <dt>Time code format</dt>
<dd><br>
- <table>
+ <table summary="CommandAndReply">
<tr>
<td>Command</td>
- <td> </td>
+ <td> --> </td>
<td>Reply</td>
</tr>
<tr>
- <td><tt>date<CR><LF></tt></td>
- <td> </td>
- <td><tt>YYYY/MM/DD WWW<CR><LF></tt></td>
+ <td><code>date<CR><LF></code></td>
+ <td> --> </td>
+ <td><code>YYYY/MM/DD WWW<CR><LF></code></td>
</tr>
<tr>
- <td><tt>stim<CR><LF></tt></td>
- <td> </td>
- <td><tt>HH:MM:SS<CR><LF></tt></td>
+ <td><code>stim<CR><LF></code></td>
+ <td> --> </td>
+ <td><code>HH:MM:SS<CR><LF></code></td>
</tr>
</table>
<br>
- <dt>NTP configuration ( ntp.conf )
- <dd>
- <p>server 127.127.40.X mode 1</p>
- <br>
+ </dd>
</dl>
<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
+ <dt>NTP configuration ( ntp.conf )</dt>
+ <dd>
+ <p>server 127.127.40.X mode 2</p>
+ <br>
+ </dd>
+ <dt>RS-232C</dt>
+ <dd>
+ <p>9600 Baud</p>
+ <br>
+ </dd>
+ <dt>Time code format</dt>
<dd><br>
- <table>
+ <table summary="CommandAndReply">
<tr>
<td>Command</td>
- <td> </td>
+ <td> --> </td>
<td>Reply</td>
</tr>
<tr>
- <td><tt><ENQ>1J<ETX></tt></td>
- <td> </td>
- <td><tt><STX>JYYMMDD HHMMSSS<ETX></tt></td>
+ <td><code><ENQ>1J<ETX></code></td>
+ <td> --> </td>
+ <td><code><STX>JYYMMDD HHMMSSS<ETX></code></td>
</tr>
</table>
<br>
- <dt>NTP configuration ( ntp.conf )
- <dd>
- <p>server 127.127.40.X mode 2</p>
- <br>
+ </dd>
</dl>
<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>NTP configuration ( ntp.conf )</dt>
+ <dd>
+ <p>server 127.127.40.X mode 3</p>
+ <br>
+ </dd>
+ <dt>RS-232C</dt>
+ <dd>
+ <p>9600 Baud</p>
+ <br>
+ </dd>
+ <dt>Time code format</dt>
<dd><br>
<table summary="CommandAndReply">
<tr>
<td>Command</td>
- <td> </td>
+ <td> --> </td>
<td>Reply</td>
</tr>
<tr>
<td><code>C</code></td>
- <td></td>
+ <td> --> </td>
<td>( Mode 2 : Continuous )</td>
</tr>
<tr>
- <td></td>
+ <td>( Every second before 0.5 second )</td>
<td></td>
<td><code>YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR></code></td>
</tr>
<tr>
<td><code>#</code></td>
- <td></td>
- <td>( Mode 1 : Request&Send )</td>
+ <td> --> </td>
+ <td>( Mode 1 : Request&Send )</td>
</tr>
</table>
<br>
- <dt>NTP configuration ( ntp.conf )
+ </dd>
+ </dl>
+ <li>
+ <p>CITIZEN T.I.C. CO.,LTD. JJY-200 <a href="http://www.tic-citizen.co.jp/">http://www.tic-citizen.co.jp/</a> (Japanese only)</p>
+ <dl>
+ <dt>NTP configuration ( ntp.conf )</dt>
<dd>
- <p>server 127.127.40.X mode 3</p>
+ <p>server 127.127.40.X mode 4</p>
+ <br>
+ </dd>
+ <dt>RS-232C</dt>
+ <dd>
+ <p>4800 Baud</p>
+ <br>
+ </dd>
+ <dt>Time code format</dt>
+ <dd><br>
+ <table summary="CommandAndReply">
+ <tr>
+ <td>Command</td>
+ <td> --> </td>
+ <td>Reply</td>
+ </tr>
+ <tr>
+ <td>( Every second )</td>
+ <td></td>
+ <td><code>'XX YY/MM/DD W HH:MM:SS<CR></code></td>
+ </tr>
+ </table>
+ <br>
+ </dd>
</dl>
</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.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>
+ <p><code>ln -s /dev/ttyS0 /dev/jjy0</code></p>
+ <p>Windows NT does not support symbolic links to device files. COM<em>X</em>: 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>
+ <p>The driver writes each timecode as received to the <code>clockstats</code> file.</p>
<h4>Fudge Factors</h4>
<dl>
- <dt><tt>time1 <i>time</i></tt>
+ <dt><code>time1 <em>time</em></code>
<dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
- <dt><tt>time2 <i>time</i></tt>
+ <dt><code>time2 <em>time</em></code>
<dd>Not used by this driver.
- <dt><tt>stratum <i>number</i></tt>
+ <dt><code>stratum <em>number</em></code>
<dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
- <dt><tt>refid <i>string</i></tt>
- <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>JJY</tt>.
- <dt><tt>flag1 0 | 1</tt>
+ <dt><code>refid <em>string</em></code>
+ <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <code>JJY</code>.
+ <dt><code>flag1 0 | 1</code>
<dd>Not used by this driver.
- <dt><tt>flag2 0 | 1</tt>
+ <dt><code>flag2 0 | 1</code>
<dd>Not used by this driver.
- <dt><tt>flag3 0 | 1</tt>
+ <dt><code>flag3 0 | 1</code>
<dd>Not used by this driver.
- <dt><tt>flag4 0 | 1</tt>
+ <dt><code>flag4 0 | 1</code>
<dd>Not used by this driver.
</dl>
<hr>
<script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
</body>
-</html>
\ No newline at end of file
+</html>
/* [Fix] C-DEX JST2000 */
/* Thanks to Hideo Kuramatsu for the patch */
/* */
+/* 2009/04/05 */
+/* [Add] Support the CITIZEN T.I.C JJY-200 receiver */
+/* */
/**********************************************************************/
#ifdef HAVE_CONFIG_H
/* <SUB> Second signal */
/* */
/**********************************************************************/
+/* */
+/* The CITIZEN T.I.C CO., LTD. JJY receiver JJY200 */
+/* */
+/* Command Response Remarks */
+/* ------------ ---------------------- --------------------- */
+/* 'XX YY/MM/DD W HH:MM:SS<CR> */
+/* XX: OK|NG|ER */
+/* W: 0(Monday)-6(Sunday) */
+/* */
+/**********************************************************************/
/*
* Interface definitions
*/
#define DEVICE "/dev/jjy%d" /* device name and unit */
#define SPEED232 B9600 /* uart speed (9600 baud) */
+#define SPEED232_TRISTATE_JJY01 B9600 /* UART speed (9600 baud) */
+#define SPEED232_CDEX_JST2000 B9600 /* UART speed (9600 baud) */
+#define SPEED232_ECHOKEISOKUKI_LT2000 B9600 /* UART speed (9600 baud) */
+#define SPEED232_CITIZENTIC_JJY200 B4800 /* UART speed (4800 baud) */
#define REFID "JJY" /* reference ID */
#define DESCRIPTION "JJY Receiver"
#define PRECISION (-3) /* precision assumed (about 100 ms) */
short operationmode ; /* Echo Keisokuki LT-2000 : 1 or 2 */
short version ;
short linediscipline ; /* LDISC_CLK or LDISC_RAW */
+ char bPollFlag ; /* Set by jjy_pool and Reset by jjy_receive */
int linecount ;
int lineerror ;
int year, month, day, hour, minute, second, msecond ;
#define UNITTYPE_TRISTATE_JJY01 1
#define UNITTYPE_CDEX_JST2000 2
#define UNITTYPE_ECHOKEISOKUKI_LT2000 3
+#define UNITTYPE_CITIZENTIC_JJY200 4
/*
* Function prototypes
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_poll_citizentic_jjy200 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 *));
+static int jjy_receive_citizentic_jjy200 P((struct recvbuf *));
/*
* Transfer vector
int fd ;
char *pDeviceName ;
short iDiscipline ;
+ int iSpeed232 ;
#ifdef DEBUG
if ( debug ) {
*/
switch ( peer->ttl ) {
case 0 :
- case 1 : iDiscipline = LDISC_CLK ; break ;
- case 2 : iDiscipline = LDISC_RAW ; break ;
- case 3 : iDiscipline = LDISC_CLK ; break ;
+ case 1 :
+ iDiscipline = LDISC_CLK ;
+ iSpeed232 = SPEED232_TRISTATE_JJY01 ;
+ break ;
+ case 2 :
+ iDiscipline = LDISC_RAW ;
+ iSpeed232 = SPEED232_CDEX_JST2000 ;
+ break ;
+ case 3 :
+ iDiscipline = LDISC_CLK ;
+ iSpeed232 = SPEED232_ECHOKEISOKUKI_LT2000 ;
+ break ;
+ case 4 :
+ iDiscipline = LDISC_CLK ;
+ iSpeed232 = SPEED232_CITIZENTIC_JJY200 ;
+ break ;
default :
msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode",
ntoa(&peer->srcadr), peer->ttl ) ;
return RC_START_ERROR ;
}
- if ( ! ( fd = refclock_open ( pDeviceName, SPEED232, iDiscipline ) ) ) {
+ if ( ! ( fd = refclock_open ( pDeviceName, iSpeed232, iDiscipline ) ) ) {
free ( (void*) pDeviceName ) ;
return RC_START_ERROR ;
}
break ;
}
break ;
+ case 4 :
+ up->unittype = UNITTYPE_CITIZENTIC_JJY200 ;
+ up->lineexpect = 1 ;
+ up->charexpect[0] = 23 ; /* 'XX YY/MM/DD W HH:MM:SS<CR> */
+ break ;
default :
msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode",
ntoa(&peer->srcadr), peer->ttl ) ;
rc = jjy_receive_echokeisokuki_lt2000 ( rbufp ) ;
break ;
+ case UNITTYPE_CITIZENTIC_JJY200 :
+ rc = jjy_receive_citizentic_jjy200 ( rbufp ) ;
+ break ;
+
default :
rc = 0 ;
break ;
if ( rc == 0 ) return ;
+ up->bPollFlag = 0 ;
+
if ( up->lineerror != 0 ) {
refclock_report ( peer, CEVNT_BADREPLY ) ;
strcpy ( sLogText, "BAD REPLY [" ) ;
}
+/**************************************************************************************************/
+
+static int
+jjy_receive_citizentic_jjy200 ( struct recvbuf *rbufp )
+{
+
+ static char *sFunctionName = "jjy_receive_citizentic_jjy200" ;
+
+ struct jjyunit *up ;
+ struct refclockproc *pp ;
+ struct peer *peer;
+
+ char *pBuf ;
+ int iLen ;
+ int rc ;
+ char cApostrophe, sStatus[3] ;
+ int iWeekday ;
+
+ /*
+ * 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 ;
+ }
+
+ /*
+ * JJY-200 sends a timestamp every second.
+ * So, a timestamp is ignored unless it is right after polled.
+ */
+ if ( ! up->bPollFlag ) return 0 ;
+
+ switch ( up->linecount ) {
+
+ case 1 : /* 'XX YY/MM/DD W HH:MM:SS<CR> */
+
+ if ( iLen != 23 ) {
+#ifdef DEBUG
+ if ( debug >= 2 ) {
+ printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
+ }
+#endif
+ up->lineerror = 1 ;
+ break ;
+ }
+
+ rc = sscanf ( pBuf, "%c%2s %2d/%2d/%2d %1d %2d:%2d:%2d",
+ &cApostrophe, sStatus,
+ &up->year, &up->month, &up->day, &iWeekday, &up->hour, &up->minute, &up->second ) ;
+ sStatus[2] = 0 ;
+ if ( rc != 9 || cApostrophe != '\'' || strcmp( sStatus, "OK" ) != 0
+ || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
+ || iWeekday > 6
+ || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+#ifdef DEBUG
+ if ( debug >= 2 ) {
+ printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %c %2s %02d %02d %02d %d %02d %02d %02d ]\n", sFunctionName,
+ rc, cApostrophe, sStatus, up->year, up->month, up->day, iWeekday, up->hour, up->minute, up->second ) ;
+ }
+#endif
+ up->lineerror = 1 ;
+ break ;
+ }
+
+ up->year += 2000 ;
+ up->msecond = 0 ;
+
+ break ;
+
+ default : /* Unexpected reply */
+
+ up->lineerror = 1 ;
+ break ;
+
+ }
+
+ return 1 ;
+
+}
+
/**************************************************************************************************/
/* jjy_poll - called by the transmit procedure */
/**************************************************************************************************/
pp->polls ++ ;
+ up->bPollFlag = 1 ;
up->linecount = 0 ;
up->lineerror = 0 ;
up->charcount = 0 ;
jjy_poll_echokeisokuki_lt2000 ( unit, peer ) ;
break ;
+ case UNITTYPE_CITIZENTIC_JJY200 :
+ jjy_poll_citizentic_jjy200 ( unit, peer ) ;
+ break ;
+
default :
break ;
}
+/**************************************************************************************************/
+
+static void
+jjy_poll_citizentic_jjy200 ( int unit, struct peer *peer )
+{
+
+ /* Do nothing ( up->bPollFlag is set by the jjy_poll ) */
+
+}
+
#else
int refclock_jjy_bs ;
-#endif /* REFCLOCK */
+#endif /* REFCLOCK */
\ No newline at end of file
Microsoft Visual Studio Solution File, Format Version 10.00
# Visual C++ Express 2008
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "instsrv", "instsrv\Instsrv.vcproj", "{C3534C4D-6DF1-498E-9904-4337878A1515}"
-EndProject
-Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libntp", "libntp\libntp.vcproj", "{400FBFCB-462E-40D0-B06B-3B74E3FFFD00}"
-EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpd", "ntpd\ntpd.vcproj", "{CB61F8BF-9637-495C-9087-E8664B400CE0}"
ProjectSection(ProjectDependencies) = postProject
{400FBFCB-462E-40D0-B06B-3B74E3FFFD00} = {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}
EndProjectSection
EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "instsrv", "instsrv\Instsrv.vcproj", "{C3534C4D-6DF1-498E-9904-4337878A1515}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libntp", "libntp\libntp.vcproj", "{400FBFCB-462E-40D0-B06B-3B74E3FFFD00}"
+EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpdate", "ntpdate\ntpdate.vcproj", "{2789A62E-3F46-44F1-AAF0-816CD23C2911}"
ProjectSection(ProjectDependencies) = postProject
{400FBFCB-462E-40D0-B06B-3B74E3FFFD00} = {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}