Lines Matching refs:up

88 /*	       Code clean up ( Remove unreachable codes ) in	      */
100 /* [Change] Split the start up routine into each JJY receivers. */
177 /* Set up by the function "jjy_start_xxxxxxxx" */
366 jjy_start, /* start up driver */
376 * Start up driver return code
441 #define DEBUG_PRINTF_JJY_RECEIVE(sFunc,iLen) { if ( debug ) { printf ( "refclock_jjy.c : %s : iProcessState=%d bLineError=%d iCommandSeq=%d iLineCount=%d iTimestampCount=%d iLen=%d\n", sFunc, up->iProcessState, up->bLineError, up->iCommandSeq, up->iLineCount, up->iTimestampCount, iLen ) ; } }
454 struct jjyunit *up ;
467 up = emalloc( sizeof(*up) ) ;
468 if ( up == NULL ) {
472 memset ( up, 0, sizeof(*up) ) ;
474 up->bInitError = FALSE ;
475 up->iProcessState = JJY_PROCESS_STATE_IDLE ;
476 up->bReceiveFlag = FALSE ;
477 up->iCommandSeq = 0 ;
478 up->iLineCount = 0 ;
479 up->iTimestampCount = 0 ;
480 up->bWaitBreakString = FALSE ;
481 up->iRawBufLen = up->iLineBufLen = up->iTextBufLen = 0 ;
482 up->bSkipCntrlCharOnly = TRUE ;
484 /* Set up the device name */
496 rc = jjy_start_tristate_jjy01 ( unit, peer, up ) ;
499 rc = jjy_start_cdex_jst2000 ( unit, peer, up ) ;
502 rc = jjy_start_echokeisokuki_lt2000 ( unit, peer, up ) ;
505 rc = jjy_start_citizentic_jjy200 ( unit, peer, up ) ;
508 rc = jjy_start_tristate_gpsclock01 ( unit, peer, up ) ;
511 rc = jjy_start_seiko_tsys_tdc_300 ( unit, peer, up ) ;
514 rc = jjy_start_telephone ( unit, peer, up ) ;
518 rc = jjy_start_telephone ( unit, peer, up ) ;
522 free ( (void*) up ) ;
530 free ( (void*) up ) ;
535 fd = refclock_open ( &peer->srcadr, sDeviceName, up->linespeed, up->linediscipline ) ;
537 free ( (void*) up ) ;
547 pp->unitptr = up ;
555 free ( up ) ;
577 struct jjyunit *up;
583 up = pp->unitptr ;
587 if ( NULL != up ) {
588 free ( up ) ;
606 struct jjyunit *up ;
621 up = pp->unitptr ;
626 if ( up->linediscipline == LDISC_RAW ) {
637 i < pp->lencode && up->iRawBufLen < MAX_RAWBUF - 2 ;
638 i ++ , up->iRawBufLen ++ ) {
639 up->sRawBuf[up->iRawBufLen] = pp->a_lastcode[i] ;
641 up->sRawBuf[up->iRawBufLen] = 0 ;
671 if ( up->iProcessState == JJY_PROCESS_STATE_IDLE
672 || up->iProcessState == JJY_PROCESS_STATE_DONE
673 || up->iProcessState == JJY_PROCESS_STATE_ERROR ) {
675 up->iRawBufLen = 0 ;
690 up->iLineCount ++ ;
692 up->iProcessState = JJY_PROCESS_STATE_RECEIVE ;
693 up->bReceiveFlag = TRUE ;
696 iBreakPosition = up->iRawBufLen - 1 ;
697 for ( ; up->iProcessState == JJY_PROCESS_STATE_RECEIVE ; ) {
699 if ( up->linediscipline == LDISC_RAW ) {
701 if ( up->bWaitBreakString ) {
702 iBreakPosition = getRawDataBreakPosition( up, iReadRawBuf ) ;
705 if ( up->iRawBufLen < MAX_RAWBUF - 2
711 iBreakPosition = up->iRawBufLen - 1 ;
715 iBreakPosition = up->iRawBufLen - 1 ;
719 up->iLineBufLen = up->iTextBufLen = 0 ;
723 up->sLineBuf[up->iLineBufLen] = up->sRawBuf[i] ;
724 up->iLineBufLen ++ ;
727 if ( ! iscntrl( (u_char)up->sRawBuf[i] ) ) {
728 up->sTextBuf[up->iTextBufLen] = up->sRawBuf[i] ;
729 up->iTextBufLen ++ ;
733 up->sLineBuf[up->iLineBufLen] = 0 ;
734 up->sTextBuf[up->iTextBufLen] = 0 ;
736 printf( "refclock_jjy.c : %s : up->iLineBufLen=%d up->iTextBufLen=%d\n",
737 sFunctionName, up->iLineBufLen, up->iTextBufLen ) ;
740 if ( up->bSkipCntrlCharOnly && up->iTextBufLen == 0 ) {
742 printf( "refclock_jjy.c : %s : Skip cntrl char only : up->iRawBufLen=%d iReadRawBuf=%d iBreakPosition=%d\n",
743 sFunctionName, up->iRawBufLen, iReadRawBuf, iBreakPosition ) ;
745 if ( iBreakPosition + 1 < up->iRawBufLen ) {
756 if ( up->linediscipline == LDISC_RAW ) {
757 pBuf = up->sLineBuf ;
758 iLen = up->iLineBufLen ;
769 switch ( up->unittype ) {
808 up->iProcessState = JJY_PROCESS_STATE_DONE ;
811 up->iProcessState = JJY_PROCESS_STATE_ERROR ;
817 if ( up->linediscipline == LDISC_RAW ) {
822 if ( iReadRawBuf >= up->iRawBufLen ) {
828 if ( up->linediscipline == LDISC_CLK ) {
834 if ( up->linediscipline == LDISC_RAW && iReadRawBuf > 0 ) {
835 for ( i = 0, j = iReadRawBuf ; j < up->iRawBufLen ; i ++, j++ ) {
836 up->sRawBuf[i] = up->sRawBuf[j] ;
838 up->iRawBufLen -= iReadRawBuf ;
839 if ( up->iRawBufLen < 0 ) {
840 up->iRawBufLen = 0 ;
844 up->bReceiveFlag = FALSE ;
851 getRawDataBreakPosition ( struct jjyunit *up, int iStart )
856 if ( iStart >= up->iRawBufLen ) {
863 for ( i = iStart ; i < up->iRawBufLen ; i ++ ) {
865 for ( j = 0 ; up->pRawBreak[j].pString != NULL ; j ++ ) {
867 if ( i + up->pRawBreak[j].iLength <= up->iRawBufLen ) {
869 if ( strncmp( up->sRawBuf + i,
870 up->pRawBreak[j].pString,
871 up->pRawBreak[j].iLength ) == 0 ) {
875 iStart, i + up->pRawBreak[j].iLength - 1 ) ;
877 return i + up->pRawBreak[j].iLength - 1 ;
900 struct jjyunit *up;
904 up = pp->unitptr ;
906 if ( up->bInitError ) {
911 if ( pp->polls > 0 && up->iLineCount == 0 ) {
933 up->iProcessState = JJY_PROCESS_STATE_POLL ;
934 up->iCommandSeq = 0 ;
935 up->iReceiveSeq = 0 ;
936 up->iLineCount = 0 ;
937 up->bLineError = FALSE ;
938 up->iRawBufLen = 0 ;
940 switch ( up->unittype ) {
985 struct jjyunit *up ;
994 up = pp->unitptr ;
996 if ( up->bReceiveFlag ) {
999 printf ( "refclock_jjy.c : jjy_timer : up->bReceiveFlag= TRUE : Timer skipped.\n" ) ;
1005 switch ( up->unittype ) {
1022 jjy_synctime ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
1028 pp->year = up->year ;
1029 pp->day = ymd2yd( up->year, up->month, up->day ) ;
1030 pp->hour = up->hour ;
1031 pp->minute = up->minute ;
1032 pp->second = up->second ;
1033 pp->nsec = up->msecond * 1000000 ;
1067 up->year, up->month, up->day,
1068 up->hour, up->minute, up->second, up->msecond,
1157 jjy_start_tristate_jjy01 ( int unit, struct peer *peer, struct jjyunit *up )
1162 up->unittype = UNITTYPE_TRISTATE_JJY01 ;
1163 up->linespeed = SPEED232_TRISTATE_JJY01 ;
1164 up->linediscipline = LDISC_CLK ;
1166 time( &(up->tLastAdjustedTimestamp) ) ;
1167 up->bStusReplyAdjustedAtLeastOnce = FALSE ;
1178 struct jjyunit *up ;
1196 up = pp->unitptr ;
1198 if ( up->linediscipline == LDISC_RAW ) {
1199 pBuf = up->sTextBuf ;
1200 iLen = up->iTextBufLen ;
1210 if ( tristate_jjy01_command_sequence[up->iCommandSeq].command == NULL ) {
1215 up->bLineError = TRUE ;
1221 if ( iLen != tristate_jjy01_command_sequence[up->iCommandSeq].iExpectedReplyLength[0]
1222 && iLen != tristate_jjy01_command_sequence[up->iCommandSeq].iExpectedReplyLength[1] ) {
1227 up->bLineError = TRUE ;
1233 switch ( tristate_jjy01_command_sequence[up->iCommandSeq].commandNumber ) {
1238 &up->year, &up->month, &up->day ) ;
1240 if ( rc != 3 || up->year < 2000 || 2099 <= up->year
1241 || up->month < 1 || 12 < up->month
1242 || up->day < 1 || 31 < up->day ) {
1245 rc, up->year, up->month, up->day ) ;
1247 up->bLineError = TRUE ;
1256 if ( up->iTimestampCount >= 2 ) {
1259 up->iTimestampCount ) ;
1261 up->bLineError = TRUE ;
1266 &up->hour, &up->minute, &up->second ) ;
1268 if ( rc != 3 || up->hour > 23 || up->minute > 59 ||
1269 up->second > 60 ) {
1272 rc, up->hour, up->minute, up->second ) ;
1274 up->bLineError = TRUE ;
1278 up->iTimestamp[up->iTimestampCount] = ( up->hour * 60 + up->minute ) * 60 + up->second ;
1280 up->iTimestampCount++ ;
1282 up->msecond = 0 ;
1291 up->bStusReplyAdjusted = TRUE ;
1292 up->bStusReplyAdjustedAtLeastOnce = TRUE ;
1293 time( &(up->tLastAdjustedTimestamp) ) ;
1297 up->bStusReplyAdjusted = FALSE ;
1303 up->bLineError = TRUE ;
1321 up->bLineError = TRUE ;
1332 up->bLineError = TRUE ;
1337 if ( up->iTimestampCount == 2 ) {
1341 fSeconds = difftime( now, up->tLastAdjustedTimestamp ) ;
1344 && ( ! up->bStusReplyAdjusted )
1345 && ( fSeconds >= ( pp->fudgetime2 * 3600 ) || ( ! up->bStusReplyAdjustedAtLeastOnce ) ) ) {
1358 } else if ( up->iTimestamp[1] - 2 <= up->iTimestamp[0]
1359 && up->iTimestamp[0] <= up->iTimestamp[1] ) {
1361 jjy_synctime( peer, pp, up ) ;
1363 } else if ( up->iTimestamp[0] > up->iTimestamp[1] ) {
1366 up->iTimestamp[0], up->iTimestamp[1] ) ;
1372 up->iTimestamp[0], up->iTimestamp[1] ) ;
1374 up->bLineError = TRUE ;
1382 if ( tristate_jjy01_command_sequence[up->iCommandSeq].command != NULL ) {
1383 up->iCommandSeq ++ ;
1386 if ( tristate_jjy01_command_sequence[up->iCommandSeq].command == NULL ) {
1391 pCmd = tristate_jjy01_command_sequence[up->iCommandSeq].command ;
1392 iCmdLen = tristate_jjy01_command_sequence[up->iCommandSeq].commandLength ;
1413 struct jjyunit *up ;
1419 up = pp->unitptr ;
1421 up->bLineError = FALSE ;
1422 up->iTimestampCount = 0 ;
1426 up->iCommandSeq = 2 ;
1427 up->iLineCount = 2 ;
1430 up->bStusReplyAdjusted = FALSE ;
1434 printf ( "%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X up->iLineCount=%d\n",
1436 up->iLineCount ) ;
1444 up->iCommandSeq ++ ;
1446 pCmd = tristate_jjy01_command_sequence[up->iCommandSeq].command ;
1447 iCmdLen = tristate_jjy01_command_sequence[up->iCommandSeq].commandLength ;
1480 jjy_start_cdex_jst2000 ( int unit, struct peer *peer, struct jjyunit *up )
1485 up->unittype = UNITTYPE_CDEX_JST2000 ;
1486 up->linespeed = SPEED232_CDEX_JST2000 ;
1487 up->linediscipline = LDISC_RAW ;
1489 up->pRawBreak = cdex_jst2000_raw_break ;
1490 up->bWaitBreakString = TRUE ;
1492 up->bSkipCntrlCharOnly = FALSE ;
1504 struct jjyunit *up ;
1516 up = pp->unitptr ;
1518 if ( up->linediscipline == LDISC_RAW ) {
1519 pBuf = up->sTextBuf ;
1520 iLen = up->iTextBufLen ;
1530 if ( up->iCommandSeq != 1 ) {
1535 up->bLineError = TRUE ;
1541 if ( up->iLineBufLen < 17 || up->sLineBuf[up->iLineBufLen-1] != 0x03 ) {
1552 up->bLineError = TRUE ;
1559 &up->year, &up->month, &up->day,
1560 &up->hour, &up->minute, &up->second,
1561 &up->msecond ) ;
1563 if ( rc != 7 || up->month < 1 || up->month > 12 ||
1564 up->day < 1 || up->day > 31 || up->hour > 23 ||
1565 up->minute > 59 || up->second > 60 ) {
1568 rc, up->year, up->month, up->day,
1569 up->hour, up->minute, up->second ) ;
1571 up->bLineError = TRUE ;
1575 up->year += 2000 ;
1576 up->msecond *= 100 ;
1578 jjy_synctime( peer, pp, up ) ;
1591 struct jjyunit *up ;
1594 up = pp->unitptr ;
1596 up->bLineError = FALSE ;
1597 up->iRawBufLen = 0 ;
1598 up->iLineBufLen = 0 ;
1599 up->iTextBufLen = 0 ;
1605 up->iCommandSeq ++ ;
1646 jjy_start_echokeisokuki_lt2000 ( int unit, struct peer *peer, struct jjyunit *up )
1651 up->unittype = UNITTYPE_ECHOKEISOKUKI_LT2000 ;
1652 up->linespeed = SPEED232_ECHOKEISOKUKI_LT2000 ;
1653 up->linediscipline = LDISC_CLK ;
1655 up->operationmode = ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS ;
1667 struct jjyunit *up ;
1680 up = pp->unitptr ;
1682 if ( up->linediscipline == LDISC_RAW ) {
1683 pBuf = up->sTextBuf ;
1684 iLen = up->iTextBufLen ;
1694 if ( ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND
1696 || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS
1698 || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS
1704 up->bLineError = TRUE ;
1708 if ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND && iLen == 15 ) {
1724 up->bLineError = TRUE ;
1730 if ( ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_REQUEST_SEND
1732 || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS
1734 || ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS
1739 &up->year, &up->month, &up->day,
1740 &up->hour, &up->minute, &up->second ) ;
1742 if ( rc != 6 || up->month < 1 || up->month > 12
1743 || up->day < 1 || up->day > 31
1744 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
1747 rc, up->year, up->month, up->day,
1748 up->hour, up->minute, up->second ) ;
1750 up->bLineError = TRUE ;
1754 up->year += 2000 ;
1756 if ( up->operationmode == ECHOKEISOKUKI_LT2000_MODE_CONTINUOUS
1757 || up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS ) {
1760 up->msecond = 500 ;
1761 up->second -- ;
1762 if ( up->second < 0 ) {
1763 up->second = 59 ;
1764 up->minute -- ;
1765 if ( up->minute < 0 ) {
1766 up->minute = 59 ;
1767 up->hour -- ;
1768 if ( up->hour < 0 ) {
1769 up->hour = 23 ;
1770 up->day -- ;
1771 if ( up->day < 1 ) {
1772 up->month -- ;
1773 if ( up->month < 1 ) {
1774 up->month = 12 ;
1775 up->year -- ;
1784 jjy_synctime( peer, pp, up ) ;
1789 if (up->operationmode == ECHOKEISOKUKI_LT2000_MODE_SWITCHING_CONTINUOUS ) {
1812 struct jjyunit *up ;
1817 up = pp->unitptr ;
1819 up->bLineError = FALSE ;
1825 switch ( up->operationmode ) {
1861 jjy_start_citizentic_jjy200 ( int unit, struct peer *peer, struct jjyunit *up )
1866 up->unittype = UNITTYPE_CITIZENTIC_JJY200 ;
1867 up->linespeed = SPEED232_CITIZENTIC_JJY200 ;
1868 up->linediscipline = LDISC_CLK ;
1880 struct jjyunit *up ;
1894 up = pp->unitptr ;
1896 if ( up->linediscipline == LDISC_RAW ) {
1897 pBuf = up->sTextBuf ;
1898 iLen = up->iTextBufLen ;
1911 if ( up->iProcessState != JJY_PROCESS_STATE_RECEIVE ) {
1922 up->bLineError = TRUE ;
1930 &up->year, &up->month, &up->day, &iWeekday,
1931 &up->hour, &up->minute, &up->second ) ;
1938 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
1940 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
1943 rc, up->year, up->month, up->day,
1944 up->hour, up->minute, up->second ) ;
1946 up->bLineError = TRUE ;
1958 up->year += 2000 ;
1959 up->msecond = 0 ;
1961 jjy_synctime( peer, pp, up ) ;
1974 struct jjyunit *up ;
1977 up = pp->unitptr ;
1979 up->bLineError = FALSE ;
2042 jjy_start_tristate_gpsclock01 ( int unit, struct peer *peer, struct jjyunit *up )
2047 up->unittype = UNITTYPE_TRISTATE_GPSCLOCK01 ;
2048 up->linespeed = SPEED232_TRISTATE_GPSCLOCK01 ;
2049 up->linediscipline = LDISC_CLK ;
2064 struct jjyunit *up ;
2080 up = pp->unitptr ;
2082 if ( up->linediscipline == LDISC_RAW ) {
2083 pBuf = up->sTextBuf ;
2084 iLen = up->iTextBufLen ;
2131 if ( tristate_gps01_command_sequence[up->iCommandSeq].command == NULL ) {
2136 up->bLineError = TRUE ;
2142 if ( iLen != tristate_gps01_command_sequence[up->iCommandSeq].iExpectedReplyLength ) {
2147 up->bLineError = TRUE ;
2153 switch ( tristate_gps01_command_sequence[up->iCommandSeq].commandNumber ) {
2157 rc = sscanf ( pBuf, "%4d/%2d/%2d", &up->year, &up->month, &up->day ) ;
2159 if ( rc != 3 || up->year < 2000 || 2099 <= up->year
2160 || up->month < 1 || 12 < up->month
2161 || up->day < 1 || 31 < up->day ) {
2164 rc, up->year, up->month, up->day ) ;
2166 up->bLineError = TRUE ;
2174 if ( up->iTimestampCount >= 2 ) {
2177 up->iTimestampCount ) ;
2179 up->bLineError = TRUE ;
2184 &up->hour, &up->minute, &up->second ) ;
2187 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
2190 rc, up->hour, up->minute, up->second ) ;
2192 up->bLineError = TRUE ;
2196 up->iTimestamp[up->iTimestampCount] = ( up->hour * 60 + up->minute ) * 60 + up->second ;
2198 up->iTimestampCount++ ;
2200 up->msecond = 0 ;
2215 up->bLineError = TRUE ;
2226 up->bLineError = TRUE ;
2231 if ( up->iTimestampCount == 2 ) {
2234 if ( up->iTimestamp[1] - 2 <= up->iTimestamp[0]
2235 && up->iTimestamp[0] <= up->iTimestamp[1] ) {
2237 jjy_synctime( peer, pp, up ) ;
2239 } else if ( up->iTimestamp[0] > up->iTimestamp[1] ) {
2242 up->iTimestamp[0], up->iTimestamp[1] ) ;
2248 up->iTimestamp[0], up->iTimestamp[1] ) ;
2250 up->bLineError = TRUE ;
2256 if ( tristate_gps01_command_sequence[up->iCommandSeq].command == NULL ) {
2258 jjy_synctime( peer, pp, up ) ;
2264 if ( tristate_gps01_command_sequence[up->iCommandSeq].command != NULL ) {
2265 up->iCommandSeq ++ ;
2268 if ( tristate_gps01_command_sequence[up->iCommandSeq].command == NULL ) {
2270 up->iProcessState = JJY_PROCESS_STATE_DONE ;
2274 pCmd = tristate_gps01_command_sequence[up->iCommandSeq].command ;
2275 iCmdLen = tristate_gps01_command_sequence[up->iCommandSeq].commandLength ;
2296 struct jjyunit *up ;
2302 up = pp->unitptr ;
2304 up->iTimestampCount = 0 ;
2308 up->iCommandSeq = 1 ;
2309 up->iLineCount = 1 ;
2314 printf ( "%s (refclock_jjy.c) : flag1=%X CLK_FLAG1=%X up->iLineCount=%d\n",
2316 up->iLineCount ) ;
2324 up->iCommandSeq ++ ;
2326 pCmd = tristate_gps01_command_sequence[up->iCommandSeq].command ;
2327 iCmdLen = tristate_gps01_command_sequence[up->iCommandSeq].commandLength ;
2363 jjy_start_seiko_tsys_tdc_300 ( int unit, struct peer *peer, struct jjyunit *up )
2368 up->unittype = UNITTYPE_SEIKO_TIMESYS_TDC_300 ;
2369 up->linespeed = SPEED232_SEIKO_TIMESYS_TDC_300 ;
2370 up->linediscipline = LDISC_RAW ;
2372 up->pRawBreak = seiko_tsys_tdc_300_raw_break ;
2373 up->bWaitBreakString = TRUE ;
2375 up->bSkipCntrlCharOnly = FALSE ;
2389 struct jjyunit *up ;
2401 up = pp->unitptr ;
2403 if ( up->linediscipline == LDISC_RAW ) {
2404 pBuf = up->sTextBuf ;
2405 iLen = up->iTextBufLen ;
2418 if ( up->iProcessState != JJY_PROCESS_STATE_RECEIVE ) {
2424 up->iReceiveSeq ++ ;
2435 &up->hour, &up->minute, &up->second ) ;
2438 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
2441 rc, up->hour, up->minute, up->second ) ;
2443 up->bLineError = TRUE ;
2445 } else if ( up->hour == 23 && up->minute == 59 && up->second >= 55 ) {
2452 up->year = pTime->tm_year ;
2453 up->month = pTime->tm_mon + 1 ;
2454 up->day = pTime->tm_mday ;
2465 &up->year, &up->month, &up->day,
2466 &up->hour, &up->minute, &up->second, &iWeekday ) ;
2469 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
2471 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
2474 rc, up->year, up->month, up->day,
2475 up->hour, up->minute, up->second ) ;
2477 up->bLineError = TRUE ;
2486 &up->year, &up->month, &up->day, &iWeekday,
2487 &up->hour, &up->minute, &up->second ) ;
2490 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
2492 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
2495 rc, up->year, up->month, up->day,
2496 up->hour, up->minute, up->second ) ;
2498 up->bLineError = TRUE ;
2509 up->sLineBuf ) ;
2511 up->bLineError = TRUE ;
2513 } else if ( up->iReceiveSeq == 1 ) {
2515 up->iReceiveSeq -- ;
2517 } else if ( up->iReceiveSeq >= 3 ) {
2520 up->sLineBuf ) ;
2522 up->bLineError = TRUE ;
2533 up->bLineError = TRUE ;
2538 up->year += 2000 ;
2539 up->msecond = 0 ;
2541 jjy_synctime( peer, pp, up ) ;
2554 struct jjyunit *up ;
2557 up = pp->unitptr ;
2559 up->bLineError = FALSE ;
2729 #define DEBUG_TELJJY_PRINTF(sFunc) { if ( debug ) { printf ( "refclock_jjy.c : %s : iClockState=%d iClockEvent=%d iTeljjySilentTimer=%d iTeljjyStateTimer=%d iClockCommandSeq=%d\n", sFunc, up->iClockState, up->iClockEvent, up->iTeljjySilentTimer, up->iTeljjyStateTimer, up->iClockCommandSeq ) ; } }
2737 jjy_start_telephone ( int unit, struct peer *peer, struct jjyunit *up )
2747 up->unittype = UNITTYPE_TELEPHONE ;
2748 up->linespeed = SPEED232_TELEPHONE ;
2749 up->linediscipline = LDISC_RAW ;
2751 up->pRawBreak = teljjy_raw_break ;
2752 up->bWaitBreakString = TRUE ;
2754 up->bSkipCntrlCharOnly = TRUE ;
2756 up->iClockState = TELJJY_STATE_IDLE ;
2757 up->iClockEvent = TELJJY_EVENT_NULL ;
2763 up->bInitError = TRUE ;
2769 up->bInitError = TRUE ;
2784 up->bInitError = TRUE ;
2791 up->bInitError = TRUE ;
2800 up->bInitError = TRUE ;
2808 up->bInitError = TRUE ;
2821 up->bInitError = TRUE ;
2857 struct jjyunit *up ;
2864 up = pp->unitptr ;
2868 if ( up->iClockState == TELJJY_STATE_IDLE
2869 || up->iClockState == TELJJY_STATE_DAILOUT
2870 || up->iClockState == TELJJY_STATE_BYE ) {
2872 iPreviousModemState = getModemState( up ) ;
2876 if ( iPreviousModemState != up->iModemState ) {
2878 if ( isModemStateDisconnect( up->iModemState ) ) {
2879 up->iClockEvent = TELJJY_EVENT_DISCONNECT ;
2880 teljjy_control ( peer, pp, up ) ;
2881 } else if ( isModemStateConnect( up->iModemState ) ) {
2882 up->iClockEvent = TELJJY_EVENT_CONNECT ;
2883 teljjy_control ( peer, pp, up ) ;
2891 if ( up->linediscipline == LDISC_RAW ) {
2892 pBuf = up->sTextBuf ;
2893 iLen = up->iTextBufLen ;
2899 up->iTeljjySilentTimer = 0 ;
2900 if ( iLen == 7 && strncmp( pBuf, "Name ? ", 7 ) == 0 ) { up->iClockEvent = TELJJY_EVENT_LOGIN ; }
2901 else if ( iLen == 1 && strncmp( pBuf, ">" , 1 ) == 0 ) { up->iClockEvent = TELJJY_EVENT_PROMPT ; }
2902 else if ( iLen >= 1 && strncmp( pBuf, "?" , 1 ) == 0 ) { up->iClockEvent = TELJJY_EVENT_ERROR ; }
2903 else { up->iClockEvent = TELJJY_EVENT_DATA ; }
2905 teljjy_control ( peer, pp, up ) ;
2921 struct jjyunit *up ;
2924 up = pp->unitptr ;
2928 if ( up->iClockState == TELJJY_STATE_IDLE ) {
2929 up->iRawBufLen = 0 ;
2930 up->iLineBufLen = 0 ;
2931 up->iTextBufLen = 0 ;
2934 up->iClockEvent = TELJJY_EVENT_START ;
2935 teljjy_control ( peer, pp, up ) ;
2949 struct jjyunit *up ;
2953 up = pp->unitptr ;
2957 if ( iTeljjySilentTimeout[up->iClockState] != 0 ) {
2958 up->iTeljjySilentTimer++ ;
2959 if ( iTeljjySilentTimeout[up->iClockState] <= up->iTeljjySilentTimer ) {
2960 up->iClockEvent = TELJJY_EVENT_SILENT ;
2961 teljjy_control ( peer, pp, up ) ;
2965 if ( iTeljjyStateTimeout[up->iClockState] != 0 ) {
2966 up->iTeljjyStateTimer++ ;
2967 if ( iTeljjyStateTimeout[up->iClockState] <= up->iTeljjyStateTimer ) {
2968 up->iClockEvent = TELJJY_EVENT_TIMEOUT ;
2969 teljjy_control ( peer, pp, up ) ;
2973 if ( isModemStateTimerOn( up ) ) {
2975 iPreviousModemState = getModemState( up ) ;
2979 if ( iPreviousModemState != up->iModemState ) {
2981 if ( isModemStateDisconnect( up->iModemState ) ) {
2982 up->iClockEvent = TELJJY_EVENT_DISCONNECT ;
2983 teljjy_control ( peer, pp, up ) ;
2984 } else if ( isModemStateConnect( up->iModemState ) ) {
2985 up->iClockEvent = TELJJY_EVENT_CONNECT ;
2986 teljjy_control ( peer, pp, up ) ;
2997 teljjy_control ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3005 rc = (*pTeljjyHandler[up->iClockEvent][up->iClockState])( peer, pp, up ) ;
3008 iPostEvent = iTeljjyPostEvent[up->iClockEvent][up->iClockState] ;
3012 up->iClockState, iTeljjyNextState[up->iClockEvent][up->iClockState], iPostEvent ) ;
3015 up->iTeljjySilentTimer = 0 ;
3016 if ( up->iClockState != iTeljjyNextState[up->iClockEvent][up->iClockState] ) {
3018 up->iTeljjyStateTimer = 0 ;
3019 up->bLineError = FALSE ;
3020 up->iClockCommandSeq = 0 ;
3021 up->iTimestampCount = 0 ;
3022 up->iLoopbackCount = 0 ;
3024 up->bLoopbackTimeout[i] = FALSE ;
3026 if (iTeljjyNextState[up->iClockEvent][up->iClockState] == TELJJY_STATE_IDLE ) {
3028 up->iProcessState = JJY_PROCESS_STATE_DONE ;
3031 up->iClockState = iTeljjyNextState[up->iClockEvent][up->iClockState] ;
3036 up->iClockEvent = iPostEvent ;
3037 teljjy_control ( peer, pp, up ) ;
3040 up->iClockEvent = TELJJY_EVENT_NULL ;
3047 teljjy_setDelay ( struct peer *peer, struct jjyunit *up )
3053 gettimeofday( &(up->delayTime[up->iLoopbackCount]), NULL ) ;
3055 up->delayTime[up->iLoopbackCount].tv_sec -= up->sendTime[up->iLoopbackCount].tv_sec ;
3056 up->delayTime[up->iLoopbackCount].tv_usec -= up->sendTime[up->iLoopbackCount].tv_usec ;
3057 if ( up->delayTime[up->iLoopbackCount].tv_usec < 0 ) {
3058 up->delayTime[up->iLoopbackCount].tv_sec -- ;
3059 up->delayTime[up->iLoopbackCount].tv_usec += 1000000 ;
3062 milliSecond = up->delayTime[up->iLoopbackCount].tv_usec / 1000 ;
3063 microSecond = up->delayTime[up->iLoopbackCount].tv_usec - milliSecond * 1000 ;
3064 milliSecond += up->delayTime[up->iLoopbackCount].tv_sec * 1000 ;
3082 teljjy_getDelay ( struct peer *peer, struct jjyunit *up )
3097 up->iLoopbackValidCount = 0 ;
3099 for ( i = 0 ; i < MAX_LOOPBACK && i < up->iLoopbackCount ; i ++ ) {
3100 if ( up->bLoopbackTimeout[i]
3101 || up->delayTime[i].tv_sec > iThresholdSecond
3102 || ( up->delayTime[i].tv_sec == iThresholdSecond
3103 && up->delayTime[i].tv_usec > iThresholdMicroSecond ) ) {
3106 if ( up->iLoopbackValidCount == 0 ) {
3107 minTime.tv_sec = up->delayTime[i].tv_sec ;
3108 minTime.tv_usec = up->delayTime[i].tv_usec ;
3109 maxTime.tv_sec = up->delayTime[i].tv_sec ;
3110 maxTime.tv_usec = up->delayTime[i].tv_usec ;
3112 } else if ( minTime.tv_sec > up->delayTime[i].tv_sec
3113 || ( minTime.tv_sec == up->delayTime[i].tv_sec
3114 && minTime.tv_usec > up->delayTime[i].tv_usec ) ) {
3115 minTime.tv_sec = up->delayTime[i].tv_sec ;
3116 minTime.tv_usec = up->delayTime[i].tv_usec ;
3118 } else if ( maxTime.tv_sec < up->delayTime[i].tv_sec
3119 || ( maxTime.tv_sec == up->delayTime[i].tv_sec
3120 && maxTime.tv_usec < up->delayTime[i].tv_usec ) ) {
3121 maxTime.tv_sec = up->delayTime[i].tv_sec ;
3122 maxTime.tv_usec = up->delayTime[i].tv_usec ;
3125 up->iLoopbackValidCount ++ ;
3128 if ( up->iLoopbackValidCount < 2 ) {
3134 for ( i = 0 ; i < MAX_LOOPBACK && i < up->iLoopbackCount ; i ++ ) {
3135 if ( up->bLoopbackTimeout[i]
3136 || up->delayTime[i].tv_sec > iThresholdSecond
3137 || ( up->delayTime[i].tv_sec == iThresholdSecond
3138 && up->delayTime[i].tv_usec > iThresholdMicroSecond ) ) {
3141 if ( up->iLoopbackValidCount >= 3 && i == maxIndex ) {
3144 if ( up->iLoopbackValidCount >= 4 && i == minIndex ) {
3147 averTime.tv_usec += up->delayTime[i].tv_usec ;
3170 teljjy_idle_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3181 teljjy_idle_dialout ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3194 teljjy_dial_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3205 teljjy_dial_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3216 teljjy_dial_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3227 teljjy_login_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3238 teljjy_login_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3249 teljjy_login_conn ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3256 up->bLineError = FALSE ;
3257 up->iClockCommandSeq = 0 ;
3258 up->iTimestampCount = 0 ;
3259 up->iLoopbackCount = 0 ;
3261 up->bLoopbackTimeout[i] = FALSE ;
3270 teljjy_login_login ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3295 teljjy_login_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3306 up->iTeljjySilentTimer = 0 ;
3314 teljjy_login_error ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3325 teljjy_conn_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3336 teljjy_conn_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3347 teljjy_conn_send ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3356 if ( up->iClockCommandSeq > 0
3357 && teljjy_command_sequence[up->iClockCommandSeq].command == NULL ) {
3362 if ( up->iClockCommandSeq == 0 && peer->ttl == 100 ) {
3365 up->iClockCommandSeq = TELJJY_COMMAND_START_SKIP_LOOPBACK ;
3367 } else if ( up->iClockCommandSeq == 0 && peer->ttl != 100 ) {
3370 up->iLoopbackCount = 0 ;
3372 up->bLoopbackTimeout[i] = FALSE ;
3375 } else if ( up->iClockCommandSeq > 0 && peer->ttl != 100
3376 && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK
3377 && up->iLoopbackCount < MAX_LOOPBACK ) {
3382 up->iClockCommandSeq, up->iLoopbackCount ) ;
3386 teljjy_setDelay( peer, up ) ;
3388 up->iLoopbackCount ++ ;
3392 up->iClockCommandSeq++ ;
3394 pCmd = teljjy_command_sequence[up->iClockCommandSeq].command ;
3395 iLen = teljjy_command_sequence[up->iClockCommandSeq].commandLength ;
3403 if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) {
3405 if ( up->iLoopbackCount < MAX_LOOPBACK ) {
3406 gettimeofday( &(up->sendTime[up->iLoopbackCount]), NULL ) ;
3407 up->bLoopbackMode = TRUE ;
3412 up->iClockCommandSeq, up->iLoopbackCount, MAX_LOOPBACK ) ;
3415 up->bLoopbackMode = FALSE ;
3419 up->bLoopbackMode = FALSE ;
3424 if ( teljjy_command_sequence[up->iClockCommandSeq+1].command == NULL ) {
3444 teljjy_conn_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3455 if ( up->linediscipline == LDISC_RAW ) {
3456 pBuf = up->sTextBuf ;
3457 iLen = up->iTextBufLen ;
3463 if ( teljjy_command_sequence[up->iClockCommandSeq].iEchobackReplyLength == iLen
3464 && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK
3465 && up->sTextBuf[0] == *(teljjy_command_sequence[up->iClockCommandSeq].command)
3466 && up->iLoopbackCount < MAX_LOOPBACK ) {
3469 teljjy_setDelay( peer, up ) ;
3471 up->iLoopbackCount ++ ;
3473 } else if ( teljjy_command_sequence[up->iClockCommandSeq].iEchobackReplyLength == iLen
3474 && strncmp( pBuf, teljjy_command_sequence[up->iClockCommandSeq].command, iLen ) == 0 ) {
3479 } else if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyLength == iLen
3480 && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_4DATE ) {
3483 rc = sscanf ( pBuf, "%4d%2d%2d", &up->year, &up->month, &up->day ) ;
3485 if ( rc != 3 || up->year < 2000 || 2099 <= up->year
3486 || up->month < 1 || 12 < up->month || up->day < 1 || 31 < up->day ) {
3489 rc, up->year, up->month, up->day ) ;
3491 up->bLineError = TRUE ;
3494 } else if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyLength == iLen
3495 && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LEAPSEC
3499 rc = sscanf ( pBuf, "%2d", &up->leapsecond ) ;
3501 if ( rc != 1 || up->leapsecond < -1 || 1 < up->leapsecond ) {
3506 up->bLineError = TRUE ;
3509 } else if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyLength == iLen
3510 && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_TIME ) {
3513 rc = sscanf ( pBuf, "%2d%2d%2d", &up->hour, &up->minute, &up->second ) ;
3515 if ( rc != 3 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
3518 rc, up->hour, up->minute, up->second ) ;
3520 up->bLineError = TRUE ;
3522 up->iTimestamp[up->iTimestampCount] = ( up->hour * 60 + up->minute ) * 60 + up->second ;
3524 up->iTimestampCount++ ;
3526 if ( up->iTimestampCount == 6 && ! up->bLineError ) {
3529 up->bLineError,
3530 up->iTimestamp[3], up->iTimestamp[4], up->iTimestamp[5] ) ;
3536 up->msecond = 0 ;
3539 up->msecond = teljjy_getDelay( peer, up ) ;
3540 if (up->msecond < 0 ) {
3541 up->msecond = 0 ;
3546 if ( ( up->iTimestamp[3] - 15 ) <= up->iTimestamp[2]
3547 && up->iTimestamp[2] <= up->iTimestamp[3]
3548 && ( up->iTimestamp[3] + 1 ) == up->iTimestamp[4]
3549 && ( up->iTimestamp[4] + 1 ) == up->iTimestamp[5] ) {
3552 jjy_synctime( peer, pp, up ) ;
3558 up->msecond, up->iLoopbackValidCount, MAX_LOOPBACK ) ;
3563 up->iLoopbackValidCount, MAX_LOOPBACK ) ;
3571 } else if ( teljjy_command_sequence[up->iClockCommandSeq].iEchobackReplyLength != iLen
3572 && teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) {
3581 up->bLineError = TRUE ;
3595 teljjy_conn_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3602 if ( up->iClockCommandSeq >= 1
3603 && up->iClockCommandSeq < TELJJY_COMMAND_START_SKIP_LOOPBACK ) {
3610 if ( teljjy_command_sequence[up->iClockCommandSeq].iExpectedReplyType == TELJJY_REPLY_LOOPBACK ) {
3611 up->bLoopbackTimeout[up->iLoopbackCount] = TRUE ;
3613 up->iTeljjySilentTimer = 0 ;
3614 return teljjy_conn_send( peer, pp, up ) ;
3625 up->iTeljjySilentTimer = 0 ;
3633 teljjy_conn_error ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3644 teljjy_bye_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3655 teljjy_bye_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3666 teljjy_bye_modem ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3803 #define DEBUG_MODEM_PRINTF(sFunc) { if ( debug ) { printf ( "refclock_jjy.c : %s : iModemState=%d iModemEvent=%d iModemSilentTimer=%d iModemStateTimer=%d\n", sFunc, up->iModemState, up->iModemEvent, up->iModemSilentTimer, up->iModemStateTimer ) ; } }
3811 getModemState ( struct jjyunit *up )
3813 return up->iModemState ;
3835 isModemStateTimerOn ( struct jjyunit *up )
3837 return ( iModemSilentTimeout[up->iModemState] != 0 || iModemStateTimeout[up->iModemState] != 0 ) ;
3846 struct jjyunit *up;
3849 up = pp->unitptr ;
3853 up->iModemEvent = MODEM_EVENT_INITIALIZE ;
3855 modem_control ( peer, pp, up ) ;
3865 struct jjyunit *up;
3868 up = pp->unitptr ;
3872 up->iModemEvent = MODEM_EVENT_DISCONNECT ;
3874 modem_control ( peer, pp, up ) ;
3885 struct jjyunit *up;
3896 up = pp->unitptr ;
3900 if ( up->linediscipline == LDISC_RAW ) {
3901 pBuf = up->sTextBuf ;
3902 iLen = up->iTextBufLen ;
3908 if ( iLen == 2 && strncmp( pBuf, "OK" , 2 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_OK ; }
3909 else if ( iLen == 7 && strncmp( pBuf, "CONNECT" , 7 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_CONNECT ; }
3910 else if ( iLen == 4 && strncmp( pBuf, "RING" , 4 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_RING ; }
3911 else if ( iLen == 10 && strncmp( pBuf, "NO CARRIER" , 10 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_NO_CARRIER ; }
3912 else if ( iLen == 5 && strncmp( pBuf, "ERROR" , 5 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_ERROR ; }
3913 else if ( iLen >= 8 && strncmp( pBuf, "CONNECT " , 8 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_CONNECT_X ; }
3914 else if ( iLen == 11 && strncmp( pBuf, "NO DAILTONE", 11 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_NO_DAILTONE ; }
3915 else if ( iLen == 4 && strncmp( pBuf, "BUSY" , 4 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_BUSY ; }
3916 else if ( iLen == 9 && strncmp( pBuf, "NO ANSWER" , 9 ) == 0 ) { up->iModemEvent = MODEM_EVENT_RESP_NO_ANSWER ; }
3917 else { up->iModemEvent = MODEM_EVENT_RESP_UNKNOWN ; }
3926 printf ( "refclock_jjy.c : modem_receive : iLen=%zu pBuf=[%s] iModemEvent=%d\n", iCopyLen, sResp, up->iModemEvent ) ;
3929 modem_control ( peer, pp, up ) ;
3942 struct jjyunit *up ;
3945 up = pp->unitptr ;
3949 if ( iModemSilentTimeout[up->iModemState] != 0 ) {
3950 up->iModemSilentTimer++ ;
3951 if ( iModemSilentTimeout[up->iModemState] <= up->iModemSilentTimer ) {
3952 up->iModemEvent = MODEM_EVENT_SILENT ;
3953 modem_control ( peer, pp, up ) ;
3957 if ( iModemStateTimeout[up->iModemState] != 0 ) {
3958 up->iModemStateTimer++ ;
3959 if ( iModemStateTimeout[up->iModemState] <= up->iModemStateTimer ) {
3960 up->iModemEvent = MODEM_EVENT_TIMEOUT ;
3961 modem_control ( peer, pp, up ) ;
3970 modem_control ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
3978 rc = (*pModemHandler[up->iModemEvent][up->iModemState])( peer, pp, up ) ;
3981 iPostEvent = iModemPostEvent[up->iModemEvent][up->iModemState] ;
3985 up->iModemState, iModemNextState[up->iModemEvent][up->iModemState], iPostEvent ) ;
3989 if ( up->iModemState != iModemNextState[up->iModemEvent][up->iModemState] ) {
3990 up->iModemSilentCount = 0 ;
3991 up->iModemStateTimer = 0 ;
3992 up->iModemCommandSeq = 0 ;
3995 up->iModemState = iModemNextState[up->iModemEvent][up->iModemState] ;
3999 up->iModemEvent = iPostEvent ;
4000 modem_control ( peer, pp, up ) ;
4003 up->iModemEvent = MODEM_EVENT_NULL ;
4009 modem_disc_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4020 modem_disc_init ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4031 modem_init_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4042 modem_init_start ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4047 up->iModemCommandSeq = 0 ;
4055 return modem_init_resp00( peer, pp, up ) ;
4061 modem_init_resp00 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4072 up->iModemCommandSeq++ ;
4074 switch ( up->iModemCommandSeq ) {
4169 modem_init_resp04 ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4174 return modem_init_resp00( peer, pp, up ) ;
4180 modem_init_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4196 modem_dial_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4207 modem_dial_dialout ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4242 modem_dial_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4252 return modem_conn_escape( peer, pp, up ) ;
4258 modem_dial_connect ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4269 modem_dial_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4279 modem_esc_disc( peer, pp, up ) ;
4287 modem_conn_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4298 modem_conn_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4309 modem_esc_ignore ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4320 modem_esc_escape ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4345 modem_esc_data ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4350 up->iModemSilentTimer = 0 ;
4358 modem_esc_silent ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )
4363 up->iModemSilentCount ++ ;
4365 if ( up->iModemSilentCount < iModemStateTimeout[up->iModemState] / iModemSilentTimeout[up->iModemState] ) {
4371 modem_esc_escape( peer, pp, up ) ;
4372 up->iModemSilentTimer = 0 ;
4381 return modem_esc_disc( peer, pp, up ) ;
4386 modem_esc_disc ( struct peer *peer, struct refclockproc *pp, struct jjyunit *up )