1*48651Sbostic /*- 2*48651Sbostic * Copyright (c) 1985 The Regents of the University of California. 3*48651Sbostic * All rights reserved. 4*48651Sbostic * 5*48651Sbostic * %sccs.include.proprietary.c% 6*48651Sbostic */ 7*48651Sbostic 817783Sralph #ifndef lint 9*48651Sbostic static char sccsid[] = "@(#)va811.c 4.4 (Berkeley) 04/24/91"; 10*48651Sbostic #endif /* not lint */ 1117783Sralph 1246875Sbostic #include "condevs.h" 1317783Sralph 1417783Sralph /* 1517783Sralph * Racal-Vadic VA811 dialer with 831 adaptor. 1617783Sralph * A typical 300 baud L-devices entry is 1717783Sralph * ACU /dev/tty10 unused 300 va811s 1817783Sralph * where tty10 is the communication line (D_Line), 1917783Sralph * and 300 is the line speed. 2017783Sralph * This is almost identical to RVMACS except that we don't need to 2117783Sralph * send addresses and modem types, and don't need the fork. 2217783Sralph * Joe Kelsey, fluke!joe, vax4.1526, Apr 11 1984. 2317783Sralph */ 2417783Sralph 2517783Sralph #define STX 02 /* Access Adaptor */ 2617783Sralph #define ETX 03 /* Transfer to Dialer */ 2717783Sralph #define SI 017 /* Buffer Empty (end of phone number) */ 2817783Sralph #define SOH 01 /* Abort */ 2917783Sralph 3017783Sralph va811opn(ph, flds, dev) 3117783Sralph char *ph, *flds[]; 3217783Sralph struct Devices *dev; 3317783Sralph { 3417783Sralph int va; 3517783Sralph register int i, tries; 3617783Sralph char c, dcname[20]; 3717783Sralph char vabuf[35]; /* STX, 31 phone digits, SI, ETX, NUL */ 3817783Sralph 3917783Sralph va = 0; 4017783Sralph sprintf(dcname, "/dev/%s", dev->D_line); 4117783Sralph if (setjmp(Sjbuf)) { 4217783Sralph DEBUG(1, "timeout va811 open\n", 0); 4317783Sralph logent("va811opn", "TIMEOUT"); 4417783Sralph if (va >= 0) 4517783Sralph close(va); 4617783Sralph delock(dev->D_line); 4717783Sralph return CF_NODEV; 4817783Sralph } 4917783Sralph DEBUG(4, "va811: STARTING CALL\n", 0); 5017783Sralph getnextfd(); 5117783Sralph signal(SIGALRM, alarmtr); 5217783Sralph alarm(10); 5317783Sralph va = open(dcname, 2); 5417783Sralph alarm(0); 5517783Sralph 5617783Sralph /* line is open */ 5717783Sralph next_fd = -1; 5817783Sralph if (va < 0) { 5917783Sralph DEBUG(4, errno == 4 ? "%s: no carrier\n" : "%s: can't open\n", 6017783Sralph dcname); 6117783Sralph delock(dev->D_line); 6217783Sralph logent(dcname, "CAN'T OPEN"); 6317783Sralph return(errno == 4 ? CF_DIAL : CF_NODEV); 6417783Sralph } 6517783Sralph fixline(va, dev->D_speed); 6617783Sralph 6717783Sralph /* first, reset everything */ 6817783Sralph sendthem("\\01\\c", va); 6917783Sralph DEBUG(4, "wanted %c ", 'B'); 7017783Sralph i = expect("B", va); 7117783Sralph DEBUG(4, "got %s\n", i ? "?" : "that"); 7217783Sralph if (i != 0) { 7317783Sralph DEBUG(4, "va811: NO RESPONSE\n", 0); 7417783Sralph logent("va811 reset", "TIMEOUT"); 7517783Sralph close(va); 7617783Sralph delock(dev->D_line); 7717783Sralph return CF_DIAL; 7817783Sralph } 7917783Sralph 8017783Sralph sprintf(vabuf, "%c%.31s%c%c\\c", STX, ph, SI, SOH); 8117783Sralph sendthem(vabuf, va); 8217783Sralph DEBUG(4, "wanted %c ", 'B'); 8317783Sralph i = expect("B", va); 8417783Sralph DEBUG(4, "got %s\n", i ? "?" : "that"); 8517783Sralph 8617783Sralph if (i != 0) { 8717783Sralph DEBUG(4, "va811: STORE NUMBER\n", 0); 8817783Sralph logent("va811 STORE", _FAILED); 8917783Sralph close(va); 9017783Sralph delock(dev->D_line); 9117783Sralph return CF_DIAL; 9217783Sralph } 9317783Sralph 9417783Sralph for (tries = 0; tries < TRYCALLS; tries++) { 9517783Sralph sprintf(vabuf, "%c%c\\c", STX, ETX); 9617783Sralph sendthem(vabuf, va); 9717783Sralph DEBUG(4, "DIALING...", CNULL); 9817783Sralph i = expect("A", va); 9917783Sralph DEBUG(4, " %s\n", i ? _FAILED : "SUCCEEDED"); 10017783Sralph if (i != 0) { 10117783Sralph DEBUG(4, "va811: RESETTING\n", CNULL); 10217783Sralph logent("va811 DIAL", _FAILED); 10317783Sralph sendthem("\\01\\c", va); 10417783Sralph expect("B", va); 10517783Sralph } 10617783Sralph else 10717783Sralph break; 10817783Sralph } 10917783Sralph 11017783Sralph if (tries >= TRYCALLS) { 11117783Sralph close(va); 11217783Sralph delock(dev->D_line); 11317783Sralph return CF_DIAL; 11417783Sralph } 11517783Sralph 11617783Sralph DEBUG(4, "va811 ok\n", CNULL); 11717783Sralph return va; 11817783Sralph } 11917783Sralph 12017783Sralph va811cls(fd) 12117783Sralph register int fd; 12217783Sralph { 12317783Sralph DEBUG(2, "va811 close %d\n", fd); 12417783Sralph p_chwrite(fd, SOH); 12517783Sralph /* ioctl(fd, TIOCCDTR, NULL);*/ 12617783Sralph close(fd); 12717783Sralph delock(devSel); 12817783Sralph } 129