Deleted Added
full compact
76a77,79
> /* 2009/04/05 */
> /* [Add] Support the CITIZEN T.I.C JJY-200 receiver */
> /* */
133a137,146
> /* */
> /* 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) */
> /* */
> /**********************************************************************/
139a153,156
> #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) */
151a169
> char bPollFlag ; /* Set by jjy_pool and Reset by jjy_receive */
166a185
> #define UNITTYPE_CITIZENTIC_JJY200 4
176a196
> static void jjy_poll_citizentic_jjy200 P((int, struct peer *));
180a201
> static int jjy_receive_citizentic_jjy200 P((struct recvbuf *));
219a241
> int iSpeed232 ;
241,243c263,278
< 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 ;
251c286
< if ( ! ( fd = refclock_open ( pDeviceName, SPEED232, iDiscipline ) ) ) {
---
> if ( ! ( fd = refclock_open ( pDeviceName, iSpeed232, iDiscipline ) ) ) {
301a337,341
> case 4 :
> up->unittype = UNITTYPE_CITIZENTIC_JJY200 ;
> up->lineexpect = 1 ;
> up->charexpect[0] = 23 ; /* 'XX YY/MM/DD W HH:MM:SS<CR> */
> break ;
436a477,480
> case UNITTYPE_CITIZENTIC_JJY200 :
> rc = jjy_receive_citizentic_jjy200 ( rbufp ) ;
> break ;
>
455a500,501
> up->bPollFlag = 0 ;
>
868a915,1001
>
> 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 ;
>
> }
>
> /**************************************************************************************************/
895a1029
> up->bPollFlag = 1 ;
913a1048,1051
> case UNITTYPE_CITIZENTIC_JJY200 :
> jjy_poll_citizentic_jjy200 ( unit, peer ) ;
> break ;
>
1008a1147,1156
> /**************************************************************************************************/
>
> static void
> jjy_poll_citizentic_jjy200 ( int unit, struct peer *peer )
> {
>
> /* Do nothing ( up->bPollFlag is set by the jjy_poll ) */
>
> }
>