Lines Matching +full:config +full:- +full:complete +full:- +full:timeout +full:- +full:us

2  * refclock_acts - clock driver for the NIST/USNO/PTB/NPL Computer Time
6 #include <config.h>
25 * This driver supports the US (NIST, USNO) and European (PTB, NPL,
33 * This driver requires a modem with a Hayes-compatible command set and
35 * modem setup string is hard-coded in the driver and may require
41 * followed by the number itself, including the long-distance prefix
76 * Phone: (303) 494-4774 (Boulder, CO); (808) 335-4721 (Hawaii)
85 * 47999 90-04-18 21:39:15 50 0 +.1 045.0 UTC(NIST) *<CR><LF>
89 * the on-time markers echoed by the driver and used by NIST to measure
91 * recently been changed to eliminate the * on-time indicator. The
94 * US Naval Observatory (USNO)
96 * Phone: (202) 762-1594 (Washington, DC); (719) 567-6742 (Boulder, CO)
98 * Data Format (two lines, repeating at one-second intervals)
106 * * on-time marker for previous timecode
119 * 1995-01-23 20:58:51 MEZ 10402303260219950123195849740+40000500<CR><LF>
133 #define PRECISION (-10) /* precision assumed (about 1 ms) */
166 * B1 US answer tone
174 * Y1 enable long-space disconnect
182 #define SETUP 3 /* setup timeout */
183 #define REDIAL 30 /* redial timeout */
184 #define ANSWER 60 /* answer timeout */
185 #define TIMECODE 60 /* message timeout */
204 int timer; /* timeout counter */
207 l_fp tstamp; /* on-time timestamp */
255 up->unit = unit; in acts_start()
256 pp = peer->procptr; in acts_start()
257 pp->unitptr = up; in acts_start()
258 pp->io.clock_recv = acts_receive; in acts_start()
259 pp->io.srcclock = peer; in acts_start()
260 pp->io.datalen = 0; in acts_start()
261 pp->io.fd = -1; in acts_start()
266 peer->precision = PRECISION; in acts_start()
267 pp->clockdesc = DESCRIPTION; in acts_start()
268 memcpy(&pp->refid, REFID, 4); in acts_start()
269 peer->sstclktype = CTL_SST_TS_TELEPHONE; in acts_start()
270 up->bufptr = up->buf; in acts_start()
282 * acts_shutdown - shut down the clock
296 pp = peer->procptr; in acts_shutdown()
297 up = pp->unitptr; in acts_shutdown()
304 * acts_receive - receive data from the serial interface
314 char tbuf[sizeof(up->buf)]; in acts_receive()
323 * the message and at the '*' and '#' on-time characters. in acts_receive()
325 peer = rbufp->recv_peer; in acts_receive()
326 pp = peer->procptr; in acts_receive()
327 up = pp->unitptr; in acts_receive()
328 octets = sizeof(up->buf) - (up->bufptr - up->buf); in acts_receive()
329 refclock_gtraw(rbufp, tbuf, octets, &pp->lastrec); in acts_receive()
332 if (up->bufptr == up->buf) { in acts_receive()
333 up->tstamp = pp->lastrec; in acts_receive()
336 *up->bufptr = '\0'; in acts_receive()
337 up->bufptr = up->buf; in acts_receive()
338 acts_message(peer, up->buf); in acts_receive()
341 *up->bufptr++ = *tptr; in acts_receive()
343 up->tstamp = pp->lastrec; in acts_receive()
352 * acts_message - process message
371 pp = peer->procptr; in acts_message()
372 up = pp->unitptr; in acts_message()
379 switch (up->state) { in acts_message()
401 up->retry, sys_phone[up->retry]); in acts_message()
402 if (ioctl(pp->io.fd, TIOCMBIS, &dtr) < 0) in acts_message()
404 refclock_write(peer, sys_phone[up->retry], in acts_message()
405 strlen(sys_phone[up->retry]), in acts_message()
408 up->retry++; in acts_message()
409 up->state = S_CONNECT; in acts_message()
410 up->timer = ANSWER; in acts_message()
424 up->state = S_MSG; in acts_message()
425 up->timer = TIMECODE; in acts_message()
436 if (up->msgcnt < MAXCODE) in acts_message()
444 * Other response. Tell us about it. in acts_message()
452 * acts_timeout - called on timeout
468 * when first started and at timeout. in acts_timeout()
470 pp = peer->procptr; in acts_timeout()
471 up = pp->unitptr; in acts_timeout()
479 if (-1 != pp->io.fd) in acts_timeout()
487 if (pp->sloppyclockflag & CLK_FLAG2) { in acts_timeout()
489 up->unit); in acts_timeout()
507 up->unit); in acts_timeout()
508 fd = refclock_open(&peer->srcadr, device, SPEED232, LDISC_ACTS | in acts_timeout()
514 pp->io.fd = fd; in acts_timeout()
515 if (!io_addclock(&pp->io)) { in acts_timeout()
518 pp->io.fd = -1; in acts_timeout()
521 up->msgcnt = 0; in acts_timeout()
522 up->bufptr = up->buf; in acts_timeout()
528 if (sys_phone[up->retry] == NULL) { in acts_timeout()
530 up->state = S_MSG; in acts_timeout()
531 up->timer = TIMECODE; in acts_timeout()
536 * Initialize the modem. This works with Hayes- in acts_timeout()
544 up->state = S_SETUP; in acts_timeout()
545 up->timer = SETUP; in acts_timeout()
556 * In CONNECT state the call did not complete. Abort the call. in acts_timeout()
568 if (up->msgcnt == 0) { in acts_timeout()
571 pp->lastref = pp->lastrec; in acts_timeout()
572 record_clock_stats(&peer->srcadr, pp->a_lastcode); in acts_timeout()
582 * acts_close - close and prepare for next call.
598 pp = peer->procptr; in acts_close()
599 up = pp->unitptr; in acts_close()
600 if (pp->io.fd != -1) { in acts_close()
603 if (ioctl(pp->io.fd, TIOCMBIC, &dtr) < 0) in acts_close()
605 io_closeclock(&pp->io); in acts_close()
606 pp->io.fd = -1; in acts_close()
608 if (pp->sloppyclockflag & CLK_FLAG2) { in acts_close()
610 LOCKFILE, up->unit); in acts_close()
613 if (up->msgcnt == 0 && up->retry > 0) { in acts_close()
614 if (sys_phone[up->retry] != NULL) { in acts_close()
615 up->state = S_IDLE; in acts_close()
616 up->timer = REDIAL; in acts_close()
620 up->state = S_IDLE; in acts_close()
621 up->timer = 0; in acts_close()
626 * acts_poll - called by the transmit routine
640 * the timeout routine and state machine. in acts_poll()
642 pp = peer->procptr; in acts_poll()
643 up = pp->unitptr; in acts_poll()
644 switch (peer->ttl) { in acts_poll()
656 * intervals determined by the poll event or specified timeout. in acts_poll()
671 pp->polls++; in acts_poll()
672 if (S_IDLE == up->state) { in acts_poll()
673 up->retry = 0; in acts_poll()
680 * acts_timer - called at one-second intervals
692 * This routine implments a timeout which runs for a programmed in acts_timer()
697 pp = peer->procptr; in acts_timer()
698 up = pp->unitptr; in acts_timer()
699 if (up->timer == 0) { in acts_timer()
700 if (pp->sloppyclockflag & CLK_FLAG1) { in acts_timer()
701 pp->sloppyclockflag &= ~CLK_FLAG1; in acts_timer()
705 up->timer--; in acts_timer()
706 if (up->timer == 0) in acts_timer()
707 acts_timeout(peer, up->state); in acts_timer()
712 * acts_timecode - identify the service and parse the timecode message
731 char flag; /* ACTS on-time character (* or #) */ in acts_timecode()
747 pp = peer->procptr; in acts_timecode()
748 up = pp->unitptr; in acts_timecode()
749 pp->nsec = 0; in acts_timecode()
753 * For USNO format on-time character '*', which is on a line by in acts_timecode()
757 if (*str == '*' && up->msgcnt > 0) in acts_timecode()
763 * ACTS format A: "jjjjj yy-mm-dd hh:mm:ss ds l uuu aaaaa in acts_timecode()
768 "%5ld %2d-%2d-%2d %2d:%2d:%2d %2d %1d %3lf %5lf %9s %c", in acts_timecode()
769 &mjd, &pp->year, &month, &day, &pp->hour, in acts_timecode()
770 &pp->minute, &pp->second, &dst, &leap, &dut1, in acts_timecode()
775 pp->day = ymd2yd(pp->year, month, day); in acts_timecode()
776 pp->leap = LEAP_NOWARNING; in acts_timecode()
778 pp->leap = LEAP_ADDSECOND; in acts_timecode()
780 pp->leap = LEAP_DELSECOND; in acts_timecode()
781 memcpy(&pp->refid, REFACTS, 4); in acts_timecode()
782 up->msgcnt++; in acts_timecode()
783 if (flag != '#' && up->msgcnt < 10) in acts_timecode()
793 &mjd, &pp->day, &pp->hour, &pp->minute, in acts_timecode()
794 &pp->second, utc) != 6) { in acts_timecode()
800 * Wait for the on-time character, which follows in a in acts_timecode()
804 pp->leap = LEAP_NOWARNING; in acts_timecode()
805 memcpy(&pp->refid, REFUSNO, 4); in acts_timecode()
806 up->msgcnt++; in acts_timecode()
810 * PTB/NPL format: "yyyy-mm-dd hh:mm:ss MEZ" in acts_timecode()
814 "%*4d-%*2d-%*2d %*2d:%*2d:%2d %*5c%*12c%4d%2d%2d%2d%2d%5ld%2lf%c%2d%3lf%*15c%c", in acts_timecode()
815 &pp->second, &pp->year, &month, &day, &pp->hour, in acts_timecode()
816 &pp->minute, &mjd, &dut1, &leapdir, &leapmonth, in acts_timecode()
821 pp->leap = LEAP_NOWARNING; in acts_timecode()
824 pp->leap = LEAP_ADDSECOND; in acts_timecode()
825 else if (leapdir == '-') in acts_timecode()
826 pp->leap = LEAP_DELSECOND; in acts_timecode()
828 pp->day = ymd2yd(pp->year, month, day); in acts_timecode()
829 memcpy(&pp->refid, REFPTB, 4); in acts_timecode()
830 up->msgcnt++; in acts_timecode()
839 &synchar, &pp->day, &pp->hour, &pp->minute, in acts_timecode()
840 &pp->second, &dstchar, &tz) != 7) { in acts_timecode()
844 pp->leap = LEAP_NOWARNING; in acts_timecode()
846 pp->leap = LEAP_NOTINSYNC; in acts_timecode()
847 memcpy(&pp->refid, REFWWVB, 4); in acts_timecode()
848 up->msgcnt++; in acts_timecode()
856 &synchar, &qualchar, &pp->year, &pp->day, in acts_timecode()
857 &pp->hour, &pp->minute, &pp->second, &pp->nsec, in acts_timecode()
862 pp->nsec *= 1000000; in acts_timecode()
863 pp->leap = LEAP_NOWARNING; in acts_timecode()
865 pp->leap = LEAP_NOTINSYNC; in acts_timecode()
867 pp->leap = LEAP_ADDSECOND; in acts_timecode()
868 memcpy(&pp->refid, REFWWVB, 4); in acts_timecode()
869 up->msgcnt++; in acts_timecode()
874 * message or timeout. in acts_timecode()
886 peer->refid = pp->refid; in acts_timecode()
887 pp->lastrec = up->tstamp; in acts_timecode()
888 if (up->msgcnt == 0) in acts_timecode()
891 strlcpy(pp->a_lastcode, str, sizeof(pp->a_lastcode)); in acts_timecode()
892 pp->lencode = strlen(pp->a_lastcode); in acts_timecode()
897 pp->lastref = pp->lastrec; in acts_timecode()