[PARPORT] carefully does it


Tim Waugh (tim@cyberelk.demon.co.uk)
Sat, 1 May 1999 19:30:26 +0100 (GMT)


In 2.0.36, LP_CAREFUL was used for switching between these two methods of
determining that a printer is ready:

a) Careless: just look at BUSY
b) Careful: check all status lines

In 2.2, we no longer have LP_CAREFUL, and use option (b). This has caused
problems on two separate occasions: one where SELECT wasn't what we
expected it to be, and one where PAPEROUT wasn't what we expected it to
be.

I would like to suggest the following alternative:

c) Check BUSY and nFault (ERROR)

The reason for this is that IEEE 1284 suggests that historical practice
has been to assert Fault when a fault condition exists, _including_ paper
out and off-line.

Patch follows (against 2.2.7), showing what I mean.

Tim.
*/

--- lp.c~ Wed Mar 24 01:42:57 1999
+++ lp.c Sat May 1 19:29:28 1999
@@ -198,7 +198,8 @@
 };
 
 /* Test if printer is ready */
-#define LP_READY(status) ((status) & LP_PBUSY)
+#define LP_READY(status) (((status) & (LP_PBUSY|LP_PERRORP)) == \
+ (LP_PBUSY|LP_PERRORP))
 /* Test if the printer is not acking the strobe */
 #define LP_NO_ACKING(status) ((status) & LP_PACK)
 /* Test if the printer has error conditions */
@@ -290,21 +291,18 @@
                 lp_yield(minor);
 
                 status = r_str(minor);
- if (LP_NO_ERROR(status))
- {
- if (LP_READY(status))
- break;
+ if (LP_READY(status))
+ break;
 
- /*
- * This is a crude hack that should be well known
- * at least by Epson device driver developers. -arca
- */
- irq_ok = (!LP_POLLED(minor) &&
- LP_NO_ACKING(status) &&
- lp_table[minor].irq_detected);
- if ((LP_F(minor) & LP_TRUST_IRQ) && irq_ok)
- break;
- }
+ /*
+ * This is a crude hack that should be well known
+ * at least by Epson device driver developers. -arca
+ */
+ irq_ok = (!LP_POLLED(minor) &&
+ LP_NO_ACKING(status) &&
+ lp_table[minor].irq_detected);
+ if ((LP_F(minor) & LP_TRUST_IRQ) && irq_ok)
+ break;
                 /*
                  * NOTE: if you run with irqs you _must_ use
                  * `tunelp /dev/lp? -c 1' to be rasonable efficient!

-- To unsubscribe, send mail to: linux-parport-request@torque.net --
-- with the single word "unsubscribe" in the body of the message. --



This archive was generated by hypermail 2.0b3 on Sat 01 May 1999 - 14:41:49 EDT