CUPS & HP 1102w: USB reset printer

Linux howto's, compile information, information on whatever we learned on working with linux, MACOs and - of course - Products of the big evil....
Post Reply
User avatar
^rooker
Site Admin
Posts: 1482
Joined: Fri Aug 29, 2003 8:39 pm

CUPS & HP 1102w: USB reset printer

Post by ^rooker »

[PROBLEM]
I'm using an HP 1102w b/w laser printer for almost 10 years now. It's a great printer!

Unfortunately, it suffers from an annoying bug/issue with CUPS:
Most of the time, the printer needs to be reset after each print, otherwise it will not spit out any following print jobs.

Turning the printer off-and-on again works, but causes the printer to do its mechanical power-on-initialization movement (you can hear it), which is unnecessary here and may age the mechanics faster than necessary. Unplugging the USB cable also works, but just seems wrong. For some time I've also added an extra USB hub that I could power on/off - but that also seems like a very ugly workaround.

[SOLUTION]
On GNU/Linux, it's possible to reset a certain USB device, given that you know the "USB path" (=which hub/port) it's connected to.

1) Soft reset the USB port

Here's a small shell script I wrote that I run after each printout now. It soft-resets (unbind/bind) that specific USB port the printer is connected to. Works like a charm. Still a workaround, but I didn't have the time (or nerves) yes to actually debug the CUPS/driver that causes this issue.

Code: Select all

USB_SYSFS="/sys/bus/usb/drivers/usb"
USB_PATH="$1"       # Syntax is like "1-1.2", etc.

echo "Resetting '$USB_PATH'..."

# Disconnect:
echo $USB_PATH > $USB_SYSFS/unbind
# Reconnect:
echo $USB_PATH > $USB_SYSFS/bind

echo "Done."
Save it as "/usr/local/sbin/usbreset" and call it like this:

Code: Select all

$ sudo usbreset 1-1.3

2) How to find out "where" your printer is actually connected

You can use "lsusb" to find out on which USB path your printer is connected.
Your output will look different, but something like this:

Using "lsusb -t" shows a tree-like structure (but a bit harder to find which is the printer):
/: Bus 01.Port 1: Dev 1, Class=root_hub, Driver=dwc_otg/1p, 480M
|__ Port 1: Dev 2, If 0, Class=Hub, Driver=hub/3p, 480M
|__ Port 1: Dev 3, If 0, Class=Vendor Specific Class, Driver=smsc95xx, 480M
|__ Port 2: Dev 17, If 0, Class=Vendor Specific Class, Driver=, 480M
|__ Port 2: Dev 17, If 1, Class=Printer, Driver=usblp, 480M
|__ Port 2: Dev 17, If 2, Class=Mass Storage, Driver=usb-storage, 480M
|__ Port 3: Dev 21, If 0, Class=Printer, Driver=usblp, 480M
|__ Port 3: Dev 21, If 1, Class=Vendor Specific Class, Driver=, 480M
If you have multiple printers connected, just running "lsusb" may help narrowing down which one you mean:
Bus 001 Device 021: ID 03f0:102a Hewlett-Packard
Bus 001 Device 017: ID 04b8:0898 Seiko Epson Corp.
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. SMSC9512/9514 Fast Ethernet Adapter
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. LAN9500 Ethernet 10/100 Adapter / SMSC9512/9514 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
As you can see, on my setup I have 2 printers: One HP (=the laserjet) and 1 Epson (actually just used as a network scanner with "sane" 8) )
Jumping out of an airplane is not a basic instinct. Neither is breathing underwater. But put the two together and you're traveling through space!
Post Reply