[net.unix-wizards] laser printers and 8 bit serial

tony@hp-sdd.UUCP (tony) (02/11/85)

> > > Does anyone know how to make a 4.2 terminal driver send out 8 data bits
> > > and honor x-on/x-off from the device.
> > 
> > Yes, use the "litout" stty mode.
> 
> I tried LLITOUT, it sends 7 bits with even parity on my SUN.
> More importantly, what complete set of flag bits and local mode
> bits did you use?
> Rather than have a reasonable stty (Like System V) where bits in the
> flags essentially control options independent of each other, 4.2 BSD
> gives you a hodgepodge of bits which interact.

It seems that there is a 4.2 bug which doesn't allow LLITOUT to be
set properly in /etc/printcap.  In fact, it you 'stty litout' to
your shell, it changes some things, but you must do it again to get
the full effect.  The same holds in the reverse direction.

I decided that neither RAW or LITOUT were appropriate, because I needed
CRMOD and XTABS to be on also, so I made my own mod to the terminal
driver.  Where it says something like:

if (ttyflags & (RAW | LITOUT))
     flag = BIT8;
  else
     flag = BIT7 | EVEN;

I changed it to include VTDELAY since I didn't notice an unused bit,
and there are no printers hooked up that need VTDELAY, and the
laser printer we use (HP LaserJet) does take a moment do formfeed,
AND, I get CRMOD and XTABS, AND XON/XOFF flow control, etc.  
It now looks more like:

if (ttyflags & (RAW | LITOUT | VTDELAY))
     flag = BIT8;
  else
     flag = BIT7 | EVEN;

This is not syntactically accurate, but it is the same general idea.
And my /etc/printcap entry is:

lpaf|Laser printer:\
	:lp=/dev/tty14:sd=/usr/spool/lpaf:lf=/usr/adm/lpaf-errs:\
        :fc#010:fs#046320:br#9600:pl#60:

Tony Parkhurst {hplabs,sdcsvax,hp-pcd,hpisla,hpfcla}!hp-sdd!tony

martillo@mit-athena.UUCP (Joaquim Martillo) (02/25/85)

I  should  think  (not having tried this) that setting the /dev/tty into
RAW|TANDEM  would  get  eight  bits  transmitted  and  the  the   device
start/stop requests would be honored.

lcc.gmwiz@UCLA-LOCUS.ARPA (Greg McGary) (02/26/85)

>	From: Joaquim Martillo <martillo@mit-athena.uucp>
>
>	I  should  think  (not having tried this) that setting the
>	/dev/tty into RAW|TANDEM  would  get  eight  bits  transmitted
>	and  the  the   device start/stop requests would be honored.

Please read the 4.xBSD manual page tty(4) in reference to TANDEM:

	In this mode the system produces a stop character (default ^S)
	when the input queue is in danger of overflowing, and a start
	character (default ^Q) when the input has drained sufficiently. 
	This mode is useful when the terminal is actually another machine
	that obeys the conventions.

In RAW mode, the tty has an 8-bit data-path in both directions, but
does not honor any start/stop requests.  In TANDEM mode, the tty
sends start/stop characters to the other end of the line whenever it
notices that its raw input queue is getting full or getting low.  The
state of the RAW flag {en,dis}ables a tty's response to flow control
requests, TANDEM {en,dis}ables a tty's generation of flow control
requests.

To wit, the TANDEM and RAW flags are orthogonal and have no direct
influence upon one another.  

Greg McGary
Locus Computing Corporation				       lcc!gm@ucla-cs
						{ucivax,trwrb}!lcc!gm
		 {ihnp4,randvax,sdcrdcf,ucbvax,trwspp}!ucla-cs!lcc!gm

martillo@mit-athena.UUCP (Joaquim Martillo) (02/28/85)

Well, if RAW and TANDEM are orthogonal, you should tell the authors of
4.2BSD kermit which in puts the terminal in RAW|TANDEM mode.  The reason
is with kermit, no special interpretation of input characters is desired
but the device hooked up to the RS232 port is assumed to be smart enough
to understand start stop protocol (unlike the average terminal).

Yehoyaqim Martillo

lund@ucla-cs.UUCP (03/11/85)

It seems to me that RAW mode and TANDEM mode are not necessarily orthogonal
if you take RAW to mean that no characters have special meaning. (They
aren't cooked.) In TANDEM mode ^S and ^Q are special. How do you pass
a ^S when in RAW and TANDEM mode at the same time? (Such as emacs might want)
I believe this is the case in the 4.1bsd tty driver, perhaps System 5
is different.

		....Laurence

	{ihnp4, ucbvax, sdcrdcf, cepu}!ucla-cs!lund,   lund@ucla-cs

chris@umcp-cs.UUCP (Chris Torek) (03/16/85)

This has all been gone over several times, but here it is again in
condensed format.  (Reference cards anyone?)

SUMMARY OF 4.2BSD TTY DRIVER FLAGS
----------------------------------

TANDEM		4.2 will send ^S to terminal when 4.2's buffers get full
		(use only in CBREAK or RAW, or you'll never get ^Q!)
CBREAK		4.2 will pass characters back to programs one at a time
LCASE		4.2 will simulate lowercase on uppercase only terminal
ECHO		4.2 will echo your typing
CRMOD		4.2 will print "\r\n" for "\n" and will accept both
		"\r" and "\n" as end of line
RAW		none of terminal's output is special in any way to 4.2
		(in particular, 4.2 will hand ^S/^Q to user programs
		regardless of other stty settings)
ODDP		4.2 will accept odd parity and (iff EVENP is off) generate
		odd parity
EVENP		4.2 will accept even parity and will generate even parity
ANYP		4.2 will accept any parity and probably generate even parity
NLDELAY		4.2 will use 1 of 4 time delays after "\n" (control J):
		NL0 => none; NL1,NL2,NL3 increasing
TBDELAY		4.2 will use 1 of 3 time delays after "\t", or (if
		set to XTABS) will expand tabs to right number of spaces:
		TAB0 => none; TAB1, TAB2 increasing
CRDELAY		4.2 will use 1 of 4 time delays after "\r" (control M):
		CR0 => none; CR1,CR2,CR3 increasing
VTDELAY		4.2 will use 1 of 2 time delays after "\f": FF0 => none,
		FF1 => some
BSDELAY		4.2 will use 1 of 2 time delays after "\b": BS0 => none,
		BS1 => some
ALLDELAY	just == NLDELAY|TBDELAY|CRDELAY|VTDELAY|BSDELAY
CRTBS		4.2 will print "\b" character to back up cursor on CRT when
		terminal sends "erase" character (usually DEL or BS or #)
PRTERA		4.2 will print original text inside \/ to "erase" on printer
		when terminal sends "erase" character
CRTERA		4.2 will print "\b \b" to remove text from CRT when terminal
		sends "erase" character
TILDE		4.2 will print backquote instead of tilde (hazeltine kludge)
MDMBUF		4.2 will treat carrier drop as ^S, raise as ^Q.  BEWARE:
		depends on driver; standard DZ driver does not support it
LITOUT		4.2 will send user's 8 bit bytes from write() syscalls
		directly to terminal (no parity, no \n=>\r\n etc).  BUG:
		depends on driver; (re)setting baud rate typically necessary
		to force LITOUT to take effect
TOSTOP		4.2 will stop background processes that attempt to write
		to terminal (sends SIGTTOU; <sys/ioctl.h> comment is wrong)
FLUSHO		4.2 is flushing output to terminal (^O key normally toggles)
NOHANG		4.2 won't send SIGHUP when carrier drops
CRTKIL		4.2 will print "\b \b" to remove line from CRT when terminal
		sends "line kill" character (usually ^U or ^X or @)
CTLECH		4.2 will echo control characters as ^, char (^A, ^D etc)
PENDIN		4.2 will retype input line on next char from terminal
DECCTQ		4.2 will only restart output for ^Q after ^S (other input
		accepted but not yet echoed)
NOFLSH		4.2 will not flush output on signals


NOTES
-----

All of these are settable via stty(1) and TIOCGET/TIOCSET ioctl(2)s.
Some of these have aliases starting with L; these aliases are for
use with TIOCLGET, TIOCLSET, etc.

This is not a comprehensive list of ioctls.

I haven't included local additions for ^T, and hope I haven't included
any other local changes.
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 4251)
UUCP:	{seismo,allegra,brl-bmd}!umcp-cs!chris
CSNet:	chris@umcp-cs		ARPA:	chris@maryland

guy@rlgvax.UUCP (Guy Harris) (03/16/85)

> It seems to me that RAW mode and TANDEM mode are not necessarily orthogonal
> if you take RAW to mean that no characters have special meaning. (They
> aren't cooked.) In TANDEM mode ^S and ^Q are special. How do you pass
> a ^S when in RAW and TANDEM mode at the same time? (Such as emacs might want)
> I believe this is the case in the 4.1bsd tty driver, perhaps System 5
> is different.

1) As Chris's article points out, RAW doesn't affect TANDEM at all.  TANDEM
doesn't affect what happens when the computer *receives* ^S or ^Q.  It
merely conditions the computer to *send* ^S when its buffers are getting
too full, and ^Q when they become sufficiently empty.

2) Why would EMACS want TANDEM mode?  EMACS wants an 8-bit data path on
terminals which have a META key which turns the 8th bit on, and may want
to disable special processing of ^S and ^Q on *input* (because people
tend to bind ^S to "search" and ^Q to "quote" - VT100s in smooth-scroll
mode *require* ^S/^Q flow control, and some versions of EMACS bind different
keys to "search" and "quote", and leave ^S/^Q processing on, to enable this).
The only way to do that in V7, or 4.xBSD, is to turn on RAW mode.  In
Systems III and V, the 8-bit data path can be selected by changing the
character size to 8 bits, disabling parity, and disabling stripping of
characters to 7 bits.  The handling of ^S/^Q on input can be disabled by
turning off the IXON mode.

If you're in RAW and TANDEM mode at the same time, any ^S or ^Q *received*
by the computer goes straight to the application program.  However, the
computer *will* send ^S and ^Q for flow control.
-- 
	Guy Harris
	{seismo,ihnp4,allegra}!rlgvax!guy

cmoore@amdimage.UUCP (chris moore) (03/19/85)

> It seems to me that RAW mode and TANDEM mode are not necessarily orthogonal
> if you take RAW to mean that no characters have special meaning. (They
> aren't cooked.) In TANDEM mode ^S and ^Q are special. How do you pass
> a ^S when in RAW and TANDEM mode at the same time? (Such as emacs might want)
> I believe this is the case in the 4.1bsd tty driver, perhaps System 5
> is different.
> 
> 		....Laurence
> 
> 	{ihnp4, ucbvax, sdcrdcf, cepu}!ucla-cs!lund,   lund@ucla-cs

TANDEM mode has nothing to do with interpretation of incoming
characters.  The TANDEM mode means that the system will SEND ^S
or ^Q to regulate INPUT to the system.  I have been succesfully
talking to an HP LaserJet under 4.2bsd using LITOUT mode, no RAW
and no TANDEM.  LITOUT makes the driver send all eight bits but
still allows input processing for ^S and ^Q


-- 

"My system is so slow we don't use 'who' anymore - it's faster to
 walk around the building and count the users."

 Chris Moore (408) 749-4692
 UUCP: {ucbvax,decwrl,ihnp4,allegra}!amdcad!amdimage!cmoore