typo
[unix-history] / usr / src / usr.bin / uucp / libacu / hys.c
index ef8edee..06042da 100644 (file)
@@ -1,13 +1,17 @@
 #ifndef lint
 #ifndef lint
-static char sccsid[] = "@(#)hys.c      4.4 (Berkeley) %G%";
+static char sccsid[] = "@(#)hys.c      4.7 (Berkeley) %G%";
 #endif
 
 #include "../condevs.h"
 
 #endif
 
 #include "../condevs.h"
 
-#ifdef HAYES
-#define USR2400        /* U.S. Robotics Courier 2400 */
 #ifdef USR2400
 #define DROPDTR
 #ifdef USR2400
 #define DROPDTR
+/*
+ * The "correct" switch settings for a USR Courier 2400 are
+ *     Dialin/out:     0 0 1 1 0 0 0 1 0 0
+ *     Dialout only:   0 0 1 1 1 1 0 1 0 0
+ * where 0 = off and 1 = on
+ */
 #endif USR2400
 
 /*
 #endif USR2400
 
 /*
@@ -41,19 +45,19 @@ char *flds[];
 struct Devices *dev;
 int toneflag;
 {
 struct Devices *dev;
 int toneflag;
 {
-       int     dh = -1;
        extern errno;
        char dcname[20];
        char cbuf[MAXPH];
        register char *cp;
        register int i;
        extern errno;
        char dcname[20];
        char cbuf[MAXPH];
        register char *cp;
        register int i;
+       int dh = -1, nrings = 0;
 
        sprintf(dcname, "/dev/%s", dev->D_line);
        DEBUG(4, "dc - %s\n", dcname);
        if (setjmp(Sjbuf)) {
                logent(dcname, "TIMEOUT");
                if (dh >= 0)
 
        sprintf(dcname, "/dev/%s", dev->D_line);
        DEBUG(4, "dc - %s\n", dcname);
        if (setjmp(Sjbuf)) {
                logent(dcname, "TIMEOUT");
                if (dh >= 0)
-                       close(dh);
+                       hyscls(dh);
                return CF_DIAL;
        }
        signal(SIGALRM, alarmtr);
                return CF_DIAL;
        }
        signal(SIGALRM, alarmtr);
@@ -68,7 +72,7 @@ int toneflag;
                fixline(dh, dev->D_speed);
                if (dochat(dev, flds, dh)) {
                        logent(dcname, "CHAT FAILED");
                fixline(dh, dev->D_speed);
                if (dochat(dev, flds, dh)) {
                        logent(dcname, "CHAT FAILED");
-                       close(dh);
+                       hyscls(dh);
                        return CF_DIAL;
                }
                write(dh, "ATV1E0H\r", 8);
                        return CF_DIAL;
                }
                write(dh, "ATV1E0H\r", 8);
@@ -78,7 +82,7 @@ int toneflag;
                        return CF_DIAL;
                }
 #ifdef USR2400
                        return CF_DIAL;
                }
 #ifdef USR2400
-               write(dh, "ATX6\r", 5);
+               write(dh, "ATX6S7=44\r", 10);
                if (expect("OK\r\n", dh) != 0) {
                        logent(dcname, "HSM seems dead");
                        hyscls(dh);
                if (expect("OK\r\n", dh) != 0) {
                        logent(dcname, "HSM seems dead");
                        hyscls(dh);
@@ -88,7 +92,11 @@ int toneflag;
                if (toneflag)
                        write(dh, "\rATDT", 5);
                else
                if (toneflag)
                        write(dh, "\rATDT", 5);
                else
+#ifdef USR2400
+                       write(dh, "\rATD", 4);
+#else HAYES
                        write(dh, "\rATDP", 5);
                        write(dh, "\rATDP", 5);
+#endif HAYES
                write(dh, telno, strlen(telno));
                write(dh, "\r", 1);
 
                write(dh, telno, strlen(telno));
                write(dh, "\r", 1);
 
@@ -99,8 +107,8 @@ int toneflag;
                        return CF_DIAL;
                }
                signal(SIGALRM, alarmtr);
                        return CF_DIAL;
                }
                signal(SIGALRM, alarmtr);
+               alarm(2*MAXMSGTIME);
                do {
                do {
-                       alarm(MAXMSGTIME);
                        cp = cbuf;
                        while (read(dh, cp ,1) == 1)
                                if (*cp >= ' ')
                        cp = cbuf;
                        while (read(dh, cp ,1) == 1)
                                if (*cp >= ' ')
@@ -112,18 +120,23 @@ int toneflag;
                        if (*cp == '\r')
                                *cp = '\0';
                        DEBUG(4,"\nGOT: %s", cbuf);
                        if (*cp == '\r')
                                *cp = '\0';
                        DEBUG(4,"\nGOT: %s", cbuf);
-               } while (strncmp(cbuf, "RING", 4) == 0);
+                       alarm(MAXMSGTIME);
+               } while ((strncmp(cbuf, "RING", 4) == 0 ||
+                        strncmp(cbuf, "RRING", 5) == 0) && nrings++ < 5);
                if (strncmp(cbuf, "CONNECT", 7) != 0) {
                        logent(cbuf, _FAILED);
                        strcpy(devSel, dev->D_line);
                        hyscls(dh);
                        return CF_DIAL;
                }
                if (strncmp(cbuf, "CONNECT", 7) != 0) {
                        logent(cbuf, _FAILED);
                        strcpy(devSel, dev->D_line);
                        hyscls(dh);
                        return CF_DIAL;
                }
+#undef DONTRESETBAUDRATE
+#ifndef DONTRESETBAUDRATE
                i = atoi(&cbuf[8]);
                if (i > 0 && i != dev->D_speed) {       
                        DEBUG(4,"Baudrate reset to %d\n", i);
                        fixline(dh, i);
                }
                i = atoi(&cbuf[8]);
                if (i > 0 && i != dev->D_speed) {       
                        DEBUG(4,"Baudrate reset to %d\n", i);
                        fixline(dh, i);
                }
+#endif /* DONTRESETBAUDRATE */
 
        }
        if (dh < 0) {
 
        }
        if (dh < 0) {
@@ -169,14 +182,15 @@ int fd;
                write(fd, "+++", 3);
 #endif
                sleep(3);
                write(fd, "+++", 3);
 #endif
                sleep(3);
-               write(fd, "ATZ\r", 4);
+               write(fd, "ATH\r", 4);
+/*
                if (expect("OK",fd) != 0)
                        logent(devSel, "HSM did not respond to ATZ");
                if (expect("OK",fd) != 0)
                        logent(devSel, "HSM did not respond to ATZ");
+*/
+               sleep(1);
+               write(fd, "ATZ\r", 4);
                sleep(1);
                close(fd);
                delock(devSel);
        }
 }
                sleep(1);
                close(fd);
                delock(devSel);
        }
 }
-
-#endif HAYES
-