[comp.sys.sgi] tty problems

alan@hal.larc.nasa.gov (alan dare) (05/01/91)

I having a problem using the tty ports to input data at 19200 baud on
my 310 VGX.  I've connected an Ascension Technology head tracker to ttyd2. The
port is set up as follows:

	port_setup.c_line = LDISC0;
        port_setup.c_iflag = IGNBRK | IGNPAR;
        port_setup.c_oflag = 0;
        port_setup.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
        port_setup.c_lflag = 0;
        status = ioctl(fd, TCSETA, &port_setup);


	I read the port with "read(fd, &buffer, 12)" because i'm expecting
a record to contain 12 bytes. The problem is sometimes it works...and sometimes it doesn't. It may read 5, 10, 20 or 50 records and then hang. A rep from
Ascension Technology thinks the driver may not be an interrupt driven
driver thus missing some data and some how hanging. I've not been able to
find any documentation describing the driver behind ttyd2. Does anyone know?
Has anyone out there used a device to input binary data at 19200 baud
on the tty ports with success or know what the problem might be?

Thanks...
-- 

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| In your head is the answer. Let it guide you along.     |
| Let your heart be the anchor and the beat of your song. |

vjs@rhyolite.wpd.sgi.com (Vernon Schryver) (05/02/91)

In article <1991May1.144614.5582@news.larc.nasa.gov>, alan@hal.larc.nasa.gov (alan dare) writes:
> 
> I having a problem using the tty ports to input data at 19200 baud on
> my 310 VGX.  I've connected an Ascension Technology head tracker to ttyd2. The
> port is set up as follows:
> 
> 	port_setup.c_line = LDISC0;
>         port_setup.c_iflag = IGNBRK | IGNPAR;
>         port_setup.c_oflag = 0;
>         port_setup.c_cflag = B9600 | CS8 | CLOCAL | CREAD;
>         port_setup.c_lflag = 0;
>         status = ioctl(fd, TCSETA, &port_setup);
> 
> 	I read the port with "read(fd, &buffer, 12)" because i'm expecting
> a record to contain 12 bytes. The problem is sometimes it works...and sometimes it doesn't. It may read 5, 10, 20 or 50 records and then hang. A rep from
> Ascension Technology thinks the driver may not be an interrupt driven
> driver thus missing some data and some how hanging.

Is Ascension Technology saying they think a usable UNIX tty driver might
use polling instead of interrupts?  If so, you might want to consider
a different vendor or at least another rep.

>                                                     I've not been able to
> find any documentation describing the driver behind ttyd2. Does anyone know?
> Has anyone out there used a device to input binary data at 19200 baud
> on the tty ports with success or know what the problem might be?

Did you mean 19.2 or 9600?  The code fragment above says 9600.

Do modems at 19.2 doing batches of compressed news count?
What about 19.2 modems and SLIP?  How about a WWV receiver?

When you set ICANON=0, as you have done, you also have to consider VTIM
and VMIN.  I bet you are suffering overrun, perhaps because your 
program does not deal with the input fast enough and the kernel buffers
overflow.  Then you do a read with VTIM & VMIN set to non-zero values,
and the kernel oblidgingly stops and waits forever.  Consider the long
explanation of VMIN and VTIM in `man termio`.

It would be better to use some kind of error correcting protocol between
the device and the computer--just to detect lost characters, protocol
botches, or mangled bits and then do a retry.
It would be best to at least use ttyf2 instead of ttyd2, so you get flow
control--if the Ascension device can do it.

Note that older release of 3.3 did have problems with heavy tty traffic
on MP systems.



Vernon Schryver,   vjs@sgi.com