static char sccsid
[] = "@(#)ventel.c 1.5 (Berkeley) 6/25/83";
* Routines for calling up on a Ventel Modem
* The Ventel is expected to be strapped for "no echo".
static jmp_buf timeoutbuf
;
register int connected
= 0;
* 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
++) {
sprintf(line
, "%d second dial timeout",
number(value(DIALTIMEOUT
)));
logent(value(HOST
), num
, "ventel", line
);
ven_disconnect(); /* insurance */
while (c
= *s
++) switch (c
) {
printf("\07timeout waiting for reply\n");
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) == '$')