Scanning
Scanning also works remotely, but requires a bit more tinkering to get working.
Server Configuration
To get started, log back in to the Pi with SSH and install SANE:
sudo apt-get update sudo apt-get install sane sane-utils dbus
SANE comes with a few useful tools for checking configuration. First, see if SANE can find your scanner:
sudo sane-find-scanner
You should get some output like this:
pi@print-server ~ $ sudo sane-find-scanner # sane-find-scanner will now attempt to detect your scanner. If the # result is different from what you expected, first make sure your # scanner is powered up and properly connected to your computer. # No SCSI scanners found. If you expected something different, make sure that # you have loaded a kernel SCSI driver for your SCSI adapter. # Also you need support for SCSI Generic (sg) in your operating system. # If using Linux, try "modprobe sg". found USB scanner (vendor=0x03f0 [HP], product=0xa011 [Deskjet 3050A J611 series]) at libusb:001:005 found USB scanner (vendor=0x0bda [Manufacturer Realtek ], product=0x8172 [RTL8191S WLAN Adapter ]) at libusb:001:004 found USB scanner (vendor=0x0424, product=0xec00) at libusb:001:003 # Your USB scanner was (probably) detected. It may or may not be supported by # SANE. Try scanimage -L and read the backend's manpage. # Not checking for parallel port scanners. # Most Scanners connected to the parallel port or other proprietary ports # can't be detected by this program.
If the program returns information about your make and model like above, you’re good to go.
Next, try the following:
sudo scanimage -L
You should get output like this:
device `hpaio:/usb/Deskjet_3050A_J611_series?serial=CN1C3438F005PJ' is a Hewlett-Packard Deskjet_3050A_J611_series all-in-one
Finally, try scanning something. Put something inside the scanner enter this command:
scanimage > ~/test-scan-file.pnm
You can see details about the file using this command:
file ~/test-scan-file.pnm
If you would like to fetch the file via SSH and inspect it on your laptop, you can use the secure copy command (run this from a terminal on your laptop):
scp pi@print-server:~/test-scan-file.pnm ~/test-scan-file.pnm
(…where print-server is the hostname of the print server, Alternatively, you can use the IP address of the Pi, e.g. 192.168.1.151).
Once the transfer is complete, you can open the file from your home directory with a program like GIMP.
Now we know that the scanner is working locally, we can set up the sane daemon. Open the configuration file /etc/default/saned
and set this option to turn the sane daemon/server on:
RUN=yes
Next, open the file /etc/sane.d/saned.conf
and add this line, which tells the server to accept connections from all IP addresses in the range 192.168.1.1 to 192.168.1.255:
192.168.1.0/24
The above assumes that your router’s IP address is 192.168.1.1 – if it is 192.168.0.1 then change the line to 192.168.0.0/24
.
Also uncomment this line:
data_portrange = 10000 - 10100
We also need to fix the permissions so that the sane daemon can access the scanner without root. Part of the output from sane-find-scanner
was the following line:
found USB scanner (vendor=0x03f0 [HP], product=0xa011 [Deskjet 3050A J611 series]) at libusb:001:005
The section „at libusb:001:005“ at the end tells us that the scanner is located at /dev/bus/usb/001/005
. Let’s check who owns that file:
pi@print-server ~ $ ls -l /dev/bus/usb/001 total 0 crw-rw-r-T 1 root root 189, 0 Jul 6 19:44 001 crw-rw-r-T 1 root root 189, 1 Jan 1 1970 002 crw-rw-r-T 1 root root 189, 2 Jan 1 1970 003 crw-rw-r-T 1 root root 189, 3 Jul 6 19:44 004 crw-rw-r-T 1 root lp 189, 4 Jul 6 19:49 005
As you can see, it is owned by root with the group lp (linux printing). We need to add the sane daemon to the lp group to give it the necessary permissions:
sudo adduser saned lp
Now restart the SANE daemon to make all of the changes take effect. On Debian Wheezy and before, the command is:
sudo service saned restart
On Jessie and later (i.e. systems with systemd), use:
sudo systemctl start saned.socket
And tell the SANE service to start automatically when the Pi starts. On Wheezy:
sudo update-rc.d saned defaults
Or on Jessie:
sudo systemctl enable saned.socket
Now check SANE is running properly:
sudo service saned status