4.[123]bsd dev/lp hoards final form feed (with fix)

Arthur David Olson ado at elsie.UUCP
Wed Feb 26 15:09:12 AEST 1986


Index:	sys/vaxuba/lp.c

Description:
	The lp driver will, with certain interfaces and printers (we've got a
	Printronix 600 ourselves), hold the the final form feed generated by
	closing the device until the device is reopened.  Not a problem for
	high-print-volume sites; a paper waster at low-volume sites, though
	(details upon request).

Repeat-By:
	Using the command
		echo HI > /dev/lp
	If you've got the problem, the page with the word HI on it will not be
	feed out of the printer, despite the fact that "lpclose" generated a
	form feed.

Fix:
	The problem comes about because various parts of the code test
		sc_outq.c_cc > 0
	to see if there's work to do.  But if the driver has read a character
	out of the above queue and was unable to output the character, the
	driver saves the character away in sc_lpchar.  So even if sc_outq.c_cc
	is zero, there may be work to do.

	Here are the changes to the 4.1bsd version of lp.c, conditioned on
	"OLDVERSION."

	First, a change to "lpintr":

	...
	sc->sc_state |= MOD;
#ifdef OLDVERSION
	if (sc->sc_outq.c_cc > 0 && (lpaddr->lpsr&ERROR)==0)
#else
	if (sc->sc_lpchar >= 0 && (lpaddr->lpsr&ERROR)==0)
#endif
		lpaddr->lpsr |= IENABLE;	/* ok and more to do later */
	if (n>LPLWAT && sc->sc_outq.c_cc<=LPLWAT && sc->sc_state&ASLP) {
		sc->sc_state &= ~ASLP;
		wakeup((caddr_t)sc);		/* top half should go on */
	}
	...

	There are also two changes to "lptout":

	...
#ifdef OLDVERSION
	if ((sc->sc_state&OPEN) == 0) {
#else
	if ((sc->sc_state&OPEN) == 0 && sc->sc_lpchar < 0) {
#endif
		sc->sc_state &= ~TOUT;		/* no longer open */
		lpaddr->lpsr = 0;
		return;
	}
#ifdef OLDVERSION
	if (sc->sc_outq.c_cc && (lpaddr->lpsr&DONE) && (lpaddr->lpsr&ERROR)==0)
#else
	if (sc->sc_lpchar>=0 && (lpaddr->lpsr&DONE) && (lpaddr->lpsr&ERROR)==0)
#endif
		lpintr(LPUNIT(dev));			/* ready to go */
	timeout(lptout, (caddr_t)dev, 10*hz);
	...
--
Bugs is a Warner Brothers trademark.
LP may have been a Columbia trademark at one time.
--
	UUCP: ..decvax!seismo!elsie!ado    ARPA: elsie!ado at seismo.ARPA
	DEC, VAX and Elsie are Digital Equipment and Borden trademarks



More information about the Comp.bugs.4bsd.ucb-fixes mailing list