* Copyright (c) 1983 The Regents of the University of California.
* %sccs.include.redist.c%
static char sccsid
[] = "@(#)ventel.c 5.4 (Berkeley) %G%";
* Routines for calling up on a Ventel Modem
* The Ventel is expected to be strapped for local echo (just like uucp)
static jmp_buf timeoutbuf
;
* some sleep calls have been replaced by this macro
* because some ventel modems require two <cr>s in less than
* a second in order to 'wake up'... yes, it is dirty...
#define delay(num,denom) busyloop(CPUSPEED*num/denom)
#define CPUSPEED 1000000 /* VAX 780 is 1MIPS */
#define DELAY(n) { register long N = (n); while (--N > 0); }
busyloop(n
) { DELAY(n
); }
register int connected
= 0;
char *msg
, *index(), line
[80];
static int gobble(), vensync();
* Get in synch with a couple of carriage returns
printf("can't synchronize with ventel\n");
logent(value(HOST
), num
, "ventel", "can't synch up");
if (boolean(value(VERBOSE
)))
echo("#k$\r$\n$D$I$A$L$:$ ");
for (cp
= num
; *cp
; cp
++) {
connected
= gobble('!', line
);
sprintf(line
, "%d second dial timeout",
number(value(DIALTIMEOUT
)));
logent(value(HOST
), num
, "ventel", line
);
ven_disconnect(); /* insurance */
if (connected
|| timeout
|| !boolean(value(VERBOSE
)))
/* call failed, parse response for user */
for (cp
= line
; cp
= index(cp
, ' '); cp
++)
while (c
= *s
++) switch (c
) {
printf("\07timeout waiting for reply\n");
register char *cp
= response
;
f
= signal(SIGALRM
, sigALRM
);
if (setjmp(timeoutbuf
)) {
alarm(number(value(DIALTIMEOUT
)));
if (boolean(value(VERBOSE
)))
} while (c
!= '\n' && c
!= match
);
signal(SIGALRM
, SIG_DFL
);
#define min(a,b) ((a)>(b)?(b):(a))
* This convoluted piece of code attempts to get
* the ventel in sync. If you don't have FIONREAD
* there are gory ways to simulate this.
* Toggle DTR to force anyone off that might have left
* the modem connected, and insure a consistent state
* If you don't have the ioctl calls to diddle directly
* with DTR, you can always try setting the baud rate to 0.
while (already
< MAXRETRY
) {
* After reseting the modem, send it two \r's to
* autobaud on. Make sure to delay between them
* so the modem can frame the incoming characters.
if (ioctl(fd
, FIONREAD
, (caddr_t
)&nread
) < 0) {
read(fd
, buf
, min(nread
, 60));
if ((buf
[nread
- 1] & 0177) == '$')