36 lines
1.5 KiB
Diff
36 lines
1.5 KiB
Diff
diff -up hplip-3.9.8/prnt/backend/hp.c.device-reconnected hplip-3.9.8/prnt/backend/hp.c
|
|
--- hplip-3.9.8/prnt/backend/hp.c.device-reconnected 2009-09-29 16:02:14.717467334 +0100
|
|
+++ hplip-3.9.8/prnt/backend/hp.c 2009-09-29 16:02:20.019342096 +0100
|
|
@@ -638,6 +638,7 @@ int main(int argc, char *argv[])
|
|
HPMUD_DEVICE hd=-1;
|
|
HPMUD_CHANNEL cd=-1;
|
|
int n, total=0, retry=0, size, pages;
|
|
+ int consecutive_failures=0;
|
|
enum HPMUD_RESULT stat;
|
|
char *printer = getenv("PRINTER");
|
|
|
|
@@ -789,10 +790,23 @@ int main(int argc, char *argv[])
|
|
/* IO error, get printer status. */
|
|
if (loop_test(hd, cd, &pa, argv[0], printer, argv[2], argv[1], argv[3]))
|
|
goto bugout;
|
|
+
|
|
+ if (++consecutive_failures == 5)
|
|
+ {
|
|
+ /* hpmud_write_channel has failed several times in
|
|
+ * succession but the Device ID-based status says
|
|
+ * the printer is happy. Time to face the fact that
|
|
+ * the device has probably reconnected, and our USB
|
|
+ * channel is invalidated. */
|
|
+
|
|
+ BUG("ERROR: device reconnected?");
|
|
+ goto bugout;
|
|
+ }
|
|
}
|
|
else
|
|
{
|
|
/* Data was sent to device successfully. */
|
|
+ consecutive_failures = 0;
|
|
if (pa.pjl_device)
|
|
{
|
|
/* Laserjets have a large data buffer, so manually check for operator intervention condition. */
|