/* ventel.c 1.2 82/07/29 */
* Routines for calling up on a Ventel Modem
#define DISCONNECT "\03" /* ^C */
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
) {
signal(SIGALRM
, SIG_IGN
);
printf("\07timeout waiting for reply\n");
signal(SIGALRM
, sigALRM
);
alarm(number(value(DIALTIMEOUT
)));
if (boolean(value(VERBOSE
)))
} while (c
!= '\n' && c
!= s
);
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 the capacity or nread
* call there are gory ways to simulate this.
register int already
= 0, nbytes
;
* 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(nbytes
, 60));
if ((buf
[nbytes
-1]&0177) == '$')
nbytes
-= min(nbytes
, 60);