ventel.c revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
* Copyright (c) 1983 Regents of the University of California.
* All rights reserved. The Berkeley software License Agreement
* specifies the terms and conditions for redistribution.
*/
#ident "%Z%%M% %I% %E% SMI" /* from UCB 1.5 6/25/83 */
/*
* Routines for calling up on a Ventel Modem
* Define VENNOECHO if the Ventel is strapped for "no echo".
*/
#include "tip.h"
#define MAXRETRY 5
static void sigALRM();
static int timeout = 0;
static sigjmp_buf timeoutbuf;
register char *num;
char *acu;
{
register char *cp;
register int connected = 0;
#ifdef ACULOG
char line[80];
#endif
/*
* Get in synch with a couple of carriage returns
*/
printf("can't synchronize with ventel\n");
#ifdef ACULOG
#endif
return (0);
}
printf("\ndialing...");
#ifdef VENNOECHO
echo("#k$\r$\n$D$I$A$L$:$ ");
sleep(1);
}
echo("\r$\n");
#else
echo("k$\r$\n$D$I$A$L$:$ <");
char c;
sleep(1);
}
echo(">\r$\n");
#endif
if (gobble('\n'))
#ifdef ACULOG
if (timeout) {
}
#endif
if (timeout)
ven_disconnect(); /* insurance */
return (connected);
}
{
}
{
}
static int
echo(s)
register char *s;
{
char c;
while (c = *s++) {
switch (c) {
case '$':
s++;
break;
case '#':
c = *s++;
break;
default:
}
}
}
static void
sigALRM()
{
printf("\07timeout waiting for reply\n");
timeout = 1;
}
static int
register char match;
{
char c;
timeout = 0;
do {
return (0);
}
alarm(0);
c &= 0177;
#ifdef notdef
putchar(c);
#endif
} while (c != '\n' && c != match);
return (c == match);
}
#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.
*/
static int
{
char buf[60];
/*
* Toggle DTR to force anyone off that might have left
* the modem connected, and insure a consistent state
* to start from.
*
* If you don't have the ioctl calls to diddle directly
* with DTR, you can always try setting the baud rate to 0.
*/
sleep(2);
/*
* 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.
*/
#ifdef VMUNIX
{
}
#else
sleep(1);
#endif
sleep(3);
perror("tip: ioctl");
continue;
}
while (nread > 0) {
return (1);
}
sleep(1);
already++;
}
return (0);
}