From: Dave Hart Date: Thu, 7 May 2009 05:10:54 +0000 (+0000) Subject: Updated JJY reference clock driver from Takao abe X-Git-Tag: NTP_4_2_4P7_RC6~7 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d9bff43d626211d7bfa3ad8fdf638798d75095a8;p=thirdparty%2Fntp.git Updated JJY reference clock driver from Takao abe Make ntpd the default project in Visual C++/Visual Studio bk: 4a026d5eqrFnr5sTJFv7-CS2OJPhxg --- diff --git a/ChangeLog b/ChangeLog index 6fdc947de..a7ffbbdd1 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,7 @@ +--- + +* Updated JJY reference clock driver from Takao abe + --- (4.2.4p7-RC5) 2009/05/02 Released by Harlan Stenn diff --git a/html/drivers/driver40.html b/html/drivers/driver40.html index 54e174746..1901dcdbf 100644 --- a/html/drivers/driver40.html +++ b/html/drivers/driver40.html @@ -5,7 +5,10 @@ + JJY Receivers + + @@ -13,122 +16,174 @@

JJY Receivers


Synopsis

- Address: 127.127.40.u
- Reference ID: JJY
- Driver ID: JJY
- Serial Port: /dev/jjyu; 9600 baud, 8-bits, no parity, 1 stop bit + Address: 127.127.40.u
+ Reference ID: JJY
+ Driver ID: JJY
+ Serial Port: /dev/jjyu; 9600|4800(See corresponding receiver) baud, 8-bits, no parity, 1 stop bit

Description

This driver supports the following JJY receivers sold in Japan.

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 http://www.nict.go.jp/ (English and Japanese) and http://jjy.nict.go.jp/ (English and Japanese)

The user is expected to provide a symbolic link to an available serial port device. This is typically performed by a command such as:

-

ln -s /dev/ttyS0 /dev/jjy0

-

Windows NT does not support symbolic links to device files. COMX: 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:

+

ln -s /dev/ttyS0 /dev/jjy0

+

Windows NT does not support symbolic links to device files. COMX: 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:

Monitor Data

-

The driver writes each timecode as received to the clockstats file.

+

The driver writes each timecode as received to the clockstats file.

Fudge Factors

-
time1 time +
time1 time
Specifies the time offset calibration factor, in seconds and fraction, with default 0.0. -
time2 time +
time2 time
Not used by this driver. -
stratum number +
stratum number
Specifies the driver stratum, in decimal from 0 to 15, with default 0. -
refid string -
Specifies the driver reference identifier, an ASCII string from one to four characters, with default JJY. -
flag1 0 | 1 +
refid string +
Specifies the driver reference identifier, an ASCII string from one to four characters, with default JJY. +
flag1 0 | 1
Not used by this driver. -
flag2 0 | 1 +
flag2 0 | 1
Not used by this driver. -
flag3 0 | 1 +
flag3 0 | 1
Not used by this driver. -
flag4 0 | 1 +
flag4 0 | 1
Not used by this driver.

- \ No newline at end of file + diff --git a/ntpd/refclock_jjy.c b/ntpd/refclock_jjy.c index 9d1419a6f..32c58c7e8 100644 --- a/ntpd/refclock_jjy.c +++ b/ntpd/refclock_jjy.c @@ -74,6 +74,9 @@ /* [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 @@ -131,12 +134,26 @@ /* Second signal */ /* */ /**********************************************************************/ +/* */ +/* The CITIZEN T.I.C CO., LTD. JJY receiver JJY200 */ +/* */ +/* Command Response Remarks */ +/* ------------ ---------------------- --------------------- */ +/* 'XX YY/MM/DD W HH:MM:SS */ +/* 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) */ @@ -149,6 +166,7 @@ struct jjyunit { 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 ; @@ -164,6 +182,7 @@ struct jjyunit { #define UNITTYPE_TRISTATE_JJY01 1 #define UNITTYPE_CDEX_JST2000 2 #define UNITTYPE_ECHOKEISOKUKI_LT2000 3 +#define UNITTYPE_CITIZENTIC_JJY200 4 /* * Function prototypes @@ -174,10 +193,12 @@ 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_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 @@ -217,6 +238,7 @@ jjy_start ( int unit, struct peer *peer ) int fd ; char *pDeviceName ; short iDiscipline ; + int iSpeed232 ; #ifdef DEBUG if ( debug ) { @@ -238,9 +260,22 @@ jjy_start ( int unit, struct peer *peer ) */ 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 ) ; @@ -248,7 +283,7 @@ jjy_start ( int unit, struct peer *peer ) 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 ; } @@ -299,6 +334,11 @@ jjy_start ( int unit, struct peer *peer ) break ; } break ; + case 4 : + up->unittype = UNITTYPE_CITIZENTIC_JJY200 ; + up->lineexpect = 1 ; + up->charexpect[0] = 23 ; /* 'XX YY/MM/DD W HH:MM:SS */ + break ; default : msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode", ntoa(&peer->srcadr), peer->ttl ) ; @@ -434,6 +474,10 @@ jjy_receive ( struct recvbuf *rbufp ) rc = jjy_receive_echokeisokuki_lt2000 ( rbufp ) ; break ; + case UNITTYPE_CITIZENTIC_JJY200 : + rc = jjy_receive_citizentic_jjy200 ( rbufp ) ; + break ; + default : rc = 0 ; break ; @@ -453,6 +497,8 @@ jjy_receive ( struct recvbuf *rbufp ) if ( rc == 0 ) return ; + up->bPollFlag = 0 ; + if ( up->lineerror != 0 ) { refclock_report ( peer, CEVNT_BADREPLY ) ; strcpy ( sLogText, "BAD REPLY [" ) ; @@ -865,6 +911,93 @@ jjy_receive_echokeisokuki_lt2000 ( struct recvbuf *rbufp ) } +/**************************************************************************************************/ + +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 */ + + 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 */ /**************************************************************************************************/ @@ -893,6 +1026,7 @@ jjy_poll ( int unit, struct peer *peer ) pp->polls ++ ; + up->bPollFlag = 1 ; up->linecount = 0 ; up->lineerror = 0 ; up->charcount = 0 ; @@ -911,6 +1045,10 @@ jjy_poll ( int unit, struct peer *peer ) jjy_poll_echokeisokuki_lt2000 ( unit, peer ) ; break ; + case UNITTYPE_CITIZENTIC_JJY200 : + jjy_poll_citizentic_jjy200 ( unit, peer ) ; + break ; + default : break ; @@ -1006,6 +1144,16 @@ jjy_poll_echokeisokuki_lt2000 ( int unit, struct peer *peer ) } +/**************************************************************************************************/ + +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 diff --git a/ports/winnt/ntp.sln b/ports/winnt/ntp.sln index bfdb3cf67..f519adb35 100644 --- a/ports/winnt/ntp.sln +++ b/ports/winnt/ntp.sln @@ -1,15 +1,15 @@  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}