<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<meta name="generator" content="HTML Tidy, see www.w3.org">
+ <meta http-equiv="Content-Style-Type" content="text/css">
<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/">
<body>
<h3>JJY Receivers</h3>
<p>Last update:
- <!-- #BeginDate format:En2m -->11-Apr-2015 00:00<!-- #EndDate -->
+ <!-- #BeginDate format:En2m -->15-May-2015 00:00<!-- #EndDate -->
UTC <a href="driver40.html">ENGLISH(英語)</a> <a href="driver40-ja.html">JAPANESE(日本語)</a></p>
<hr>
<h4>Synopsis</h4>
Driver ID: <code>JJY</code><br>
Serial Port: <code>/dev/jjy<em>u</em></code>; それぞれのJJY受信機、GPS時計、テレフォンJJYを参照して下さい。
<h4>Description</h4>
- <p>このドライバーは、以下の、日本で販売されている JJY受信機、GPS時計と、電話回線による時刻配信サービスをサポートしています。<br>
+ <p>このドライバーは、以下の、日本で販売されている JJY受信機、GPS時計と、電話回線による時刻配信サービスをサポートしています。
+ </p>
+ <table width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top;">
<a href="#mode-1">トライステート TS-JJY01, TS-JJY02</a><br>
<a href="#mode-2">シーデックス JST2000</a><br>
<a href="#mode-3">エコー計測器 LT-2000</a><br>
<a href="#mode-4">シチズンTIC JJY-200</a><br>
<a href="#mode-5">トライステート TS-GPSclock-01</a><br>
- <a href="#mode-100">テレフォンJJY</a></p>
+ </td>
+ <td width="50%" style="vertical-align:top; border-left:solid; padding:0px 0px 0px 10px;">
+ <a href="#mode-6">セイコー タイム システム TDC-300</a><br>
+ <a href="#mode-100">テレフォンJJY</a><br>
+ </td>
+ </tr>
+ </table>
<ul>
<li>
<dl>
<dt>server 127.127.40.X mode 1</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1 time1 0.NNN flag1 0|1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN flag1 0|1</dt>
<dd>
<p>Time1 は、受信機からの時刻に加算する調整時間を、固定小数点形式の秒で設定します。<br>
この受信機には、数10ミリ秒 ( 0.0NN秒 ) から百数10ミリ秒 ( 0.1NN秒 ) の調整時間を設定すると良いでしょう。</p>
<dl>
<dt>server 127.127.40.X mode 2</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
</dl>
<br>
</dd>
<dl>
<dt>server 127.127.40.X mode 3</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
</dl>
<br>
</dd>
<dl>
<dt>server 127.127.40.X mode 4</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
</dl>
<br>
</dd>
<dl>
<dt>server 127.127.40.X mode 5</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1 time1 0.NNN flag1 0|1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN flag1 0|1</dt>
<dd>
<p>Time1 は、受信機からの時刻に加算する調整時間を、固定小数点形式の秒で設定します</p>
<p>Flag1 は、時刻同期には無関係です。Flag1 を 1 に設定すると、状態を問い合わせるコマンドを DATE コマンドと STIM コマンドの前に発行して、応答を clockstats ファイルに記録します。</p>
</dl>
</li>
+ <li>
+ <p><a name="mode-6">セイコー タイム システム TDC-300</a> <a href="http://www.seiko-sts.co.jp/">http://www.seiko-sts.co.jp/</a> (英語と日本語)</p><br>
+ <p>TDC-300 は、フロント・パネルのメニュー表示とスイッチで type 3 のデータ形式に設定しなければなりません。</p>
+ <dl>
+ <dt>NTP configuration ( ntp.conf )</dt>
+ <dd><br>
+ <dl>
+ <dt>server 127.127.40.X mode 6</dt>
+ <dd><br></dd>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
+ </dl>
+ <br>
+ </dd>
+ <dt>インターフェース</dt>
+ <dd>
+ <p>RS-232C, 2400 BPS, 8-bits, no parity, 1 stop bit</p>
+ <br>
+ </dd>
+ <dt>日時データの形式</dt>
+ <dd><br>
+ <table summary="CommandAndReply">
+ <tr>
+ <td>コマンド</td>
+ <td> --> </td>
+ <td>応答</td>
+ </tr>
+ <tr>
+ <td></td>
+ <td></td>
+ <td><code>{STX}YYMMDDWHHMMSS{ETX}</code></td>
+ </tr>
+ <tr>
+ <td>( 5 to 10 mSec. before second )</td>
+ <td></td>
+ <td><code>{STX}{xE5}{ETX}</code></td>
+ </tr>
+ </table>
+ <br>
+ </dd>
+ </dl>
+ </li>
+
<li>
<p><a name="mode-100">テレフォンJJY</a> <a href="http://jjy.nict.go.jp/">http://jjy.nict.go.jp/</a> (英語と日本語)</p>
<p>テレフォンJJYは、電話回線による時刻配信サービスです。<br>
<p>デフォルトの日時問い合わせ処理間隔 6 ( 64 秒 ) は、このモードには、短すぎます。 "minpoll" は、8 ( 256 秒, 約 4 分 ) 以上を設定して下さい。<br>
日時問い合わせ処理間隔は、秒数を 2 のべき乗で指定します。 minpoll の値が、12 なら 4096 秒(約1時間)、14 なら 16384 秒(約4.5時間)、16 なら 65536 秒(約18時間)となります。</p><br>
</dd>
- <dt>fudge 127.127.40.X stratum 1 flag1 0|1 flag2 0|1 flag3 0|1 flag4 0|1</dt>
+ <dt>fudge 127.127.40.X flag1 0|1 flag2 0|1 flag3 0|1 flag4 0|1</dt>
<dd>
<p>Time1 は、受信機からの時刻に加算する調整時間を、固定小数点形式の秒で設定します。<br>
mode 100 の場合は、time1 で調整する時間を設定したほうが良いでしょう。<br>
<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-Style-Type" content="text/css">
<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/">
<body>
<h3>JJY Receivers</h3>
<p>Last update:
- <!-- #BeginDate format:En2m -->30-Apr-2015 05:53<!-- #EndDate -->
+ <!-- #BeginDate format:En2m -->15-May-2015 00:00<!-- #EndDate -->
UTC <a href="driver40.html">ENGLISH</a> <a href="driver40-ja.html">JAPANESE</a></p>
<hr>
<h4>Synopsis</h4>
Driver ID: <code>JJY</code><br>
Serial Port: <code>/dev/jjy<em>u</em></code>; See corresponding receiver
<h4>Description</h4>
- <p>This driver supports the following the JJY receivers and the GPS clock sold in Japan, and the time service through a telephone line.<br>
+ <p>This driver supports the following the JJY receivers and the GPS clock sold in Japan, and the time service through a telephone line.
+ </p>
+ <table width="100%">
+ <tr>
+ <td width="50%" style="vertical-align:top;">
<a href="#mode-1">Tristate Ltd. TS-JJY01, TS-JJY02</a><br>
<a href="#mode-2">C-DEX Co.,Ltd. JST2000</a><br>
<a href="#mode-3">Echo Keisokuki Co.,Ltd. LT-2000</a><br>
<a href="#mode-4">CITIZEN T.I.C. CO.,LTD. JJY-200</a><br>
<a href="#mode-5">Tristate Ltd. TS-GPSclock-01</a><br>
- <a href="#mode-100">Telephone JJY</a></p>
+ </td>
+ <td width="50%" style="vertical-align:top; border-left:solid; padding:0px 0px 0px 10px;">
+ <a href="#mode-6">SEIKO TIME SYSTEMS INC. TDC-300</a><br>
+ <a href="#mode-100">Telephone JJY</a><br>
+ </td>
+ </tr>
+ </table>
<ul>
<li>
<dl>
<dt>server 127.127.40.X mode 1</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1 time1 0.NNN flag1 0|1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN flag1 0|1</dt>
<dd>
<p>Time1 may specify a constant to be added to the time offset for the time from the receiver, a fixed-point decimal number in seconds. You may specify the time offset from several tens of milli-seconds ( 0.0NN seconds ) to a hundred and several tens of milli-seconds ( 0.1NN seconds ) for this clock.</p>
<p>Flag1 has no effect for time synchronization. When flag1 is set to 1, status commands are issued before DATE and STIM commands, and write a response text into the clockstats file.</p>
<dl>
<dt>server 127.127.40.X mode 2</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
</dl>
<br>
</dd>
<dl>
<dt>server 127.127.40.X mode 3</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
</dl>
<br>
</dd>
<dl>
<dt>server 127.127.40.X mode 4</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
</dl>
<br>
</dd>
<dl>
<dt>server 127.127.40.X mode 5</dt>
<dd><br></dd>
- <dt>fudge 127.127.40.X stratum 1 time1 0.NNN flag1 0|1</dt>
+ <dt>fudge 127.127.40.X time1 0.NNN flag1 0|1</dt>
<dd>
<p>Time1 may specify a constant to be added to the time offset for the time from the receiver, a fixed-point decimal number in seconds.</p>
<p>Flag1 has no effect for time synchronization. When a flag1 is set to 1, status command is issued before DATE and TIME commands, and write a response text into a clockstats file.</p>
</dl>
</li>
+ <li>
+ <p><a name="mode-6">SEIKO TIME SYSTEMS INC. TDC-300</a> <a href="http://www.seiko-sts.co.jp/">http://www.seiko-sts.co.jp/</a> (English and Japanese)</p><br>
+ <p>The TDC-300 must be set to the type 3 data format using the front panel menu display and the switches.</p>
+ <dl>
+ <dt>NTP configuration ( ntp.conf )</dt>
+ <dd><br>
+ <dl>
+ <dt>server 127.127.40.X mode 6</dt>
+ <dd><br></dd>
+ <dt>fudge 127.127.40.X time1 0.NNN</dt>
+ </dl>
+ <br>
+ </dd>
+ <dt>Interface</dt>
+ <dd>
+ <p>RS-232C, 2400 BPS, 8-bits, no parity, 1 stop bit</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></td>
+ <td></td>
+ <td><code>{STX}YYMMDDWHHMMSS{ETX}</code></td>
+ </tr>
+ <tr>
+ <td>( 5 to 10 mSec. before second )</td>
+ <td></td>
+ <td><code>{STX}{xE5}{ETX}</code></td>
+ </tr>
+ </table>
+ <br>
+ </dd>
+ </dl>
+ </li>
+
<li>
<p><a name="mode-100">Telephone JJY</a> <a href="http://jjy.nict.go.jp/">http://jjy.nict.go.jp/</a> (English and Japanese)</p>
<p>The telephone JJY is the time service through a public telephone line.<br>
<p>The default polling interval 6 ( 64 seconds ) is too short for this mode. The "minpoll" should be set to greater than or equal to 8 ( 256 seconds, about 4 minutes ).<br>
The interval time is given the value in second power of 2. The minpoll value 12 is 4096 seconds interval ( about 1 hour ), 14 is 16384 seconds interval ( about 4.5 hours ), 16 is 65536 seconds ( about 18 hours ), respectively.</p><br>
</dd>
- <dt>fudge 127.127.40.X stratum 1 flag1 0|1 flag2 0|1 flag3 0|1 flag4 0|1</dt>
+ <dt>fudge 127.127.40.X flag1 0|1 flag2 0|1 flag3 0|1 flag4 0|1</dt>
<dd>
<p>Time1 may specify a constant to be added to the time offset for the time from the receiver, a fixed-point decimal number in seconds.<br>
When the mode 100 is specified, the time1 may be specified in order to adjust the time offset.<br>
/* to put DATE command between before and after TIME's. */
/* Unify the writing clockstats of all JJY receivers. */
/* */
+/* 2015/05/15 */
+/* [Add] Support the SEIKO TIME SYSTEMS TDC-300 */
+/* */
/**********************************************************************/
#ifdef HAVE_CONFIG_H
#define SPEED232_ECHOKEISOKUKI_LT2000 B9600 /* UART speed (9600 baud) */
#define SPEED232_CITIZENTIC_JJY200 B4800 /* UART speed (4800 baud) */
#define SPEED232_TRISTATE_GPSCLOCK01 B38400 /* USB speed (38400 baud) */
+#define SPEED232_SEIKO_TIMESYS_TDC_300 B2400 /* UART speed (2400 baud) */
#define SPEED232_TELEPHONE B2400 /* UART speed (4800 baud) */
#define REFID "JJY" /* reference ID */
#define DESCRIPTION "JJY Receiver"
short iProcessState ; /* JJY_PROCESS_STATE_XXXXXX */
char bReceiveFlag ; /* Set and reset by jjy_receive */
char bLineError ; /* Reset by jjy_poll / Set by jjy_receive_xxxxxxxx*/
- int iCommandSeq ; /* 0:Idle Non-Zero:Issued */
+ short iCommandSeq ; /* 0:Idle Non-Zero:Issued */
+ short iReceiveSeq ;
int iLineCount ;
int year, month, day, hour, minute, second, msecond ;
int leapsecond ;
#define UNITTYPE_ECHOKEISOKUKI_LT2000 3
#define UNITTYPE_CITIZENTIC_JJY200 4
#define UNITTYPE_TRISTATE_GPSCLOCK01 5
+#define UNITTYPE_SEIKO_TIMESYS_TDC_300 6
#define UNITTYPE_TELEPHONE 100
#define JJY_PROCESS_STATE_IDLE 0
* |-- jjy_start_echokeisokuki_lt2000
* |-- jjy_start_citizentic_jjy200
* |-- jjy_start_tristate_gpsclock01
+ * |-- jjy_start_seiko_tsys_tdc_300
* |-- jjy_start_telephone
*
* jjy_shutdown
* |-- jjy_poll_echokeisokuki_lt2000
* |-- jjy_poll_citizentic_jjy200
* |-- jjy_poll_tristate_gpsclock01
+ * |-- jjy_poll_seiko_tsys_tdc_300
* |-- jjy_poll_telephone
* |-- teljjy_control
* |-- teljjy_XXXX_YYYY ( XXXX_YYYY is an event handler name. )
* | |-- jjy_synctime
* |-- jjy_receive_tristate_gpsclock01
* | |-- jjy_synctime
+ * |-- jjy_receive_seiko_tsys_tdc_300
+ * | |-- jjy_synctime
* |-- jjy_receive_telephone
* |-- modem_receive
* | |-- modem_control
static int jjy_start_echokeisokuki_lt2000 (int, struct peer *, struct jjyunit *);
static int jjy_start_citizentic_jjy200 (int, struct peer *, struct jjyunit *);
static int jjy_start_tristate_gpsclock01 (int, struct peer *, struct jjyunit *);
+static int jjy_start_seiko_tsys_tdc_300 (int, struct peer *, struct jjyunit *);
static int jjy_start_telephone (int, struct peer *, struct jjyunit *);
static void jjy_shutdown (int, struct peer *);
static void jjy_poll_echokeisokuki_lt2000 (int, struct peer *);
static void jjy_poll_citizentic_jjy200 (int, struct peer *);
static void jjy_poll_tristate_gpsclock01 (int, struct peer *);
+static void jjy_poll_seiko_tsys_tdc_300 (int, struct peer *);
static void jjy_poll_telephone (int, struct peer *);
static void jjy_receive (struct recvbuf *);
static int jjy_receive_echokeisokuki_lt2000 (struct recvbuf *);
static int jjy_receive_citizentic_jjy200 (struct recvbuf *);
static int jjy_receive_tristate_gpsclock01 (struct recvbuf *);
+static int jjy_receive_seiko_tsys_tdc_300 (struct recvbuf *);
static int jjy_receive_telephone (struct recvbuf *);
static void jjy_timer (int, struct peer *);
case 5 :
rc = jjy_start_tristate_gpsclock01 ( unit, peer, up ) ;
break ;
+ case 6 :
+ rc = jjy_start_seiko_tsys_tdc_300 ( unit, peer, up ) ;
+ break ;
case 100 :
rc = jjy_start_telephone ( unit, peer, up ) ;
break ;
rc = jjy_receive_tristate_gpsclock01 ( rbufp ) ;
break ;
+ case UNITTYPE_SEIKO_TIMESYS_TDC_300 :
+ rc = jjy_receive_seiko_tsys_tdc_300 ( rbufp ) ;
+ break ;
+
case UNITTYPE_TELEPHONE :
rc = jjy_receive_telephone ( rbufp ) ;
break ;
up->iProcessState = JJY_PROCESS_STATE_POLL ;
up->iCommandSeq = 0 ;
+ up->iReceiveSeq = 0 ;
up->iLineCount = 0 ;
up->bLineError = FALSE ;
up->iRawBufLen = 0 ;
jjy_poll_tristate_gpsclock01 ( unit, peer ) ;
break ;
+ case UNITTYPE_SEIKO_TIMESYS_TDC_300 :
+ jjy_poll_seiko_tsys_tdc_300 ( unit, peer ) ;
+ break ;
+
case UNITTYPE_TELEPHONE :
jjy_poll_telephone ( unit, peer ) ;
break ;
}
+/*################################################################################################*/
+/*################################################################################################*/
+/*## ##*/
+/*## The SEIKO TIME SYSTEMS TDC-300 ##*/
+/*## ##*/
+/*## server 127.127.40.X mode 6 ##*/
+/*## ##*/
+/*################################################################################################*/
+/*################################################################################################*/
+/* */
+/* Type Response Remarks */
+/* -------------------- ---------------------------------------- ---------------------------- */
+/* Type 1 <STX>HH:MM:SS<ETX> */
+/* Type 2 <STX>YYMMDDHHMMSSWLSCU<ETX> W:0(Sun)-6(Sat) */
+/* Type 3 <STX>YYMMDDWHHMMSS<ETX> W:0(Sun)-6(Sat) */
+/* <STX><xE5><ETX> 5 to 10 mSec. before second */
+/* */
+/*################################################################################################*/
+
+static struct jjyRawDataBreak seiko_tsys_tdc_300_raw_break [ ] =
+{
+ { "\x03", 1 }, { NULL, 0 }
+} ;
+
+/**************************************************************************************************/
+
+static int
+jjy_start_seiko_tsys_tdc_300 ( int unit, struct peer *peer, struct jjyunit *up )
+{
+
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_JJY, "Refclock: SEIKO TIME SYSTEMS TDC-300" ) ;
+
+ up->unittype = UNITTYPE_SEIKO_TIMESYS_TDC_300 ;
+ up->linespeed = SPEED232_SEIKO_TIMESYS_TDC_300 ;
+ up->linediscipline = LDISC_RAW ;
+
+ up->pRawBreak = seiko_tsys_tdc_300_raw_break ;
+ up->bWaitBreakString = TRUE ;
+
+ up->bSkipCntrlCharOnly = FALSE ;
+
+ return 0 ;
+
+}
+
+/**************************************************************************************************/
+
+static int
+jjy_receive_seiko_tsys_tdc_300 ( struct recvbuf *rbufp )
+{
+
+ struct peer *peer;
+ struct refclockproc *pp ;
+ struct jjyunit *up ;
+
+ char *pBuf, sLog [ 100 ] ;
+ int iLen, i ;
+ int rc, iWeekday ;
+ time_t now ;
+ struct tm *pTime ;
+
+ /* Initialize pointers */
+
+ peer = rbufp->recv_peer ;
+ pp = peer->procptr ;
+ up = pp->unitptr ;
+
+ if ( up->linediscipline == LDISC_RAW ) {
+ pBuf = up->sTextBuf ;
+ iLen = up->iTextBufLen ;
+ } else {
+ pBuf = pp->a_lastcode ;
+ iLen = pp->lencode ;
+ }
+
+ DEBUG_PRINTF_JJY_RECEIVE( "jjy_receive_seiko_tsys_tdc_300", iLen ) ;
+
+ /*
+ * TDC-300 sends a timestamp every second.
+ * So, a timestamp is ignored unless it is right after polled.
+ */
+
+ if ( up->iProcessState != JJY_PROCESS_STATE_RECEIVE ) {
+ return JJY_RECEIVE_SKIP ;
+ }
+
+ /* Process timestamp */
+
+ up->iReceiveSeq ++ ;
+
+ switch ( iLen ) {
+
+ case 8 : /* Type 1 : <STX>HH:MM:SS<ETX> */
+
+ for ( i = 0 ; i < iLen ; i ++ ) {
+ pBuf[i] &= 0x7F ;
+ }
+
+ rc = sscanf ( pBuf+1, "%2d:%2d:%2d",
+ &up->hour, &up->minute, &up->second ) ;
+
+ if ( rc != 3
+ || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+ /* Invalid time */
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_TIME,
+ rc, up->hour, up->minute, up->second ) ;
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
+ up->bLineError = TRUE ;
+ return JJY_RECEIVE_ERROR ;
+ } else if ( up->hour == 23 && up->minute == 59 && up->second >= 55 ) {
+ /* Uncertainty date guard */
+ return JJY_RECEIVE_WAIT ;
+ }
+
+ time( &now ) ;
+ pTime = localtime( &now ) ;
+ up->year = pTime->tm_year ;
+ up->month = pTime->tm_mon + 1 ;
+ up->day = pTime->tm_mday ;
+
+ break ;
+
+ case 17 : /* Type 2 : <STX>YYMMDDHHMMSSWLSCU<ETX> */
+
+ for ( i = 0 ; i < iLen ; i ++ ) {
+ pBuf[i] &= 0x7F ;
+ }
+
+ rc = sscanf ( pBuf+1, "%2d%2d%2d%2d%2d%2d%1d",
+ &up->year, &up->month, &up->day,
+ &up->hour, &up->minute, &up->second, &iWeekday ) ;
+
+ if ( rc != 7
+ || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
+ || iWeekday > 6
+ || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+ /* Invalid date and time */
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME,
+ rc, up->year, up->month, up->day,
+ up->hour, up->minute, up->second ) ;
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
+ up->bLineError = TRUE ;
+ return JJY_RECEIVE_ERROR ;
+ }
+
+ break ;
+
+ case 13 : /* Type 3 : <STX>YYMMDDWHHMMSS<ETX> */
+
+ rc = sscanf ( pBuf, "%2d%2d%2d%1d%2d%2d%2d",
+ &up->year, &up->month, &up->day, &iWeekday,
+ &up->hour, &up->minute, &up->second ) ;
+
+ if ( rc != 7
+ || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
+ || iWeekday > 6
+ || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+ /* Invalid date and time */
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_SSCANF_INVALID_DATETIME,
+ rc, up->year, up->month, up->day,
+ up->hour, up->minute, up->second ) ;
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
+ up->bLineError = TRUE ;
+ return JJY_RECEIVE_ERROR ;
+ }
+
+ return JJY_RECEIVE_WAIT ;
+
+ case 1 : /* Type 3 : <STX><xE5><ETX> */
+
+ if ( ( *pBuf & 0xFF ) != 0xE5 ) {
+ /* Invalid second signal */
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_REPLY,
+ up->sLineBuf ) ;
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
+ up->bLineError = TRUE ;
+ return JJY_RECEIVE_ERROR ;
+ } else if ( up->iReceiveSeq == 1 ) {
+ /* Wait for next timestamp */
+ up->iReceiveSeq -- ;
+ return JJY_RECEIVE_WAIT ;
+ } else if ( up->iReceiveSeq >= 3 ) {
+ /* Unexpected second signal */
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_UNEXPECTED_REPLY,
+ up->sLineBuf ) ;
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
+ up->bLineError = TRUE ;
+ return JJY_RECEIVE_ERROR ;
+ }
+
+ break ;
+
+ default : /* Unexpected reply length */
+
+ snprintf( sLog, sizeof(sLog)-1, JJY_CLOCKSTATS_MESSAGE_INVALID_LENGTH,
+ iLen ) ;
+ jjy_write_clockstats( peer, JJY_CLOCKSTATS_MARK_ERROR, sLog ) ;
+ up->bLineError = TRUE ;
+ return JJY_RECEIVE_ERROR ;
+
+ }
+
+ up->year += 2000 ;
+ up->msecond = 0 ;
+
+ jjy_synctime( peer, pp, up ) ;
+
+ return JJY_RECEIVE_DONE ;
+
+}
+
+/**************************************************************************************************/
+
+static void
+jjy_poll_seiko_tsys_tdc_300 ( int unit, struct peer *peer )
+{
+
+ struct refclockproc *pp ;
+ struct jjyunit *up ;
+
+ pp = peer->procptr ;
+ up = pp->unitptr ;
+
+ up->bLineError = FALSE ;
+
+}
+
/*################################################################################################*/
/*################################################################################################*/
/*## ##*/