usr.bin/tip/libacu/t3000.c
static int
t3000_sync()
{
	int already = 0;
	int len;
	char buf[40];

	while (already++ < MAXRETRY) {
		ioctl(FD, TIOCFLUSH, 0);	/* flush any clutter */
		t3000_write(FD, "\rAT Z\r", 6);	/* reset modem */
		bzero(buf, sizeof(buf));
		sleep(2);
		ioctl(FD, FIONREAD, &len);
#if 1
if (len == 0) len = 1;
#endif
		if (len) {
			len = read(FD, buf, sizeof(buf));
#ifdef DEBUG
			buf[len] = '\0';
			printf("t3000_sync: (\"%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.
		 */
		sleep(1);
		t3000_write(FD, "+++", 3);
		sleep(1);
		/*
		 * Toggle DTR to force anyone off that might have left
		 * the modem connected.
		 */
		ioctl(FD, TIOCCDTR, 0);
		sleep(1);
		ioctl(FD, TIOCSDTR, 0);
	}
	t3000_write(FD, "\rAT Z\r", 6);
	return (0);
}
/*
 * This convoluted piece of code attempts to get
 * the t3000 in sync.
 */
This convoluted piece of code attempts to get
the t3000 in sync.
This convoluted piece of code attempts to get the t3000 in sync .
static int
t3000_sync()
{
	int already = 0;
	int len;
	char buf[40];
	while (already++ < MAXRETRY) {
		ioctl(FD, TIOCFLUSH, 0);	
		t3000_write(FD, "\rAT Z\r", 6);	
		bzero(buf, sizeof(buf));
		sleep(2);
		ioctl(FD, FIONREAD, &len);
#if 1
if (len == 0) len = 1;
#endif
		if (len) {
			len = read(FD, buf, sizeof(buf));
#ifdef DEBUG
			buf[len] = '\0';
			printf("t3000_sync: (\"%s\")\n\r", buf);
#endif
			if (index(buf, '0') ||
		   	   (index(buf, 'O') && index(buf, 'K')))
				return(1);
		}
		sleep(1);
		t3000_write(FD, "+++", 3);
		sleep(1);
		ioctl(FD, TIOCCDTR, 0);
		sleep(1);
		ioctl(FD, TIOCSDTR, 0);
	}
	t3000_write(FD, "\rAT Z\r", 6);
	return (0);
}
static int t3000_sync ( ) { int already = 0 ; int len ; char buf [ 40 ] ; while ( already ++ < MAXRETRY ) { ioctl ( FD , TIOCFLUSH , 0 ) ; t3000_write ( FD , " \r \r " , 6 ) ; bzero ( buf , sizeof ( buf ) ) ; sleep ( 2 ) ; ioctl ( FD , FIONREAD , & len ) ; #if 1 if ( len == 0 ) len = 1 ; #endif if ( len ) { len = read ( FD , buf , sizeof ( buf ) ) ; #ifdef DEBUG buf [ len ] = ' \0 ' ; printf ( " \" \" \n \r " , buf ) ; #endif if ( index ( buf , ' ' ) || ( index ( buf , ' ' ) && index ( buf , ' ' ) ) ) return ( 1 ) ; } sleep ( 1 ) ; t3000_write ( FD , " " , 3 ) ; sleep ( 1 ) ; ioctl ( FD , TIOCCDTR , 0 ) ; sleep ( 1 ) ; ioctl ( FD , TIOCSDTR , 0 ) ; } t3000_write ( FD , " \r \r " , 6 ) ; return ( 0 ) ; }
This convoluted piece of code attempts to get
 the t3000 in sync.
This convoluted piece of code attempts to get the t3000 in sync .
/* flush any clutter */ /* reset modem */ /*
		 * If not strapped for DTR control,
		 * try to get command mode.
		 */ /*
		 * Toggle DTR to force anyone off that might have left
		 * the modem connected.
		 */