Better approximation for TIOCGETP (gtty) for non-standard speeds.
Old variant returns 38400 for them, now it returns nearest matched rounded down, expect speeds in range 0 > speed < 50 rounded up to not produce hangup.
This commit is contained in:
parent
29ae13ad3c
commit
4e5f73581c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=9859
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* @(#)tty_compat.c 8.1 (Berkeley) 6/10/93
|
||||
* $Id: tty_compat.c,v 1.14 1995/08/01 23:27:36 ache Exp $
|
||||
* $Id: tty_compat.c,v 1.15 1995/08/02 06:55:35 ache Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -80,9 +80,22 @@ static struct speedtab compatspeeds[] = {
|
||||
};
|
||||
static int compatspcodes[] = {
|
||||
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
|
||||
1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
|
||||
1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200
|
||||
};
|
||||
|
||||
static
|
||||
int ttcompatspeedtab(speed, table)
|
||||
int speed;
|
||||
register struct speedtab *table;
|
||||
{
|
||||
if (speed == 0)
|
||||
return (0); /* hangup */
|
||||
for ( ; table->sp_speed > 0; table++)
|
||||
if (table->sp_speed <= speed) /* nearest one, rounded down */
|
||||
return (table->sp_code);
|
||||
return (1); /* 50, min and not hangup */
|
||||
}
|
||||
|
||||
int ttsetcompat(tp, com, data, term)
|
||||
register struct tty *tp;
|
||||
int *com;
|
||||
@ -187,16 +200,12 @@ ttcompat(tp, com, data, flag)
|
||||
case TIOCGETP: {
|
||||
register struct sgttyb *sg = (struct sgttyb *)data;
|
||||
register cc_t *cc = tp->t_cc;
|
||||
register speed;
|
||||
|
||||
speed = ttspeedtab(tp->t_ospeed, compatspeeds);
|
||||
sg->sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
|
||||
sg->sg_ospeed = ttcompatspeedtab(tp->t_ospeed, compatspeeds);
|
||||
if (tp->t_ispeed == 0)
|
||||
sg->sg_ispeed = sg->sg_ospeed;
|
||||
else {
|
||||
speed = ttspeedtab(tp->t_ispeed, compatspeeds);
|
||||
sg->sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
|
||||
}
|
||||
else
|
||||
sg->sg_ispeed = ttcompatspeedtab(tp->t_ispeed, compatspeeds);
|
||||
sg->sg_erase = cc[VERASE];
|
||||
sg->sg_kill = cc[VKILL];
|
||||
sg->sg_flags = tp->t_flags = ttcompatgetflags(tp);
|
||||
|
Loading…
Reference in New Issue
Block a user