[net.bugs.uucp] condevs support for Vadic 212 and Vadic VA811S

joe@fluke.UUCP (Joe Kelsey) (04/12/84)

Here are the changes to condevs.c to support Vadic 212 dialers and
Vadic VA811S dialers.  The Vadic 212 is similar to the VA3451, but
better.  The basic dialing code is almost the same, some of the prompts
have changed.  The same goes for the VA811S - it is almost the same as
the VA811M, but with some operatonal differences.  Since there is no
MACS support, you don't need to worry about modem addresses and such.
Also, the modem and dialer share the same tty line, making it easier to
interface.  (By the way, if anyone is interested in converting a VA811M
to a VA811S, I'd be willing to document my personal horror stories...)

Anyway, here are our changes to condevs.c.  There are a couple of other
miscellaneous changes not related to the new dialer code.  There are a
couple of changes to the Micom support to match our Micom prompts and I
also modified the VADIC code to use the constant TRYCALLS instead of 5
in the for loop which redials the call.  Btw, why isn't there any
reference to TRYCALLS anywhere in the code?  Did you just give up on
using it or what?

/Joe Kelsey			John Fluke Mfg. Co., Inc.
(206)356-5933			uw-beaver!fluke!joe

joe@fluke.UUCP (Joe Kelsey) (04/12/84)

Oooops!  I fumbled and sent the message out without the code!  Well,
here is the code:  (the usual caveats apply - the line numbers are not
exact, etc.)

74a75,77
> #ifdef VA212
> int va212opn(), va212cls();
> #endif VA212
76a80,82
> #endif VA212
> #ifdef VA811S
> int va811opn(), va811cls();
113a120,122
> #ifdef VA212
> { "ACU", "va212", Acuopn, va212opn, va212cls },
> #endif VA212
116a126,128
> #ifdef VA811S
> { "ACU", "va811s", Acuopn, va811opn, va811cls },
> #endif VA811S
422a435
> #ifndef FLUKE
424a438,441
> #else
> 	DEBUG(4, "wanted %s ", "#");
> 	ok = expect("#", dh);
> #endif FLUKE
429a447
> #ifndef FLUKE
431a450,453
> #else
> 		DEBUG(4, "wanted %s ", "CONNECTING");
> 		ok = expect("CONNECTING", dh);
> #endif FLUKE
1265a1288,1289
> 		DEBUG (4, errno == 4 ? "%s: no carrier\n" : "%s: can't open\n",
> 			dcname);
1267c1291
< 		return(CF_NODEV);
---
> 		return(errno == 4 ? CF_DIAL : CF_NODEV);
1285c1309
< 	for(i = 0; i < 5; ++i) {	/* make 5 tries */
---
> 	for(i = 0; i < TRYCALLS; ++i) {	/* make TRYCALLS tries */
1347a1372,1500
> #ifdef VA212
> 
> /*
>  *	va212opn: establish dial-out connection through a Racal-Vadic 212.
>  *	Returns descriptor open to tty for reading and writing.
>  *	Negative values (-1...-7) denote errors in connmsg.
>  *	Be sure to disconnect tty when done, via HUPCL or stty 0.
>  */
> 
> va212opn(telno, flds, dev)
> char *telno;
> char *flds[];
> struct Devices *dev;
> {
> 	int	dh = -1;
> 	int	i, ok, er = 0, delay;
> 	extern errno;
> 	char dcname[20];
> 
> 	sprintf(dcname, "/dev/%s", dev->D_line);
> 	if (setjmp(Sjbuf)) {
> 		DEBUG(1, "timeout va212 open\n", "");
> 		logent("va212 open", "TIMEOUT");
> 		if (dh >= 0)
> 			close(dh);
> 		delock(dev->D_line);
> 		return(CF_NODEV);
> 	}
> 	signal(SIGALRM, alarmtr);
> 	getnextfd();
> 	alarm(10);
> 	dh = open(dcname, 2);
> 	alarm(0);
> 
> 	/* modem is open */
> 	next_fd = -1;
> 	if (dh < 0) {
> 		DEBUG (4, errno == 4 ? "%s: no carrier\n" : "%s: can't open\n",
> 			dcname);
> 		delock(dev->D_line);
> 		return(errno == 4 ? CF_DIAL : CF_NODEV);
> 		}
> 	fixline(dh, dev->D_speed);
> 
> /* translate - to K for Vadic */
> 	DEBUG(4, "calling %s -> ", telno);
> 	delay = 0;
> 	for (i = 0; i < strlen(telno); ++i) {
> 		switch(telno[i]) {
> 		case '=':	/* await dial tone */
> 		case '-':	/* delay */
> 		case '<':
> 			telno[i] = 'K';
> 			delay += 5;
> 			break;
> 		}
> 	}
> 	DEBUG(4, "%s\n", telno);
> 	for(i = 0; i < TRYCALLS; ++i) {	/* make TRYCALLS tries */
> 		/* wake up Vadic */
> 		sendthem("\005\\d", dh);
> 		DEBUG(4, "wanted %s ", "*");
> 		ok = expect("*", dh);
> 		DEBUG(4, "got %s\n", ok ? "?" : "that");
> 		if (ok != 0)
> 			continue;
> 
> 		sendthem("D\\d", dh);	/* "D" (enter number) command */
> 		DEBUG(4, "wanted %s ", "NUMBER?");
> 		ok = expect("NUMBER?", dh);
> 		if (ok == 0)
> 			ok = expect("\n", dh);
> 		DEBUG(4, "got %s\n", ok ? "?" : "that");
> 		if (ok != 0)
> 			continue;
> 
> 	/* send telno, send \r */
> 		sendthem(telno, dh);
> 		ok = expect(telno, dh);
> 		if (ok == 0)
> 			ok = expect("\n", dh);
> 		DEBUG(4, "got %s\n", ok ? "?" : "that");
> 		if (ok != 0)
> 			continue;
> 
> 		sendthem("", dh); /* confirm number */
> 		DEBUG(4, "wanted %s ", "DIALING...");
> 		ok = expect("DIALING...", dh);
> 		if (ok == 0) {
> 		    ok = expect("\n", dh);
> 		    DEBUG(4, "wanted %s ", "ANSWER TONE");
> 		    ok = expect("ANSWER TONE", dh);
> 		    if (ok == 0)
> 		        ok = expect("\n", dh);
> 		}
> 		DEBUG(4, "got %s\n", ok ? "?" : "that");
> 		if (ok == 0)
> 			break;
> 	}
> 
> 	if (ok == 0) {
> 		DEBUG(4, "wanted ON LINE \\r\\n ", 0);
> 		ok = expect("ON LINE \r\n", dh);
> 		DEBUG(4, "got %s\n", ok ? "?" : "that");
> 	}
> 
> 	if (ok != 0) {
> 		sendthem("I\\d", dh);	/* back to idle */
> 		if (dh > 2)
> 			close(dh);
> 		DEBUG(4, "vadDial failed\n", "");
> 		delock(dev->D_line);
> 		return(CF_DIAL);
> 	}
> 	DEBUG(4, "va212 ok\n", "");
> 	return(dh);
> }
> 
> va212cls(fd) {
> 
> 	if (fd > 0) {
> 		close(fd);
> 		sleep(5);
> 		delock(devSel);
> 		}
> 	}
> 
> #endif VA212
> 
1482c1635,1751
< #endif
---
> #endif RVMACS
> 
> #ifdef	VA811S
> /*
>  * Racal-Vadic VA811 dialer with 831 adaptor.
>  * A typical 300 baud L-devices entry is
>  *	ACU /dev/tty10 unused 300 va811s
>  * where tty10 is the communication line (D_Line),
>  * and 300 is the line speed.
>  * This is almost identical to RVMACS except that we don't need to
>  * send addresses and modem types, and don't need the fork.
>  */
> 
> #define	STX	02	/* Access Adaptor */
> #define	ETX	03	/* Transfer to Dialer */
> #define	SI	017	/* Buffer Empty (end of phone number) */
> #define	SOH	01	/* Abort */
> 
> va811opn(ph, flds, dev)
> char *ph, *flds[];
> struct Devices *dev;
> {
> 	int va;
> 	register int i, tries;
> 	char c, dcname[20];
> 	char vabuf[35];		/* STX, 31 phone digits, SI, ETX, NUL */
> 
> 	va = 0;
> 	sprintf(dcname, "/dev/%s", dev->D_line);
> 	if (setjmp(Sjbuf)) {
> 		DEBUG(1, "timeout va811 open\n", "");
> 		logent("va811opn", "TIMEOUT");
> 		if (va >= 0)
> 			close(va);
> 		delock(dev->D_line);
> 		return CF_NODEV;
> 	}
> 	DEBUG(4, "va811: STARTING CALL\n", 0);
> 	getnextfd();
> 	signal(SIGALRM, alarmtr);
> 	alarm(10);
> 	va = open(dcname, 2);
> 	alarm(0);
> 
> 	/* line is open */
> 	next_fd = -1;
> 	if (va < 0) {
> 		DEBUG(4, errno == 4 ? "%s: no carrier\n" : "%s: can't open\n",
> 			dcname);
> 		delock(dev->D_line);
> 		logent(dcname, "CAN'T OPEN");
> 		return(errno == 4 ? CF_DIAL : CF_NODEV);
> 	}
> 	fixline(va, dev->D_speed);
> 
> 	/* first, reset everything */
> 	sendthem("\\01\\c", va);
> 	DEBUG(4, "wanted %c ", 'B');
> 	i = expect("B", va);
> 	DEBUG(4, "got %s\n", i ? "?" : "that");
> 	if (i != 0) {
> 	    DEBUG(4, "va811: NO RESPONSE\n", "");
> 	    logent("va811 reset", "TIMEOUT");
> 	    close(va);
> 	    delock(dev->D_line);
> 	    return(CF_DIAL);
> 	}
> 
> 	sprintf(vabuf, "%c%.31s%c%c\\c", STX, ph, SI, SOH);
> 	sendthem(vabuf, va);
> 	DEBUG(4, "wanted %c ", 'B');
> 	i = expect("B", va);
> 	DEBUG(4, "got %s\n", i ? "?" : "that");
> 
> 	if (i != 0) {
> 	    DEBUG(4, "va811: STORE NUMBER\n", "");
> 	    logent("va811 STORE", "FAILED");
> 	    close(va);
> 	    delock(dev->D_line);
> 	    return(CF_DIAL);
> 	}
> 
> 	for (tries = 0; tries < TRYCALLS; tries++) {
> 	    sprintf(vabuf, "%c%c\\c", STX, ETX);
> 	    sendthem(vabuf, va);
> 	    DEBUG(4, "DIALING...", "");
> 	    i = expect("A", va);
> 	    DEBUG(4, " %s\n", i ? "FAILED" : "SUCCEEDED");
> 	    if (i != 0) {
> 		DEBUG(4, "va811: RESETTING\n", "");
> 		logent("va811 DIAL", "FAILED");
> 	        sendthem("\\01\\c", va);
> 	        expect("B", va);
> 	    }
> 	    else
> 	        break;
> 	}
> 
> 	if (tries >= TRYCALLS) {
> 	    close(va);
> 	    delock(dev->D_line);
> 	    return(CF_DIAL);
> 	}
> 
> 	DEBUG(4, "va811 ok\n", "");
> 	return(va);
> }
> 
> va811cls(fd)
> register int fd;
> {
> 	DEBUG(2, "va811 close %d\n", fd);
> 	p_chwrite(fd, SOH);
> /*	ioctl(fd, TIOCCDTR, NULL);*/
> 	close(fd);
> }
> #endif VA811S