writing an lpr filter (SunOS 4.1.1)
Robert Perlberg
perl at dwrsun2.UUCP
Fri Jun 21 07:05:15 AEST 1991
In writing an lpd filter for an HP LaserJet, I discovered something
important. It may not be necessary on all systems, but it sure was on
mine (SunOS 3.5 at the time).
I had a problem with handshaking not working and sometimes small jobs
just wouldn't print at all. I discovered that the problem was that
since my filter exits as soon as it finishes writing to the serial
port, the port had not been flushed. Apparently, when you close a
serial port before all of the data in the output queue has been
physically transmitted it can cause the driver to stop doing
handshaking, or to throw away the rest of the output queue. I solved
the problem by making sure in the filter that the serial port output
queue was empty before exiting. Here is the code I used for this:
#include <sgtty.h>
...
int outchars;
...
fflush(stdout);
while(ioctl(fileno(stdout), TIOCOUTQ, &outchars) == 0 && outchars > 0)
{
sleep(1);
}
Robert Perlberg
Dean Witter Reynolds Inc., New York
murphy!dwrsun2!perl
-- "I am not a language ... I am a free man!"
More information about the Comp.unix.questions
mailing list