Get the required packages:
sudo su aptitude update aptitude install xinetd sane-utils
xinetd is the Internet superdaemon which will start saned, the “Scanner Easy Access Now” daemon when a network connection to it’s port is opened (saned can’t do that on it’s own).
sane-utils contains the saned. (On Archlinux the package is called simply “sane”)
Raspbian automatically sets up the group saned and the user saned for you. It also adds the user saned to the group scanner.
Configure /etc/default/saned so it will start automatically (RUN=yes):
# Defaults for the saned initscript, from sane-utils # Set to yes to start saned RUN=yes # Set to the user saned should run as RUN_AS_USER=saned
Start saned, and test whether the scanner is recognized. Ideally you should do this as user saned, to see if all access rights for saned are setup correctly. Your scanner should naturally be attached to the Raspberry Pi. If it draws its power through USB, we recommend to use a powered USB hub.
root@raspberrypi:/home/pi# /etc/init.d/saned start root@raspberrypi:/home/pi# su -s /bin/sh - saned No directory, logging in with HOME=/ $ lsusb Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. Bus 001 Device 004: ID 05e3:0608 Genesys Logic, Inc. USB-2.0 4-Port HUB Bus 001 Device 008: ID 04a9:220e Canon, Inc. CanoScan N1240U/LiDE 30 Bus 001 Device 007: ID 093a:2510 Pixart Imaging, Inc. Optical Mouse Bus 001 Device 006: ID 046d:c31c Logitech, Inc. Keyboard K120 for Business $ scanimage -L device `plustek:libusb:001:008' is a Canon CanoScan N1240U/LiDE30 flatbed scanner $ exit root@raspberrypi:/home/pi#
I have included the # and $ prompt in this listing, so you can distinguish between commands the root user (#) issues and the saned user issues ($)
If you see your scanner here, great. If not – have a look at the documentation and further reading links we will provide at the end of this article.
The USB scanner itself is plug & play – you can attach it to the Raspberry Pi when you feel like scanning, and remove it after you have finished.
Prepare network sharing of the scanner
root@raspberrypi:/etc/xinetd.d# cat /etc/services | grep sane sane-port 6566/tcp sane saned # SANE network scanner daemon
You should see the sane-port line as in the listing. If it is not in there, add it.
root@raspberrypi:/# cd /etc/xinetd.d root@raspberrypi:/etc/xinetd.d# touch sane-daemon root@raspberrypi:/etc/xinetd.d# which saned /usr/sbin/saned root@raspberrypi:/etc/xinetd.d# nano sane-daemon
This will set up the XInet configuration. Please use the following configuration for the /etc/xinetd.d/sane-daemon file:
service sane-port { socket_type = stream server = /usr/sbin/saned protocol = tcp user = saned group = saned wait = no disable = no }
Note that we used the output from “which saned” in the configuration above. If it is different for you – e.g. on Archlinux – adjust accordingly.
Set up saned to accept connections from your network by editing /etc/sane.d/saned.conf:
# saned.conf # Configuration for the saned daemon ## Daemon options # [...] # data_portrange = 10000 - 10100 ## Access list # [...] # The hostname matching is not case-sensitive. #scan-client.somedomain.firm 192.168.1.0/24 #192.168.0.1 #192.168.0.1/29 #[2001:7a8:185e::42:12] #[2001:7a8:185e::42:12]/64 # [...]
Please adjust the subnet specification 192.168.1.0/24 to your network architecture. You can also explicitly specify single IPs. If you do not edit this file, SaneTwain will hang when contacting your Raspberry Pi scanner server.
Setting up Linux to scan from the network scanner
If you have a Linux box, you can use basically any SANE Frontend to scan using the network.
You need to add the network scanner to a local SANE installation.
Edit /etc/sane.d/net.conf and add the IP of your server. You can specify multiple servers.
Test with scanimage –L once again, and after a while you will see your network scanner showing up.