[net.micro.att] ATT 3b2

djs@wlcrjs.UUCP (David Schmidt) (07/16/85)

  The company I work for recently recieved a 3b2 on loan from
ATT.  In porting some programs I have come across a problem.
Many of the programs I'm trying to port require CBREAK and no
ECHO modes.  How is this done under SVR2?  Any help would be
appreciated (examples best of all!).  The local (and Seattle too)
ATT guys are mostly marketing types and don't know the answers
to my questions.
  Also if anyone has a 3B2 version of hack and would be willing
to send me a copy please mail me a MESSAGE and I'll pick the
shortest route to get me one copy (binary only is ok).
--
	David Schmidt
	ISC Systems Corp
	Spokane, Wa
	ihnp4!tektronix!reed!iscs!david

"Life is a tough job...and the hours are lousy!"

heiby@cuae2.UUCP (Ron Heiby) (07/19/85)

In article <746@wlcrjs.UUCP> djs@wlcrjs.UUCP (David Schmidt) writes:
>
>Many of the programs I'm trying to port require CBREAK and no
>ECHO modes.  How is this done under SVR2?

In Unix System V, the terminal modes have quite a lot of flexibility in
determining when a read() can complete.  They are documented in excruciating
detail in termio(7) (in the "AT&T 3B2 Computer UNIX System V Release 2.0
System Administration Utilities Guide", Select Code 305-422, Comcode
403778384, which is bundled with the 3B2 and which you should have received).

What you basically want to do is turn off ICANON and set VMIN and VTIME as
your application requires.  CBREAK is, I believe, MIN=1, TIME=0.  "The MIN
and TIME values are stored in the position for the EOF and EOL characters,
respectively.  The time value represents tenths of seconds."
To turn off echo modes, turn off that bit, as well.  (It may be that this
is automatic, but I don't think so.)  The parameters are changed via ioctl()
operations.  I strongly recommend using TCSETAW instead of TCSETA, because
some computer systems actually implement a no-wait mode stomper, which can
garble some characters being output at the time.
-- 
Ron Heiby	heiby@cuae2.UUCP	(via ihnp4)
AT&T-IS, /app/eng, Lisle, IL	(312) 810-6109

root@bu-cs.UUCP (Barry Shein) (07/21/85)

>From: heiby@cuae2.UUCP (Ron Heiby)
>Subject: Re: ATT 3b2 (SVR2) questions
>
>What you basically want to do is turn off ICANON and set VMIN and VTIME as
>your application requires.  CBREAK is, I believe, MIN=1, TIME=0.  "The MIN
					^^^^^^^^^^^^^^^^^^^^^^^^
>and TIME values are stored in the position for the EOF and EOL characters,
>respectively.  The time value represents tenths of seconds."

[FLAME ON]

Yeah Ron, I agree wholeheartedly, to quote in full from TERMIO(7):

"A read will not be satisfied until at least MIN characters have been
received or the timeout value has expired...The MIN and TIME values are
in the position for the EOF and EOL characters respectively. The time value
represents tenths of seconds."

Not too clear is it: Does a zero value in TIME produce non-blocking I/O
(timeouts occur immediately?) or should that be -1?  or does that end up
to be 255 on most machines and then the read times out in 25.5 seconds?

Maybe I'll go read the source, but not having a uniform 'no-op' value is
a bug in c_cc[].

And I won't even mention how bad an idea it was to put termio into the
administrator's manual (hasn't anyone at ATTIS heard of students?)  or
the fact that those #defines are actually VMIN and VTIME not MIN and
TIME (and VEOF, VEOL, you mention this but the man page doesn't)
....oops, guess I just did.

I'm not surprised people are confused about this very important section,
if they can find it at all.

[FLAME OFF]

	-Barry Shein, Boston University

P.S. I am not flaming at Ron, he gave a fine answer under the
circumstances, maybe someone who can get this all fixed will do
something about it.

guy@sun.uucp (Guy Harris) (07/23/85)

> "A read will not be satisfied until at least MIN characters have been
> received or the timeout value has expired...The MIN and TIME values are
> in the position for the EOF and EOL characters respectively. The time value
> represents tenths of seconds."
> 
> Not too clear is it: Does a zero value in TIME produce non-blocking I/O
> (timeouts occur immediately?) or should that be -1?  or does that end up
> to be 255 on most machines and then the read times out in 25.5 seconds?

The only real explanation of what (V)MIN and (V)TIME do that tells
*everything* is in the System V Interface Definition; it gets a subsection
to itself which is 5 paragraphs long.  I think the System III rules were
quite fine, thank you - they took less space to explain, and the only thing
they didn't do is provide a way to do read timeouts, but that's what "alarm"
is for.

Basically, if MIN is non-zero:

	If TIME is zero, there is no timeout of any sort; the read
	doesn't complete until (int)c_cc[VMIN] characters have come in.

	If time is non-zero, the read completes if (int)c_cc[VMIN]
	characters have come in or *at least one* character has come in
	and (int)c_cc[VTIME] 10ths of a second have elapsed since the
	first character came in.

If MIN is zero:

	If TIME is zero, you get a no-delay read (that's what the S5ID says,
	at least; I haven't checked the code).

	If TIME is non-zero, the read completes as soon as a character
	comes in or (int)c_cc[VMIN] 10ths of a second have elapsed since
	the "read" system call was first made.

> And I won't even mention how bad an idea it was to put termio into the
> administrator's manual (hasn't anyone at ATTIS heard of students?)

AMEN.  WAKE UP, SOMEBODY, AND PUT THAT SECTION IN THE *P*R*O*G*R*A*M*M*E*R*S*
MANUAL WHERE IT BELONGS!  Administrators don't care how to write screen
editors.  Programmers do.

	Guy Harris

mats@dual.UUCP (Mats Wichmann) (07/28/85)

This VMIN/VTIME business is being carefully described in the IEEE P1003
proposals as well...and has been the cause of some head-banging,
not suprisingly. The business of sharing entries in the c_cc array,
depending on how some of the other flags have been set up, is
how shall we say, a bit distasteful....and the addition of
SWTCH for c_cc[7] (for shl) makes hash of the rather sensible idea of
using c_cc[6,7] for VMIN and VTIME. Oh well, time to grow
the array....

    Mats Wichmann
    Dual Systems
    ...{ucbvax,ihnp4,cbosgd,decwrl,fortune}!dual!mats

gwyn@brl-tgr.ARPA (Doug Gwyn <gwyn>) (07/29/85)

> ....and the addition of
> SWTCH for c_cc[7] (for shl) makes hash of the rather sensible idea of
> using c_cc[6,7] for VMIN and VTIME.

If the sharing of c_cc[6,7] was a kludge, the introduction of SWTCH
was a botch.  "shl" has so many problems that it is not worth it,
particularly in light of the existence of a better, inexpensive
alternative (5620 DMD).  What we need are FEWER out-of-band tty
characters, not more!