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

Defined functions

va811cls defined in line 114; never used
va811opn defined in line 24; never used

Defined variables

sccsid defined in line 2; never used

Defined macros

ETX defined in line 20; used 1 times
  • in line 89
SI defined in line 21; used 1 times
  • in line 74
SOH defined in line 22; used 2 times
STX defined in line 19; used 2 times
Last modified: 1987-02-17
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 3513
Valid CSS Valid XHTML 1.0 Strict