Sunday, September 19, 2010

Part #2 - Networking Sane

Part #2 - Installing/Configuring Saned for network scanner access.

Okay, now that I/you/the family pet can finally print through cups to your new all-in-one device; it’s time to setup and configure SANEd so everyone can scan in a document. My reasoning behind this was in the past, we had to unplug the all-in-one from one desktop, drag the laptop in the computer room, plug the scanner in, scan the documents, unplug the scanner (and if we remembered to) plug it back into the desktop. What a royal PITA to do every time we wanted to scan a document in, and even more of a PITA when your attempting to print off a document from the desktop, only to realize that the last person who used the printer forgot to plug it back into the desktop! *cough* you know who you are! *cough*.

In part 1 I talked about installing the necessary packages for sane and the hplip drivers. If you haven’t already done this, please for the love of everything holy, do this now.

Before we start getting into saned configuration, the first thing you need to do is make sure that your new fancy schmancy all-in-one works with the scanner. Now according to http://www.openprinting.org/printers my HP Deskjet all-in-one F4480 is considered a ‘paperweight’. I don’t know their reasoning behind this, and maybe their database needs to be updated. But I do know that both cups and saned support this device with the hplip driver’s. So at some point, I’ll have to update this. And the Sane page for supported devices: http://www.sane-project.org/sane-mfgs.html#SCANNERS Doesn’t even show the all-in-one. But alas, once again this does work, I promise you. To see a list of supported devices with the HPLIP device driver, go here: http://hplipopensource.com/hplip-web/supported_devices/index.html

If HPlip website says Scanning/Printing/WorldDomination is supported, then you are good to go.

From the commandline type: scanimage -L
If your scanner shows up (and it should with the hplip driver support) then you can use this device with saned. For instance with my HP F4480 I get the following result:

device `hpaio:/usb/Deskjet_F4400_series?serial=CN07DC404ZXXXX' is a Hewlett-Packard Deskjet_F4400_series all-in-one

So, now that we know that scanimage can see your scanner, time to make the necessary changes. Once again, I am doing this from an Ubuntu 10.04LTS distro, so you might have to change stuff for the distribution that you are using.

First things first, changed your inetd.conf file to allow saned access.
1. vim /etc/inetd.conf
2. add the following information: sane-port stream tcp nowait saned.saned /usr/sbin/saned saned

This will allow inetd to push the saned port through and startup the saned services. Next, make sure that the tcp port is setup properly in /etc/services
1. vim /etc/services
2. search for: sane-port
3. Should look like this: sane-port 6566/tcp sane saned # SANE network scanner daemon

Okay, now that the hard stuff is out of the way, time to setup the saned.conf file. It’s actually quite straightforward and I really only have 2 lines (for security reasons) inside of my saned.conf file
1. vim /etc/sane.d/saned.conf
2. Add the following (mileage may vary depending on your internal network)
1. data_portrange = 10000 - 10100
2. 192.168.1.0/24
As you can see, I used a CIDR network mask for my network. You can add specific ip addresses, CIDR subnets, or even ipv6.

Now save saned.conf and restart inetd
1. pkill inetd && inetd

telnet to tcp port 6566 from the server, you should get the following:
1. telnet localhost 6566
root@dino:/etc/init.d# telnet localhost 6566
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
2. If you can connect to localhost, then saned is properly setup and listening on tcp port 6566.

When I first set this up, I had issues with saned and networking. These were my steps to debugging the saned interface.
1. Stop inetd (pkill inetd)
2. start saned in debug mode: /etc/init.d/saned -d255
3. This kicks off a high-level debug to the console. From here (once you have setup the sane client..more on that in a minute) you can scan a document remotely and see the debug output. Once you are done debugging, don’t forget to restart inetd.

Okay, so it’s safe to assume that saned is now listening on port 6566. Time to do some network scanning!

Remote scanning from a linux client
1. Make sure you actually have xsane installed (get it from the repo’s)
a. apt-get install xsane xsane-common
2. Setup the sane client for network scanning
a. vim /etc/sane.d/net.conf
b. add the ip address of the saned server
c. Save and quit the file
3. Put a document in the scanner, fire up xsane from the client and see if it scans!
a. xscane will check the net.conf file and attempt to connect to the server, if it makes a valid connection, you will see the device name in the title page of xsane. From here just select scan and you should see your document loaded up on the scanner. If you are having problems, check above on how I documented starting saned in debug mode.

Remote scanning from a windows client
1. Get the sanetwain package from http://sanetwain.ozuzo.net/
2. Unzip the package and execute: ScanImage.exe
3. Click the little wrench and screwdriver icon up at the top
4. Add the ip address of the saned server and port 6566 (if you set user access, now is the time to put the user name in)
5. Either click ‘scan image’ to start scanning, or close out ScanImage.exe and open it up again...by closing out and re-opening the application, it appears that it goes out to the server and adds the remote scanning device (had to do this on windows 7, tricky bugger). Tada! you should be able to remotely scan from windows now. As i said earlier, if this doesn’t work, run saned in debug mode.

There you have it, Network scanning with sane on both linux and windows clients.

My last and final part on this blog will be on getting SAMBA, CUPS and Windows driver’s happy. As this is a royal PITA to do, muchless remember how I did this 3 days ago; I’ll probably post this final update this week.

1 comment: