* modules to be installed/loaded in the kernel. If specified, but not
* installed, the code runs as if unspecified.
*/
-#define LDISC_STD 0x0 /* standard */
-#define LDISC_CLK 0x1 /* tty_clk \n intercept */
-#define LDISC_CLKPPS 0x2 /* tty_clk \377 intercept */
-#define LDISC_ACTS 0x4 /* tty_clk #* intercept */
-#define LDISC_CHU 0x8 /* depredated */
+#define LDISC_STD 0x00 /* standard */
+#define LDISC_CLK 0x01 /* tty_clk \n intercept */
+#define LDISC_CLKPPS 0x02 /* tty_clk \377 intercept */
+#define LDISC_ACTS 0x04 /* tty_clk #* intercept */
+#define LDISC_CHU 0x08 /* depredated */
#define LDISC_PPS 0x10 /* ppsclock, ppsapi */
#define LDISC_RAW 0x20 /* raw binary */
#define LDISC_ECHO 0x40 /* enable echo */
+#define LDISC_REMOTE 0x80 /* remobe mode */
struct refclockproc {
struct refclockio io; /* I/O handler structure */
* Timeouts (all in seconds)
*/
#define SETUP 3 /* setup timeout */
+#define DTR 1 /* DTR timeout */
#define ANSWER 60 /* answer timeout */
#define CONNECT 20 /* first valid message timeout */
#define TIMECODE 30 /* all valid messages timeout */
* State machine codes
*/
#define S_IDLE 0 /* wait for poll */
-#define S_OK 1 /* wait for modem */
-#define S_CONNECT 2 /* wait for answer*/
-#define S_FIRST 3 /* wait for first valid message */
-#define S_MSG 4 /* wait for all messages */
-#define S_CLOSE 5 /* wait after sending disconnect */
+#define S_OK 1 /* wait for modem setup */
+#define S_DTR 2 /* wait for modem DTR */
+#define S_CONNECT 3 /* wait for answer*/
+#define S_FIRST 4 /* wait for first valid message */
+#define S_MSG 5 /* wait for all messages */
+#define S_CLOSE 6 /* wait after sending disconnect */
/*
* Unit control structure
return;
}
ioctl(pp->io.fd, TIOCMBIS, (char *)&dtr);
- sprintf(tbuf, "DIAL #%d %s", up->retry,
- sys_phone[up->retry]);
- record_clock_stats(&peer->srcadr, tbuf);
-#ifdef DEBUG
- if (debug)
- printf("%s\n", tbuf);
-#endif
- write(pp->io.fd, sys_phone[up->retry],
- strlen(sys_phone[up->retry]));
- write(pp->io.fd, "\r", 1);
- up->state = S_CONNECT;
- up->timer = ANSWER;
+ up->state = S_DTR;
+ up->timer = DTR;
return;
/*
int fd;
char device[20];
char lockfile[128], pidbuf[8];
+ char tbuf[BMAX];
/*
* The state machine is driven by messages from the modem, when
if (!pp->io.fd) {
sprintf(device, DEVICE, up->unit);
fd = refclock_open(device, SPEED232,
- LDISC_ACTS | LDISC_RAW);
+ LDISC_ACTS | LDISC_RAW | LDISC_REMOTE);
if (fd == 0) {
return;
}
msyslog(LOG_ERR, "acts: no modem");
break;
+ /*
+ * In DTR state we are waiting for the modem to settle down
+ * before hammering it with a dial command.
+ */
+ case S_DTR:
+ sprintf(tbuf, "DIAL #%d %s", up->retry,
+ sys_phone[up->retry]);
+ record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+ if (debug)
+ printf("%s\n", tbuf);
+#endif
+ write(pp->io.fd, sys_phone[up->retry],
+ strlen(sys_phone[up->retry]));
+ write(pp->io.fd, "\r", 1);
+ up->state = S_CONNECT;
+ up->timer = ANSWER;
+ return;
+
/*
* In CONNECT state the call did not complete.
*/
/*
* Open serial port
*/
- (void)sprintf(device, DEVICE, unit);
- if (!(fd = refclock_open(device, speed[peer->ttl & 0x3], 0)))
- return (0);
+ sprintf(device, DEVICE, unit);
+ if (!(fd = refclock_open(device, speed[peer->ttl & 0x3],
+ LDISC_REMOTE)))
+ return (0);
pp = peer->procptr;
pp->io.clock_recv = heath_receive;
pp->io.srcclock = (caddr_t)peer;