laser-lovers@uw-beaver (02/06/85)
From: Chris Torek <chris@maryland>
If you need only 8 bits of output (that is, if you can stand 7 bit input)
then all you need to do to an ordinary tty line is:
#include <sgtty.h>
seteightbits(ttyfd)
int ttyfd;
{
int bits;
struct sgttyb sg;
bits = LLITOUT;
if (ioctl(ttyfd, TIOCLBIS, &bits))
return (-1); /* something went wrong */
/* theoretically we're done now, but most 4BSD drivers have a
small bug, which we get around as follows: */
if (ioctl(ttyfd, TIOCGETP, &sg) || ioctl(ttyfd, TIOCSETN, &sg))
return (-1);
return (0); /* success */
}
You can eliminate the bug-workaround if your driver calls its param()
routine on TIOCLBIS ioctl()s. (Most of them only do it for TIOCSETN
and TIOCSETP; you should add TIOCLBIS, TIOCLBIC, and TIOCLSET to fix.)
Chris