]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
driver40.html, refclock_jjy.c, driver40-ja.html, ChangeLog:
authorTakao Abe <abe@ntp.org>
Fri, 15 May 2015 11:43:04 +0000 (11:43 +0000)
committerTakao Abe <abe@ntp.org>
Fri, 15 May 2015 11:43:04 +0000 (11:43 +0000)
  refclock_jjy.c supports the TDC-300

bk: 5555dbc8wgvA88eTUudE8u_62zXaMQ

ChangeLog
html/drivers/driver40-ja.html
html/drivers/driver40.html
ntpd/refclock_jjy.c

index 6dd8aba23567c68bb5d0e558a420cd11ae6def07..3fd77a2b5a7af2748a569204b0a7c8b4edb5a46f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -5,6 +5,7 @@
 * CID 1295478: Quiet a pedantic potential error from the fix for Bug 2776.
 * CID 1296235: Fix refclock_jjy.c and correcting type of the driver40-ja.html
 * CID 1269537: Clean up a line of dead code in getShmTime().
+* [Bug 2832] refclock_jjy.c supports the TDC-300
 * [Bug 2590] autogen-5.18.5.
 * [Bug 2612] restrict: Warn when 'monitor' can't be disabled because
   of 'limited'.
index 45c656d1fae83b5be2c9f2d3db6d46b43c4b8f1b..8b67e9009d40bcd5544c93f8a727335c8696233f 100644 (file)
@@ -5,6 +5,7 @@
        <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/">
@@ -15,7 +16,7 @@
        <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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="driver40.html">ENGLISH(英語)</a> &nbsp; <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">トライステート &nbsp; TS-JJY01, TS-JJY02</a><br>
                <a href="#mode-2">シーデックス &nbsp; JST2000</a><br>
                <a href="#mode-3">エコー計測器 &nbsp; LT-2000</a><br>
                <a href="#mode-4">シチズンTIC &nbsp; JJY-200</a><br>
                <a href="#mode-5">トライステート &nbsp; 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">セイコー タイム システム &nbsp; TDC-300</a><br>
+               <a href="#mode-100">テレフォンJJY</a><br>
+               </td>
+               </tr>
+               </table>
                <ul>
 
                        <li>
@@ -41,7 +52,7 @@
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 1</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1 &nbsp; time1 0.NNN &nbsp; flag1 0|1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN &nbsp; flag1 0|1</dt>
                                                        <dd>
                                                                <p>Time1 は、受信機からの時刻に加算する調整時間を、固定小数点形式の秒で設定します。<br>
                                                                この受信機には、数10ミリ秒 ( 0.0NN秒 ) から百数10ミリ秒 ( 0.1NN秒 ) の調整時間を設定すると良いでしょう。</p>
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 2</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN</dt>
                                                </dl>
                                                <br>
                                        </dd>
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 3</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN</dt>
                                                </dl>
                                                <br>
                                        </dd>
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 4</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN</dt>
                                                </dl>
                                                <br>
                                        </dd>
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 5</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1 &nbsp; time1 0.NNN &nbsp; flag1 0|1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN &nbsp; flag1 0|1</dt>
                                                        <dd>
                                                                <p>Time1 は、受信機からの時刻に加算する調整時間を、固定小数点形式の秒で設定します</p>
                                                                <p>Flag1 は、時刻同期には無関係です。Flag1 を 1 に設定すると、状態を問い合わせるコマンドを DATE コマンドと STIM コマンドの前に発行して、応答を clockstats ファイルに記録します。</p>
                                </dl>
                        </li>
 
+                       <li>
+                               <p><a name="mode-6">セイコー タイム システム &nbsp; TDC-300</a> &nbsp; <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 &nbsp; 127.127.40.X &nbsp; mode 6</dt>
+                                                       <dd><br></dd>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; 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>&nbsp;--&gt;&nbsp;</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> &nbsp; <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 &nbsp; 127.127.40.X &nbsp; stratum 1 &nbsp; flag1 0|1 &nbsp; flag2 0|1 &nbsp; flag3 0|1 &nbsp; flag4 0|1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; flag1 0|1 &nbsp; flag2 0|1 &nbsp; flag3 0|1 &nbsp; flag4 0|1</dt>
                                                        <dd>
                                                                <p>Time1 は、受信機からの時刻に加算する調整時間を、固定小数点形式の秒で設定します。<br>
                                                                mode 100 の場合は、time1 で調整する時間を設定したほうが良いでしょう。<br>
index 2fb7c151684e7ad03fd4de3dc2ba21cf4fda2520..356429e499e6d19367ed67a88ddb625ebe0bce1b 100644 (file)
@@ -5,6 +5,7 @@
        <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/">
@@ -15,7 +16,7 @@
        <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 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<a href="driver40.html">ENGLISH</a> &nbsp; <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. &nbsp; TS-JJY01, TS-JJY02</a><br>
                <a href="#mode-2">C-DEX Co.,Ltd. &nbsp; JST2000</a><br>
                <a href="#mode-3">Echo Keisokuki Co.,Ltd. &nbsp; LT-2000</a><br>
                <a href="#mode-4">CITIZEN T.I.C. CO.,LTD. &nbsp; JJY-200</a><br>
                <a href="#mode-5">Tristate Ltd. &nbsp; 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. &nbsp; TDC-300</a><br>
+               <a href="#mode-100">Telephone JJY</a><br>
+               </td>
+               </tr>
+               </table>
                <ul>
 
                        <li>
@@ -41,7 +52,7 @@
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 1</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1 &nbsp; time1 0.NNN &nbsp; flag1 0|1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN &nbsp; 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 &nbsp; 127.127.40.X &nbsp; mode 2</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN</dt>
                                                </dl>
                                                <br>
                                        </dd>
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 3</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN</dt>
                                                </dl>
                                                <br>
                                        </dd>
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 4</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN</dt>
                                                </dl>
                                                <br>
                                        </dd>
                                                <dl>
                                                        <dt>server &nbsp; 127.127.40.X &nbsp; mode 5</dt>
                                                        <dd><br></dd>
-                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; stratum 1 &nbsp; time1 0.NNN &nbsp; flag1 0|1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; time1 0.NNN &nbsp; 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. &nbsp; TDC-300</a> &nbsp; <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 &nbsp; 127.127.40.X &nbsp; mode 6</dt>
+                                                       <dd><br></dd>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; 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>&nbsp;--&gt;&nbsp;</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> &nbsp; <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 &nbsp; 127.127.40.X &nbsp; stratum 1 &nbsp; flag1 0|1 &nbsp; flag2 0|1 &nbsp; flag3 0|1 &nbsp; flag4 0|1</dt>
+                                                       <dt>fudge &nbsp; 127.127.40.X &nbsp; flag1 0|1 &nbsp; flag2 0|1 &nbsp; flag3 0|1 &nbsp; 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>
index c10bf64b10117defcf0df8e3cea248c8621cbeb9..fef829ca071b26f191e238172556ef0cf27f8127 100644 (file)
 /*             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"
@@ -164,7 +168,8 @@ struct jjyunit {
        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 ;
@@ -208,6 +213,7 @@ struct jjyunit {
 #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
@@ -227,6 +233,7 @@ struct jjyunit {
  *   |--  jjy_start_echokeisokuki_lt2000
  *   |--  jjy_start_citizentic_jjy200
  *   |--  jjy_start_tristate_gpsclock01
+ *   |--  jjy_start_seiko_tsys_tdc_300
  *   |--  jjy_start_telephone
  *
  *  jjy_shutdown
@@ -237,6 +244,7 @@ struct jjyunit {
  *   |--  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. )
@@ -256,6 +264,8 @@ struct jjyunit {
  *   |     |--  jjy_synctime
  *   |--  jjy_receive_tristate_gpsclock01
  *   |     |--  jjy_synctime
+ *   |--  jjy_receive_seiko_tsys_tdc_300
+ *   |     |--  jjy_synctime
  *   |--  jjy_receive_telephone
  *         |--  modem_receive
  *         |     |--  modem_control
@@ -287,6 +297,7 @@ static      int     jjy_start_cdex_jst2000          (int, struct peer *, struct jjyunit *);
 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 *);
@@ -297,6 +308,7 @@ static      void    jjy_poll_cdex_jst2000           (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 *);
@@ -305,6 +317,7 @@ static      int     jjy_receive_cdex_jst2000        (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 *);
@@ -472,6 +485,9 @@ jjy_start ( int unit, struct peer *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 ;
@@ -750,6 +766,10 @@ jjy_receive ( struct recvbuf *rbufp )
                        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 ;
@@ -890,6 +910,7 @@ jjy_poll ( int unit, struct peer *peer )
 
        up->iProcessState = JJY_PROCESS_STATE_POLL ;
        up->iCommandSeq = 0 ;
+       up->iReceiveSeq = 0 ;
        up->iLineCount = 0 ;
        up->bLineError = FALSE ;
        up->iRawBufLen = 0 ;
@@ -916,6 +937,10 @@ jjy_poll ( int unit, struct peer *peer )
                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 ;
@@ -2252,6 +2277,233 @@ jjy_poll_tristate_gpsclock01 ( int unit, struct peer *peer )
 
 }
 
+/*################################################################################################*/
+/*################################################################################################*/
+/*##                                                                                           ##*/
+/*##    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 ;
+
+}
+
 /*################################################################################################*/
 /*################################################################################################*/
 /*##                                                                                           ##*/