[comp.unix.xenix] Serial Printer on Terminal

gah@blft1.UUCP (Gregg Houck SysOp) (05/03/88)

Am having a small problem using a serial printer off of a remote
terminal.  Here is the setup:

	* IBM AT 6Mhz
	* Consensys Powerports Board
	* Wyse 50 Terminals
	* Oki-Data MicroLine 294 serial printer.
	* All setup using XON/XOFF Protocall....
	* Termianl speed set or tested at 9600 and 38.4kb..
	* Printer Aux port tested at 9600 and 19.2kb..

Now, Trying to send a printjob to the printer works just fine until you
reach the end.  After printing a question is to come up on the screen
and the printer should be off.  What happens is that the question sent to
the screen shows on the printer.  After this the printer does shut off.
We are using the Basmark basic compiler and interfacing the printer is
by using the LPR variable..  Here is how I have the link setup.

	* I set LPR="cat > lcat > /dev/ttyh?"

The C program lcat.c is as follows..

#include <stdio.h>
main()
{
		int c;
	putchar(24); /* Turn on Transparent print */
	while ((c = getchar() ) != 126)
		putchar(c);
	putchar(20); /* Turn Transparent print off */
}

Can anyone help?  I'm at a loss and the companies are of little or
no help..

Thanks in advance.

Gregg


Gregg Houck  :  ..psuvax1!blft1!gah        |    NITTANY LION COUNTRY
HOUCK'S COMMUNICATIONS and ELECTRONICS     |       GOoooo LIONS!
(814)-355-7648  ----  (800)-544-8450       |         WE'RE #1

les@chinet.UUCP (Leslie Mikesell) (05/07/88)

In article <293@blft1.UUCP> gah@blft1.UUCP (Gregg Houck SysOp) writes:
>Am having a small problem using a serial printer off of a remote
>terminal.  Here is the setup:
>...
>and the printer should be off.  What happens is that the question sent to
>the screen shows on the printer.  After this the printer does shut off.

What is happening is that the hardware buffers are holding the "printer-off"
code long enough for the output of the next program to get ahead of it.
You need to add:
  fflush(file);
  ioctl(fileno(file),TCSBRK,1);
to wait for I/O to complete.

If that doesn't work (and it doesn't with some hardware), add a short
sleep() at the end.  Some terminals take a while to respond to control
codes also, so you may have to allow for that with a delay.  Even worse,
some will do buffering for the printer, but will stop immediately when
the "printer-off" code is received without printing the rest of the
buffered data.

   Les Mikesell