|
|
1.1 ! root 1: #ifndef lint ! 2: static char sccsid[] = "@(#)va811.c 4.2 (Berkeley) 2/24/88"; ! 3: #endif ! 4: ! 5: #include "../condevs.h" ! 6: ! 7: /* ! 8: * Racal-Vadic VA811 dialer with 831 adaptor. ! 9: * A typical 300 baud L-devices entry is ! 10: * ACU /dev/tty10 unused 300 va811s ! 11: * where tty10 is the communication line (D_Line), ! 12: * and 300 is the line speed. ! 13: * This is almost identical to RVMACS except that we don't need to ! 14: * send addresses and modem types, and don't need the fork. ! 15: * Joe Kelsey, fluke!joe, vax4.1526, Apr 11 1984. ! 16: */ ! 17: ! 18: #define STX 02 /* Access Adaptor */ ! 19: #define ETX 03 /* Transfer to Dialer */ ! 20: #define SI 017 /* Buffer Empty (end of phone number) */ ! 21: #define SOH 01 /* Abort */ ! 22: ! 23: va811opn(ph, flds, dev) ! 24: char *ph, *flds[]; ! 25: struct Devices *dev; ! 26: { ! 27: int va; ! 28: register int i, tries; ! 29: char c, dcname[20]; ! 30: char vabuf[35]; /* STX, 31 phone digits, SI, ETX, NUL */ ! 31: ! 32: va = 0; ! 33: sprintf(dcname, "/dev/%s", dev->D_line); ! 34: if (setjmp(Sjbuf)) { ! 35: DEBUG(1, "timeout va811 open\n", 0); ! 36: logent("va811opn", "TIMEOUT"); ! 37: if (va >= 0) ! 38: close(va); ! 39: delock(dev->D_line); ! 40: return CF_NODEV; ! 41: } ! 42: DEBUG(4, "va811: STARTING CALL\n", 0); ! 43: getnextfd(); ! 44: signal(SIGALRM, alarmtr); ! 45: alarm(10); ! 46: va = open(dcname, 2); ! 47: alarm(0); ! 48: ! 49: /* line is open */ ! 50: next_fd = -1; ! 51: if (va < 0) { ! 52: DEBUG(4, errno == 4 ? "%s: no carrier\n" : "%s: can't open\n", ! 53: dcname); ! 54: delock(dev->D_line); ! 55: logent(dcname, "CAN'T OPEN"); ! 56: return(errno == 4 ? CF_DIAL : CF_NODEV); ! 57: } ! 58: fixline(va, dev->D_speed); ! 59: ! 60: /* first, reset everything */ ! 61: sendthem("\\01\\c", va); ! 62: DEBUG(4, "wanted %c ", 'B'); ! 63: i = expect("B", va); ! 64: DEBUG(4, "got %s\n", i ? "?" : "that"); ! 65: if (i != 0) { ! 66: DEBUG(4, "va811: NO RESPONSE\n", 0); ! 67: logent("va811 reset", "TIMEOUT"); ! 68: close(va); ! 69: delock(dev->D_line); ! 70: return CF_DIAL; ! 71: } ! 72: ! 73: sprintf(vabuf, "%c%.31s%c%c\\c", STX, ph, SI, SOH); ! 74: sendthem(vabuf, va); ! 75: DEBUG(4, "wanted %c ", 'B'); ! 76: i = expect("B", va); ! 77: DEBUG(4, "got %s\n", i ? "?" : "that"); ! 78: ! 79: if (i != 0) { ! 80: DEBUG(4, "va811: STORE NUMBER\n", 0); ! 81: logent("va811 STORE", _FAILED); ! 82: close(va); ! 83: delock(dev->D_line); ! 84: return CF_DIAL; ! 85: } ! 86: ! 87: for (tries = 0; tries < TRYCALLS; tries++) { ! 88: sprintf(vabuf, "%c%c\\c", STX, ETX); ! 89: sendthem(vabuf, va); ! 90: DEBUG(4, "DIALING...", CNULL); ! 91: i = expect("A", va); ! 92: DEBUG(4, " %s\n", i ? _FAILED : "SUCCEEDED"); ! 93: if (i != 0) { ! 94: DEBUG(4, "va811: RESETTING\n", CNULL); ! 95: logent("va811 DIAL", _FAILED); ! 96: sendthem("\\01\\c", va); ! 97: expect("B", va); ! 98: } ! 99: else ! 100: break; ! 101: } ! 102: ! 103: if (tries >= TRYCALLS) { ! 104: close(va); ! 105: delock(dev->D_line); ! 106: return CF_DIAL; ! 107: } ! 108: ! 109: DEBUG(4, "va811 ok\n", CNULL); ! 110: return va; ! 111: } ! 112: ! 113: va811cls(fd) ! 114: register int fd; ! 115: { ! 116: DEBUG(2, "va811 close %d\n", fd); ! 117: p_chwrite(fd, SOH); ! 118: /* ioctl(fd, TIOCCDTR, NULL);*/ ! 119: close(fd); ! 120: delock(devSel); ! 121: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.