/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
#pragma ident "%Z%%M% %I% %E% SMI"
#include <stdio.h>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termio.h>
#include <unistd.h>
#include <signal.h>
#include <stdlib.h>
#include "tmextern.h"
/*
* At this time, we only recognize certain speeds.
* This table can be expanded if new patterns are found
*/
static struct autobaud {
char *a_speed;
} autob2400[] = {
#ifdef i386
/*
* These are the bit patterns returned on x86 boxes
*/
"110", "\1\000",
#else
"110", "\3\000\000\000",
#endif
"1200", "\2\346\200",
"2400", "\1\15",
"4800", "\1\371",
"4800", "\1\362",
"9600", "\1\377",
0, 0
};
/*
* auto_termio - set termio to allow autobaud
* - the line is set to raw mode, with VMIN = 5, VTIME = 1
* - baud rate is set to 2400
*/
int
{
return(-1);
}
log("auto_termio: ioctl TCSETAF failed, fd = %d: %s",
return(-1);
}
} else {
log("auto_termio: ioctl TCSETSF failed, fd = %d: %s",
return(-1);
}
}
return(0);
}
/*
* autobaud - determine the baudrate by reading data at 2400 baud rate
* - the program is anticipating <CR>
* - the bit pattern is matched again an autobaud table
* - if a match is found, the matched speed is returned
* - otherwise, NULL is returned
*/
char *
{
int i, k, count;
extern void timedout();
extern void flush_input();
#ifdef DEBUG
debug("in autobaud");
#endif
while (count--) {
if (timeout) {
}
if ( peek_ptr ) {
}
if (timeout)
(void)alarm((unsigned)0);
buf[0] = (char)k;
for (i = 0;; i++) {
break;
if (i == buf[0]) {
}
}
}
} /* end while */
return(NULL); /* autobaud failed */
}