Пример #1
0
void multitech_disconnect ()
{
	int okay, retries;
	for (retries = okay = 0; retries < 3 && !okay; retries++)
	{
		 /* first hang up the modem*/
		ioctl (FD, TIOCCDTR, 0);
		acu_nap (escape_guard_time);
		ioctl (FD, TIOCSDTR, 0);
		acu_nap (escape_guard_time);
		/*
		 * If not strapped for DTR control, try to get command mode.
		 */
		acu_nap (escape_guard_time);
		multitech_write_str (FD, escape_sequence);
		acu_nap (escape_guard_time);
		multitech_write_str (FD, hangup_command);
		okay = multitech_swallow ("\r\nOK\r\n");
	}
	if (!okay)
	{
		#if ACULOG
		logent(value(HOST), "", "multitech", "can't hang up modem");
		#endif
		if (boolean(value(VERBOSE)))
			printf("hang up failed\n");
	}
	close (FD);
}
Пример #2
0
/*
 * This convoluted piece of code attempts to get
 * the multitech in sync.
 */
static int
multitechsync(void)
{
	int already = 0;
	int len;
	char buf[40];

	while (already++ < MAXRETRY) {
		acu_nap (intercommand_delay);
		ioctl (FD, TIOCFLUSH, 0);	/* flush any clutter */
		multitech_write_str (FD, reset_command); /* reset modem */
		bzero(buf, sizeof(buf));
		acu_nap (reset_delay);
		ioctl (FD, FIONREAD, &len);
		if (len) {
			len = read(FD, buf, sizeof(buf));
#ifdef DEBUG
			buf [len] = '\0';
			printf("multitechsync: (\"%s\")\n\r", buf);
#endif
			if (index(buf, '0') ||
		   	   (index(buf, 'O') && index(buf, 'K')))
				return(1);
		}
		/*
		 * If not strapped for DTR control,
		 * try to get command mode.
		 */
		acu_nap (escape_guard_time);
		multitech_write_str (FD, escape_sequence);
		acu_nap (escape_guard_time);
		multitech_write_str (FD, hangup_command);
		/*
		 * Toggle DTR to force anyone off that might have left
		 * the modem connected.
		 */
		acu_nap (escape_guard_time);
		ioctl (FD, TIOCCDTR, 0);
		acu_nap (escape_guard_time);
		ioctl (FD, TIOCSDTR, 0);
	}
	acu_nap (intercommand_delay);
	multitech_write_str (FD, reset_command);
	return (0);
}
Пример #3
0
int multitech_dialer (char *num, char *acu)
{
	char *cp;
#if ACULOG
	char line [80];
#endif

	if (lock_baud)
	{
		int i;
		if ((i = speed(number(value(BAUDRATE)))) == 0)
			return 0;
		ttysetup (i);
	}

	if (boolean(value(VERBOSE)))
		printf("Using \"%s\"\n", acu);

	acu_hupcl ();

	/*
	 * Get in synch.
	 */
	if (!multitechsync()) {
badsynch:
		printf("can't synchronize with multitech\n");
#if ACULOG
		logent(value(HOST), num, "multitech", "can't synch up");
#endif
		return (0);
	}
	acu_nap (intercommand_delay);

	multitech_write_str (FD, echo_off_command);	/* turn off echoing */

	sleep(1);

#ifdef DEBUG
	if (boolean(value(VERBOSE)))
		multitech_verbose_read();
#endif

	acu_flush ();

	acu_nap (intercommand_delay);
	multitech_write_str (FD, init_string);

	if (!multitech_swallow ("\r\nOK\r\n"))
		goto badsynch;

	fflush (stdout);

	acu_nap (intercommand_delay);
	multitech_write_str (FD, dial_command);

	for (cp = num; *cp; cp++)
		if (*cp == '=')
			*cp = ',';

	multitech_write_str (FD, num);

	multitech_write_str (FD, "\r");

	connected = multitech_connect();

#if ACULOG
	if (timeout) {
		sprintf(line, "%d second dial timeout",
			number(value(DIALTIMEOUT)));
		logent(value(HOST), num, "multitech", line);
	}
#endif
	if (timeout)
		multitech_disconnect ();
	return (connected);
}
Пример #4
0
void multitech_abort ()
{
	multitech_write_str (FD, "\r");	/* send anything to abort the call */
	multitech_disconnect ();
}