Apr 112013

As we have posted earlier, we own an old CanoScan LiDE 30. We are very satisfied with this scanner – but unfortunately it does not work on newer versions of Windows (e.g. Windows 7 64 bit, Windows 8) – Canon “forgot” to release updated drivers.

Raspberry Pi networked scanner sharing

A Raspberry Pi is perfect for a small, low volume server application. Today, we have put together all the pieces necessary to use it to attach the Canon scanner to our network, and scan from Windows once again.

BTW: It looks as though the Fujitsu ScanSnap 1300i might also be supported by SANE. This is the replacement scanner for the Canon flatbed scanner we bought – but it can’t scan books, for instance.

Step by step setup guide:

This guide is written for Raspbian. We have tested it with the latest Raspbian version currently available (2013-02-09).

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

# Set to the user saned should run as

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


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

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.



# [...]

Please adjust the subnet specification 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.

Now you can reboot the Raspberry Pi (sudo reboot), and continue to the set up on the Windows side.

Setting up Windows to access the SANE network scanner

We have tested with Windows 7 64 bit & Windows 8 64 bit.

Windows users use “TWAIN” drivers. Luckily, there is an application, which will create a bridge between TWAIN and SANE on the network. The author claims it does not work for 64 bit Windows, but it did work for us. Please report back in the comments about your success / failure stories on different Windows versions.

Download SaneTwain here.

SaneTwain Setup


Just enter your Raspberry Pi IP (if you do not know it, “ip addr show” will show you it’s network setup) as the hostname. Port and Username can stay the way they are. Look through the other settings, if you want to. The Mail tab, for instance, offers the possibility to set up an Evernote account you want to scan to.

Before you try to use the TWAIN driver SaneTwain offers, you should set up the hostname using the way we just described (by starting ScanImage.exe).


Now you’re set up for scanning. Use the “preview” button to acquire a preview, and the “scan” button to save the selected area to a PNG (it will be scanned with better quality, of course). The resolution can be set, also other options.

Wait until the scanner is finished with the preview and has repositioned itself, before you hit the “scan” button.


The TWAIN driver works for us, too. (Tested with IrfanView) – this is Windows 8 64 bit. No special tweaks were applied.

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.


Try XSane. Noteworthy is also gscan2pdf which will convert scanned pages to multipage PDFs, and even OCR them for you!

Of course you should be able to scan from another Raspberry Pi on your network, or even the Internet.

simple-scan is a frontend for SANE.

Further Reading & Links




We used the following how-tos in building this tutorial. Thanks, guys!

Apr 072013

For our production process (for the upcoming Raspberry Pi media centre edition in a nifty transparent red case) we need to mass-extract the Broadcom SoC’s serial numbers. Doing this manually would be a chore for 50 Raspberry Pis, so we came up with a quick & dirty solution in Ruby.

We’d like to share that with you guys – the code is released into the public domain. 

Download the script:



The script is supposed to be run on a master Raspberry Pi. You need to install some prerequisites (nmap, Ruby, Ruby gems) for it to be able to run:

aptitude install ruby
aptitude install nmap

gem install nmap-parser
gem install net-ssh

The script is written in Ruby. Other languages (e.g. Python) could be used, too, of course. I just feel really at home with Ruby. nmap is used to scan the network (you can even scan for ports, etc.). Have a look at this site for some further information about nmap usage to scan a network.

The gems are Ruby extension packages. Ruby has its own package manager “gem” which will download and setup the packages for you. nmap-parser is a wrapper and interface for nmap, net-ssh is an interface to SSH.

Unzip the script, put it into a new folder and make it executable ( chmod +x getips-v1.rb ).

Edit the script to reflect your network (line 35 – replace with the network range you want to scan), the expected amount of Raspberry Pis per batch (line 8) you will be processing.

Edit the SSH part to reflect the password setup of your Raspberry Pis (here defaulting to “pi” / “raspberry”) and what should be done on them (line 62 ff).

If you really want to, you could uncomment the “espeak” line (line 12) to enable speech output from your Raspberry as a prompt to setup the next batch, etc. I have disabled it after some experimenting – the script uses a mix of straight “puts” and “speak” (which in turn will also use puts to output to the default output) – you would need to do some more editing for this to be really consistent.


Start the script ( ./getips-v1.rb ) – it uses the shebang notation, so ruby will be called automagically to parse and execute the script.

The script will show you your master Raspberry’s serial and IP adress – it’s IP and serial will be ignored from now on (no processing done on it).

Afterwards it will enter into an infinite loop (which you can terminate by entering q or x + enter when prompted, or Ctrl + C at any point). It will scan your network for Raspberry Pis (determined by the MAC vendor – so be sure to attach your Raspberrys via their own LAN port, not WiFi – or modify it to work!). If less Pis are found than expected (default is 7), it offers you to rescan the network – allowing for additional Raspberrys to come up if they did not boot fast enough during the first scan. If you want, you can skip the rescan by entering n + enter when prompted.

After the scan, it will connect to every Raspberry in turn, login via SSH with the default password and user (pi / raspberry), get the SoC serial, halt the Raspberry and disconnect.

The serials will be written to a file which will be saved to the same directory.

The serial extraction is just a sample use, of course. You could use it to install packages, modify configuration files, and much, much more.

After having finished the tasks you requested, it will offer you to quit the script (q or x + enter) or read another batch. It will loop forever if you want to.

For more sophisticated requirements

We recommend you to look into Capistrano or similar tools for batch automation. Capistrano is also Ruby based, and uses a “DSL” to describe the automation tasks.

Feel free to contact us, if you need it custom tailored to your requirements – we charge fair rates, especially if the result can be released as open source.

Optimization WordPress Plugins & Solutions by W3 EDGE