Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
On some printers the libusb-based "usb" CUPS backend needs to send a reset signal to the printer #3964
The problem happens on Ubuntu Oneiric which uses CUPS 1.5.0. This is the first Ubuntu release which deprecates (blacklists) the usblp kernel module and uses a purely libusb-based "usb" CUPS backend.
The bug happens only for some printer models, including the Samsung ML-2250, ML-2570, and the OKI B410d. The Dymo label writer 450 is not affected. If the problem occurs it occurs with all drivers, PostScript, PCL, HPLIP, Ghostscript, ..., so it is not driver-specific.
The problem is that after the printer has printed a job its USB interface is not in the same state as before printing the job. Sending a second job, even if it is absolutely identical with the first job, leads to garbage being printed. Users report to work around this they have to turn off and turn on the printer or unplug and replug the USB cable before each print job so that the jobs get printed correctly.
A workaround was found by sending a USB reset (USBDEVFS_RESET IOCTL) to the /dev/bus/usb/XXX/YYY file representing the printer using a little C program (attached, compile with "gcc -o usbreset usbreset.c", then run "./usbreset /dev/bus/usb/XXX/YYY" as root or with "sudo") between jobs.
So a possible fix would be to let the "usb" CUPS backend send this IOCTL before (or after?) each job. The C code does not need any special library (not even libusb), so the code can be added without introducing new dependencies.
CUPS.org User: till.kamppeter
Attached is a patch for backend/usb-libusb.c. It makes a printer reset, equivalent to the small C program which I attached in the beginning (I checked the source code of libusb) before each job. After the reset I close the device and reinitialize the connection (simple reopen does not work), as otherwise some printers (I tested with 5 different HP printers) crash and reboot and/or drop the job.
Now all printers print reliably and one does not perceive any additional delay between jobs.
I am applying the patch to the Ubuntu package of CUPS and let the original bug reporter test whether it solves his problem.
Note that the patch is set up to get a quick testing and can perhaps be done in a more elegant way by someone who is more knowledgeable about USB than me.
CUPS.org User: henry128
I just posted STR #3965 for a very similar problem, except that I got ignored print jobs (not gibberish), and usb_reset() caused me even more problems.
I think it may solve your problem as well. I compared the USB trace between the usblp and libusb backends, and then made the libusb backend behave almost identically to usblp.
CUPS.org User: till.kamppeter
This patch is actually not needed and perhaps too invasive. The reporter of the Ubuntu bug
has tested the patch of STR #3965 and it is absolutely sufficient. There are also no known regressions reported by other Ubuntu users.
So the patch of this STR can be dropped in favor of the patch of STR #3965.