How to Get a Scanner to Work in Linux

I have a Hewlett-Packard Laserjet 3050, their budget all-in-one printer, copier, fax, and scanner. According to the device matrix in the open source HPLIP project this machine is completely supported in Linux. However, I have a different definition of “support” than HP– theirs seems to be “A determined and stubborn Linux guru can make the darned thing work if they try really hard.”

The easy part is printing. Install the HPLIP packages, and the drivers will show up in CUPS. Piece of cake. The copier is easy too, just insert your document and hit a button. But

there isn’t any software control panel for adjusting copy quality, you

have to use the weird little printer control panel.

CUPS also shows a fax queue, but nothing happens when I send document to it. To send faxes I have to run a hard copy through the printer and use the printer control panel. Whatever, it works.

The 3050 has a sheet-feed scanner. Yeah, el cheapo, it’s what I could afford at the time. Here is where I get annoyed. My main workstation is Debian Lenny, and the darned thing does not set up scanners bloodlessly, you have to jump through mondo hoops. Last time I looked it was the 21st century, did something happen and I got sent back to 1998? Though I recall having to jump through the same hoops on Kubuntu last year on the same PC.

Useless HP Toolbox

The machine comes with the HP Toolbox, which is sort of useful, but mostly not. The graphical interface is very limited and doesn’t even recognize the printer and throws up sad communication errors. It doesn’t do much of anything, I wonder why they even bother.

There are some commands that are occasionally useful, and which helped me get the scanner to work. The first step for any scanner connected to a Linux PC is to consult the SANE supported devices database. (SANE is the scanner backend for Linux.) This isn’t 100% complete, but it’s a good start.

Then run this command to see if SANE detects your scanner:

$ scanimage -L

No scanners were identified. If you were expecting something different,

check that the scanner is plugged in, turned on and detected by the

sane-find-scanner tool

Don’t take no for an answer; try it as root:

# scanimage -L

device `hpaio:/usb/HP_LaserJet_3050?serial=00CNBK406377' is a Hewlett-Packard HP_LaserJet_3050 all-in-one

This is good news and bad news. The good news is SANE sees it. The bad news is this indicates a permissions problem, and since the advent of udev adjusting device permissions is hell itself.

Next step is find the USB address:

# sane-find-scanner

found USB scanner (vendor=0x03f0 [Hewlett-Packard], product=0x3217 [HP LaserJet 3050]) at libusb:005:002

We’re getting closer, really we are! Ordinarily at this point we would take this information, the vendor=0x03f0 and product=0x3217, and plug it into a /etc/udev/rules.d/ script. On my Lenny PC, that is /etc/udev/rules.d/z60_libsane.rules. Quit laughing, it is too. I don’t invent this stuff, I just use it.

OK then. This file is already full of rules, so all I need to do to create a new one is copy-and-paste, using the vendor and product ID for my printer. My new rule looks like this:

# Hewlett-Packard LaserJet 3050 MFP

SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="3217", MODE="0664", GROUP="scanner", ENV{libsane_matched}="yes"

Then I need to add myself to the “scanner” group, and log out and log back in to activate my shiny new group membership.

But still no scanner. A fast test is to scan a document as root and as an unprivileged user with the scanimage > filename.pnm command. This tells you if it works at all, and if you have permission problems.

Somewheres in my peeve-fueled Google searches I learned about this command from the HP Toolbox:

# hp-check -t

This spits out a lot of information, and the key bit for me was

'hpaio' not in '/etc/sane.d/dll.conf'...

SANE backend 'hpaio' is not properly set up.

Um. OK. I guess the person who crafted this message was charged by the word and ran out of budget. But it turns out it is literal– I added the word “hpaio” to /etc/sane.d/dll.conf and lo, forsooth, and boy howdy I now have a functioning scanner.

Crazy Dream

I have this crazy dream. I dream of a world where things like this do not happen because vendors take pride in their products and want customers to have good experiences. Where HP works with CUPS and SANE to create an integrated installer and device manager. Where it doesn’t take fifteen freaking years of experience to figure out how to make something that I paid for to work like it is supposed to. You know all those people who stick with commercial vendors because they get support? Ha. It is to laugh– I got nothing from HP.

At any rate the thing works now.

Get the Free Newsletter!

Subscribe to Developer Insider for top news, trends, & analysis