ITEM: I0362L

How do I prevent losing data with printer offline (as a tty)




Question:

I am forced to add my printers as tty's to get around some of the complications
of the drivers.  When I do this, I am not able to use the stick XON/XOFF feature
of the printer driver. (3.2.5)  I am using 3 wire cable and can only use XON
flow control, but if I take the printer off line when the queue is empty, I
lose data.  How do I prevent this?

How to use sticky XON/XOFF with a tty

One of the major problems with adding a printer as a tty is that when
this is done, if the queue is empty and someone turns the printer offline
with only XON/XOFF flow control, all data sent to the printer will be
flushed out the port but not received by the printer.  This happens  
because the driver ignores XOFF when the port is not open.  However, a tty 
can have multiple opens on the port.  We can take advantage of this feature
to solve the problem.  By creating a never ending shell script, running the 
shell script with output redirected to the port, we leave the port OPEN.
This will not effect the operation of the

Created the following shell script:

\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#
while true
 do
 sleep 60000
 done
\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#\#

called it holdtty

Ran as follows:

\# holdtty > /dev/tty4 &

As a caution to make ixon and ixoff not float run the following command:

\# stty ixon ixoff \< /dev/tty4 &

I tested with a terminal by hitting CTRL-S , ofc light came on.
I then sent data to the port with

\# lptest > /dev/tty4

No data was sent, the command hung until I hit CTRL-Q then data
started flowing.  CTRL-S stopped the data, CTRL-Q started again.
No data was lost.

Next created a queue on the tty and sent data to the queue.  

\#mkvirprt
        1. Printer attached to host.
        Enter device name (or, ! to exit ) ->  tty4
        select printer type:

\# enq -Ptty5 /etc/motd

Once again I could stop flow with CTRL-S between or during jobs.

If I stopped the shell process running the sleep, then CTRL-S no longer
worked between jobs.



Support Line: How do I prevent losing data with printer offline (as a tty) ITEM: I0362L
Dated: April 1994 Category: N/A
This HTML file was generated 99/06/24~13:30:46
Comments or suggestions? Contact us