Newsgroups: comp.sys.transputer
From: ian@robots.ox.ac.uk (Ian Reid)
Subject: iserver problem
Organization: Robotics Research Group, Engineering Science Dept, Oxford, UK.
Date: Mon, 5 Dec 1994 09:22:02 GMT
Message-ID: <1994Dec5.092202.28379@percy.robots.ox.ac.uk>

My apologies if this has appeared already.

I have experienced a few problems with the standard iserver code which
others may be able to help me with ...

The first problem is that functions pollkey and getkey do not appear
to work correctly to spec on a Sun workstation.  The first problem is
relatively simple, namely that pollkey should return immediately.  It
in fact waits for 100ms, as a result of the following code.

	 CurMode.c_iflag &= ~ICRNL;
	 CurMode.c_lflag &= ~(ICANON | ECHO);
	 CurMode.c_cc[VTIME] = 1;
	 CurMode.c_cc[VMIN] = 0;
	 ioctl( 0, TCSETS, &CurMode );

The value of CurMode.c_cc[VTIME] gives the wait period in tenths of a
second, thus I believe the correct value should be 0, viz: 

	 CurMode.c_iflag &= ~ICRNL;
	 CurMode.c_lflag &= ~(ICANON | ECHO);
	 CurMode.c_cc[VTIME] = 0;
	 CurMode.c_cc[VMIN] = 0;
	 ioctl( 0, TCSETS, &CurMode );

Similarly I believe that the code for getkey, which is:

       CurMode.c_iflag &= ~ICRNL;
       CurMode.c_lflag &= ~(ICANON | ECHO);
       CurMode.c_cc[VTIME] = 1;
       CurMode.c_cc[VMIN] = 0;
       ioctl( 0, TCSETS, &CurMode );

should be:

       CurMode.c_iflag &= ~ICRNL;
       CurMode.c_lflag &= ~(ICANON | ECHO);
       CurMode.c_cc[VTIME] = 1;
       CurMode.c_cc[VMIN] = 1;
       ioctl( 0, TCSETS, &CurMode );

to return at least one key.

Is this a known problem?

The second, related problem concerns iserver's interaction with stdin
and stdout when redirected.  I have occasion to do this when I want to
use an X interface to a transputer program and, for example, button
presses are to replace keystrokes.  As soon as the standard streams
are redirected the ioctl call above fails and pollkey and getkey do
not operate correctly.  A way around this would be either:

(a) modify iserver so that pollkey and getkey check for stdin connected
to a terminal, and if not use "fcntl" calls to toggle
blocking/non-blocking I/O;

(b) Find out in the transputer code using an "iserver_transaction"
call (I think the code is "isatty") if stdin is connected to a
terminal and use fread((char *), 1, 1, stdin) instead.  This still
involves changing the iserver so that stdin can be toggled between
blocking and non-blocking I/O.

While I could do this by modifying the source for Inmos iserver, I am
running a transputer network hosted from an (Sun) S-Bus Sparc II
workstation, with the host transputer sited on a Volvox S-Bus ->
transputer board.  The source for the iserver driver for this board
was not distributed.  I have tried to contact Archipel to get the
source without success.

Does anyone have either a fix, some volvox iserver source, or a site
where I could access said source.

Many thanks,
Ian
--------------------------------------------------------------------------
Ian Reid                            _--_|\        ian@robots.oxford.ac.uk
Dept of Engineering Science        /      \
Oxford University, OX1 3PJ         \_.--._/
(0865) 2 73168                           v



