*BSD News Article 67784


Return to BSD News archive

Path: euryale.cc.adfa.oz.au!newshost.anu.edu.au!harbinger.cc.monash.edu.au!news.bhp.com.au!mel.dit.csiro.au!munnari.OZ.AU!news.hawaii.edu!ames!usenet.kornet.nm.kr!usenet.etri.re.kr!news.kreonet.re.kr!usenet.seri.re.kr!news.cais.net!news.mathworks.com!fu-berlin.de!zib-berlin.de!news.tu-chemnitz.de!irz401!uriah.heep!news
From: j@uriah.heep.sax.de (J Wunsch)
Newsgroups: comp.unix.bsd.freebsd.misc
Subject: Re: HP Deskjet 540 Setup Assistance Requested
Date: 5 May 1996 16:11:14 GMT
Organization: Private BSD site, Dresden
Lines: 128
Message-ID: <4mijv2$sb9@uriah.heep.sax.de>
References: <4mgefd$6j9@usenet.rpi.edu>
Reply-To: joerg_wunsch@uriah.heep.sax.de (Joerg Wunsch)
NNTP-Posting-Host: localhost.heep.sax.de
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 8bit
X-Newsreader: knews 0.9.6
X-Phone: +49-351-2012 669
X-PGP-Fingerprint: DC 47 E6 E4 FF A6 E9 8F  93 21 E0 7D F9 12 D6 4E

mahj@cortez.its.rpi.edu (Jon Mah (JaMah!)) wrote:

> 	I am running FreeBSD 2.1 Release, and have an
> HP Deskjet 540 which I am attempting to connect and use.
> In my preliminary setups, 
> 
> cat > /dev/lpt0
> lptest 20 5 > /dev/lpt0
> 
> each do not produce any output.

Not any output?  Or would they produce output after a rather long
amount of time (ie. you notice on the printer that it's receiving data
slowly, but no paper comes out)?

Several newer {Desk,Laser}Jets are known to be broken since HP has
botched the /ACK timing.  There's a fix available now (see below).
What makes me nervous is that all these printers worked fine in polled
mode.


Index: /sys/i386/isa/lpt.c
===================================================================
RCS file: /home/cvs/src/sys/i386/isa/lpt.c,v
retrieving revision 1.52
retrieving revision 1.53
diff -u -u -r1.52 -r1.53
--- lpt.c	1996/03/29 11:54:56	1.52
+++ lpt.c	1996/04/04 12:28:36	1.53
@@ -46,7 +46,7 @@
  * SUCH DAMAGE.
  *
  *	from: unknown origin, 386BSD 0.1
- *	$Id: lpt.c,v 1.52 1996/03/29 11:54:56 bde Exp $
+ *	$Id: lpt.c,v 1.53 1996/04/04 12:28:36 joerg Exp $
  */
 
 /*
@@ -149,7 +149,8 @@
 
 
 #define	LPINITRDY	4	/* wait up to 4 seconds for a ready */
-#define	LPTOUTTIME	4	/* wait up to 4 seconds for a ready */
+#define	LPTOUTINITIAL	10	/* initial timeout to wait for ready 1/10 s */
+#define	LPTOUTMAX	1	/* maximal timeout 1 s */
 #define	LPPRI		(PZERO+8)
 #define	BUFSIZE		1024
 
@@ -221,6 +222,7 @@
 #define LP_HAS_IRQ	0x01	/* we have an irq available */
 #define LP_USE_IRQ	0x02	/* we are using our irq */
 #define LP_ENABLE_IRQ	0x04	/* enable IRQ on open */
+	u_char	sc_backoff ;	/* time to call lptout() again */
 
 #ifdef INET
 	struct  ifnet	sc_if;
@@ -590,7 +592,8 @@
 	lprintf("irq %x\n", sc->sc_irq);
 	if (sc->sc_irq & LP_USE_IRQ) {
 		sc->sc_state |= TOUT;
-		timeout ((timeout_func_t)lptout, (caddr_t)sc, hz/2);
+		timeout ((timeout_func_t)lptout, (caddr_t)sc,
+			 (sc->sc_backoff = hz/LPTOUTINITIAL));
 	}
 
 	lprintf("opened.\n");
@@ -602,9 +605,12 @@
 {	int pl;
 
 	lprintf ("T %x ", inb(sc->sc_port+lpt_status));
-	if (sc->sc_state & OPEN)
-		timeout ((timeout_func_t)lptout, (caddr_t)sc, hz/2);
-	else
+	if (sc->sc_state & OPEN) {
+		sc->sc_backoff++;
+		if (sc->sc_backoff > hz/LPTOUTMAX)
+			sc->sc_backoff = sc->sc_backoff > hz/LPTOUTMAX;
+		timeout ((timeout_func_t)lptout, (caddr_t)sc, sc->sc_backoff);
+	} else
 		sc->sc_state &= ~TOUT;
 
 	if (sc->sc_state & ERROR)
@@ -785,6 +791,7 @@
 {
 	struct lpt_softc *sc = lpt_sc + unit;
 	int port = sc->sc_port, sts;
+	int i;
 
 #ifdef INET
 	if(sc->sc_if.if_flags & IFF_UP) {
@@ -793,9 +800,19 @@
 	}
 #endif /* INET */
 
-	/* is printer online and ready for output */
-	if (((sts=inb(port+lpt_status)) & RDY_MASK) == LP_READY) {
+	/*
+	 * Is printer online and ready for output?
+	 *
+	 * Avoid falling back to lptout() too quickly.  First spin-loop
+	 * to see if the printer will become ready ``really soon now''.
+	 */
+	for (i = 0;
+	     i < 100 &&
+	     ((sts=inb(port+lpt_status)) & RDY_MASK) != LP_READY;
+	     i++) ;
+	if ((sts & RDY_MASK) == LP_READY) {
 		sc->sc_state = (sc->sc_state | OBUSY) & ~ERROR;
+		sc->sc_backoff = hz/LPTOUTINITIAL;
 
 		if (sc->sc_xfercnt) {
 			/* send char */
@@ -822,6 +839,7 @@
 		if(((sts & (LPS_NERR | LPS_OUT) ) != LPS_NERR) &&
 				(sc->sc_state & OPEN))
 			sc->sc_state |= ERROR;
+		/* lptout() will jump in and try to restart. */
 	}
 	lprintf("sts %x ", sts);
 }


-- 
cheers, J"org

joerg_wunsch@uriah.heep.sax.de -- http://www.sax.de/~joerg/ -- NIC: JW11-RIPE
Never trust an operating system you don't have sources for. ;-)