|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)hysq.c 4.1 (Berkeley) 1/22/85"; ! 3: #endif ! 4: ! 5: #include "../condevs.h" ! 6: ! 7: #ifdef HAYESQ ! 8: /* ! 9: * New dialout routine to work with Hayes' SMART MODEM ! 10: * 13-JUL-82, Mike Mitchell ! 11: * Modified 23-MAR-83 to work with Tom Truscott's (rti!trt) ! 12: * version of UUCP (ncsu!mcm) ! 13: * ! 14: * The modem should be set to NOT send any result codes to ! 15: * the system (switch 3 up, 4 down). This end will figure out ! 16: * what is wrong. ! 17: * ! 18: * I had lots of problems with the modem sending ! 19: * result codes since I am using the same modem for both incomming and ! 20: * outgoing calls. I'd occasionally miss the result code (getty would ! 21: * grab it), and the connect would fail. Worse yet, the getty would ! 22: * think the result code was a user name, and send garbage to it while ! 23: * it was in the command state. I turned off ALL result codes, and hope ! 24: * for the best. 99% of the time the modem is in the correct state. ! 25: * Occassionally it doesn't connect, or the phone was busy, etc., and ! 26: * uucico sits there trying to log in. It eventually times out, calling ! 27: * clsacu() in the process, so it resets itself for the next attempt. ! 28: */ ! 29: ! 30: /* ! 31: * NOTE: this version is not for the faint-hearted. ! 32: * Someday it would be nice to have a single version of hayes dialer ! 33: * with a way to specify the switch settings that are on the dialer ! 34: * as well as tone/pulse. ! 35: * In the meantime, using HAYES rather than HAYESQ is probably best. ! 36: */ ! 37: ! 38: hysqpopn(telno, flds, dev) ! 39: char *telno, *flds[]; ! 40: struct Devices *dev; ! 41: { ! 42: return hysqopn(telno, flds, dev, 0); ! 43: } ! 44: ! 45: hysqtopn(telno, flds, dev) ! 46: char *telno, *flds[]; ! 47: struct Devices *dev; ! 48: { ! 49: return hysqopn(telno, flds, dev, 1); ! 50: } ! 51: ! 52: hysqopn(telno, flds, dev, toneflag) ! 53: char *telno, *flds[]; ! 54: struct Devices *dev; ! 55: int toneflag; ! 56: { ! 57: char dcname[20], phone[MAXPH+10], c = 0; ! 58: #ifdef USG ! 59: struct termio ttbuf; ! 60: #endif USG ! 61: int status, dnf; ! 62: unsigned timelim; ! 63: ! 64: signal(SIGALRM, alarmtr); ! 65: sprintf(dcname, "/dev/%s", dev->D_line); ! 66: ! 67: getnextfd(); ! 68: if (setjmp(Sjbuf)) { ! 69: logent("DEVICE", "NO"); ! 70: DEBUG(4, "Open timed out %s", dcname); ! 71: return CF_NODEV; ! 72: } ! 73: alarm(10); ! 74: ! 75: if ((dnf = open(dcname, 2)) <= 0) { ! 76: logent("DEVICE", "NO"); ! 77: DEBUG(4, "Can't open %s", dcname); ! 78: return CF_NODEV; ! 79: } ! 80: ! 81: alarm(0); ! 82: next_fd = -1; ! 83: fixline(dnf, dev->D_speed); ! 84: DEBUG(4, "Hayes port - %s, ", dcname); ! 85: ! 86: if (toneflag) ! 87: sprintf(phone, "\rATDT%s\r", telno); ! 88: else ! 89: sprintf(phone, "\rATDP%s\r", telno); ! 90: ! 91: write(dnf, phone, strlen(phone)); ! 92: ! 93: /* calculate delay time for the other system to answer the phone. ! 94: * Default is 15 seconds, add 2 seconds for each comma in the phone ! 95: * number. ! 96: */ ! 97: timelim = 150; ! 98: while(*telno) { ! 99: c = *telno++; ! 100: if (c == ',') ! 101: timelim += 20; ! 102: else if (toneflag) ! 103: timelim += 2; /* .2 seconds per tone */ ! 104: else { ! 105: if (c == '0') timelim += 10; /* .1 sec per digit */ ! 106: else if (c > '0' && c <= '9') ! 107: timelim += (c - '0'); ! 108: } ! 109: } ! 110: alarm(timelim/10 + 1); ! 111: if (setjmp(Sjbuf) == 0) { ! 112: read(dnf, &c, 1); ! 113: alarm(0); ! 114: } ! 115: ! 116: return dnf; ! 117: } ! 118: ! 119: hysqcls(fd) ! 120: int fd; ! 121: { ! 122: char dcname[20]; ! 123: struct sgttyb hup, sav; ! 124: ! 125: if (fd > 0) { ! 126: sprintf(dcname, "/dev/%s", devSel); ! 127: DEBUG(4, "Hanging up fd = %d\n", fd); ! 128: /* ! 129: * code to drop DTR -- change to 0 baud then back to default. ! 130: */ ! 131: gtty(fd, &hup); ! 132: gtty(fd, &sav); ! 133: hup.sg_ispeed = B0; ! 134: hup.sg_ospeed = B0; ! 135: stty(fd, &hup); ! 136: sleep(2); ! 137: stty(fd, &sav); ! 138: /* ! 139: * now raise DTR -- close the device & open it again. ! 140: */ ! 141: sleep(2); ! 142: close(fd); ! 143: sleep(2); ! 144: fd = open(dcname, 2); ! 145: /* ! 146: * Since we have a getty sleeping on this line, when it wakes up it sends ! 147: * all kinds of garbage to the modem. Unfortunatly, the modem likes to ! 148: * execute the previous command when it sees the garbage. The previous ! 149: * command was to dial the phone, so let's make the last command reset ! 150: * the modem. ! 151: */ ! 152: sleep(2); ! 153: write(fd, "\rATZ\r", 5); ! 154: close(fd); ! 155: delock(devSel); ! 156: } ! 157: } ! 158: ! 159: #endif HAYESQ
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.