[comp.sys.sun] lpr loses last part of output

jns@meridian.com (Jerry N Sweet) (04/27/89)

We have a Printronix P6040L printer hooked up to the ALM-2 parallel port
on a Sun 3/260 running SunOS 4.0.1.  About half the times that lpr is used
with plain text, the very last part of the output is mysteriously
truncated.  The problem is reproducible with certain files.  Has anyone
else run into this one---and fixed it?  There doesn't seem to be anything
special in /etc/printcap that needs to be set, but perhaps I'm missing
something.  Here's the entry:

0|lp|printronix|Printronix P6040L:lp=/dev/mcpp0:sd=/var/spool/lpd:\
	:pl#66:pw#80:fo:df=/i/dvi/dviprx:

I'm not 100% certain it's not a problem with the printer itself; to make
the P6040L work with the ALM-2 parallel port, certain resistors in the
printer's Centronics interface had to be exchanged for others in a
standard, documented way.  But I'm not a hardware person; I know not to
stick my fingers in light sockets and how to pull socketed chips, and
that's about it.

The only work-around we can think of is to append a big "END OF FILE"
banner to the output.  This seems to work fairly reliably, but it's icky.

rcodi@uunet.uu.net (Ian Donaldson) (05/08/89)

> We have a Printronix P6040L printer hooked up to the ALM-2 parallel port
> on a Sun 3/260 running SunOS 4.0.1.  About half the times that lpr is used
> with plain text, the very last part of the output is mysteriously
> truncated.  The problem is reproducible with certain files.  Has anyone
> else run into this one---and fixed it?  There doesn't seem to be anything
> special in /etc/printcap that needs to be set, but perhaps I'm missing
> something.  

There is a bug in a lot of old BSD tty drivers in that the last close on
the device drops DTR before the last data goes out.  This means that if
DCD is connected to DTR (some how) then the last lot of data might be
flushed down the toilet.

In short, the icky method of sticking out extra blanks on the output at
the end works fine.  Another approach is to sleep(4) after you've written
the last data to allow it time to go out.  For lpr, this means you need
your own filter that does this, to replace "lpf".

The fix in the tty driver (at least 4.2bsd and SunOS 3.5 I suspect) is to
reorder the the statements that do the ttyflush() in the code that detects
the drop in DCD.  In 4.3bsd this is fixed in ttymodem() (this is all from
memory, and a bit hazy at that...)

Anyway, I *know* the bug exists in SunOS 3.3 thru 3.5 and Vax 4.2bsd.  Not
sure about other SunOS's.  The bug doesn't exist in Vax 4.3bsd however.

Ian D

jeff@tc.fluke.com (Jeff Stearns) (05/09/89)

jns@meridian.com (Jerry N Sweet) writes:
>We have a Printronix P6040L printer hooked up to the ALM-2 parallel port
>on a Sun 3/260 running SunOS 4.0.1.  About half the times that lpr is used
>with plain text, the very last part of the output is mysteriously
>truncated.  ...

Have you installed the "General TTY Patches" tape from Sun?  It's alleged
to cure this problem (which occurs with other serial ports under SunOS
4.0.1 as well).

You'll see this same problem if you just "cat file>/dev/ttya", for example.
-- 
    Jeff Stearns        John Fluke Mfg. Co, Inc.               (206) 356-5064
    jeff@tc.fluke.COM   {uw-beaver,microsoft,sun}!fluke!jeff

PS - Calling all users of the Vitalink TransLAN IV Ethernet bridge! Please
     drop me a line.