1: #ifndef lint
   2: static char sccsid[] = "@(#)att2224.c	1.1 (Berkeley) 2/12/86";
   3: #endif
   4: 
   5: #include "../condevs.h"
   6: 
   7: #ifdef ATT2224
   8: attopn(telno, flds, dev)
   9: char *telno, *flds[];
  10: struct Devices *dev;
  11: {
  12:     char dcname[20], phone[MAXPH+10], c = 0;
  13:     int dnf, failret = 0, timelim;
  14: 
  15:     sprintf(dcname, "/dev/%s", dev->D_line);
  16: 
  17:     if (setjmp(Sjbuf)) {
  18:         delock(dev->D_line);
  19:         logent("DEVICE", "NO");
  20:         DEBUG(4, "Open timed out %s", dcname);
  21:         alarm (0);
  22:         return CF_NODEV;
  23:     }
  24: 
  25:     signal(SIGALRM, alarmtr);
  26:     getnextfd();
  27:     alarm(10);
  28: 
  29:     if ((dnf = open(dcname, 2)) <= 0) {
  30:         delock(dev->D_line);
  31:         logent("DEVICE", "NO");
  32:         DEBUG(4, "Can't open %s", dcname);
  33:         alarm (0);
  34:         return CF_NODEV;
  35:     }
  36: 
  37:     alarm(0);
  38:     next_fd = -1;
  39:     fixline(dnf, dev->D_speed);
  40:     DEBUG(4, "modem port - %s\n", dcname);
  41: 
  42:     if (setjmp(Sjbuf)) {
  43:         delock(dev->D_line);
  44:         logent("ACU WRITE", "FAILED");
  45:         return CF_DIAL;
  46:     }
  47:     signal(SIGALRM, alarmtr);
  48:     alarm(10);
  49:     do {
  50:         slowrite(dnf, "\r");        /* wake up modem */
  51:     } while (expect(":~3", dnf));
  52:     alarm(0);
  53: 
  54:     sprintf (phone, "atzt%s\r", telno);
  55:     slowrite (dnf, phone);      /* type telno string to modem */
  56: 
  57:     if ((expect(phone, dnf)) != SUCCESS) {
  58:         delock(dev->D_line);
  59:         logent("ACU READ", "FAILED");
  60:         return CF_DIAL;
  61:     }
  62: 
  63:     if (setjmp(Sjbuf)) {
  64:         delock(dev->D_line);
  65:         logent("NO ANSWER", "FAILED");
  66:         alarm (0);
  67:         return CF_DIAL;
  68:     }
  69:     timelim = strlen(telno) * 4;
  70:     signal(SIGALRM, alarmtr);
  71:     alarm(timelim > 30 ? timelim : 30);
  72: 
  73: readchar:
  74:     if ((read(dnf, &c, 1)) != 1) {
  75:         delock(dev->D_line);
  76:         logent("ACU READ", "FAILED");
  77:         return CF_DIAL;
  78:     }
  79: 
  80:     switch (c) {
  81:         case 'D':   /* no dial tone */
  82:             logent("NO DIAL TONE", "FAILED");
  83:             failret++;
  84:             break;
  85:         case 'B':   /* line busy */
  86:             logent("LINE BUSY", "FAILED");
  87:             failret++;
  88:             break;
  89:         case 'N':   /* no answer */
  90:             logent("NO ANSWER", "FAILED");
  91:             failret++;
  92:             break;
  93:         case 'H':   /* handshake failed */
  94:             logent("MODEM HANDSHAKE", "FAILED");
  95:             failret++;
  96:             break;
  97:         case '3':   /* 2400 baud */
  98:             DEBUG(4, "Baudrate set to 2400 baud", CNULL);
  99:             fixline(dnf, 2400);
 100:             break;
 101:         case '2':   /* 1200 baud */
 102:             DEBUG(4, "Baudrate set to 1200 baud", CNULL);
 103:             fixline(dnf, 1200);
 104:             break;
 105:         case '1':   /* 300 baud */
 106:             DEBUG(4, "Baudrate set to 300 baud", CNULL);
 107:             fixline(dnf, 300);
 108:             break;
 109:         default:    /* Not one of the above, so must be garbage */
 110:             goto readchar;
 111:         }
 112:     if (failret) {
 113:         alarm (0);
 114:         delock(dev->D_line);
 115:         return CF_DIAL;
 116:     }
 117:     alarm (0);
 118:     return dnf;
 119: }
 120: 
 121: attcls(fd)
 122: int fd;
 123: {
 124:     char dcname[20];
 125: #ifdef USG
 126:     struct termio hup, sav;
 127: #else  !USG
 128:     struct sgttyb hup, sav;
 129: #endif !USG
 130: 
 131:     if (fd > 0) {
 132:         sprintf(dcname, "/dev/%s", devSel);
 133:         DEBUG(4, "Hanging up fd = %d\n", fd);
 134:         /*
 135: 		 * code to drop DTR -- change to 0 baud then back to default.
 136: 		 */
 137:         gtty(fd, &hup);
 138:         gtty(fd, &sav);
 139: #ifdef USG
 140:         hup.c_cflag = B0;
 141: #else  !USG
 142:         hup.sg_ispeed = B0;
 143:         hup.sg_ospeed = B0;
 144: #endif !USG
 145:         stty(fd, &hup);
 146:         sleep(2);
 147:         stty(fd, &sav);
 148:         /*
 149: 		 * now raise DTR -- close the device
 150: 		 */
 151:         sleep(2);
 152:         close(fd);
 153:         delock(devSel);
 154:     }
 155: }
 156: #endif ATT2224

Defined functions

attcls defined in line 121; never used
attopn defined in line 8; never used

Defined variables

sccsid defined in line 2; never used
Last modified: 1986-02-13
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 1157
Valid CSS Valid XHTML 1.0 Strict