Raspberry Pi as remote print and scan server for SCX-4200

I am a happy owner of a Samsung SCX-4200 printer/scanner combo. It’s already pretty old but serves me well and I’m not going to replace it only because of its age.
However useful it is for me, I have no place on my desk for it. It’s simply too big. So I’ve put in the corner of my room with other stuff. The downside was wherever I wanted to print or scan something, I had to take my laptop there to connect it via USB cable. Enough is enough, let’s make the Raspberry Pi useful 😉

Printer

When I have bought it, SCX-4200 came with Linux drivers. They were never state-of-the-art but were working. Later on Samsung’ve screwed things with permissions and from that moment it went worse and worse till finally the official driver has been discontinued. After initial chaos the community took over and provided necessary drivers and installing the thing became easy as pie.

If you haven’t used any printers on your Pi you probably don’t have CUPS installed. Let’s fix it:

$ sudo aptitude install cups

It’ll pull a lot of dependencies. Between the others sane-utils will be installed which we’ll use in the scanner section.
Now, I’m aware that one may configure CUPS from the command line but I prefer to take the fastest route. Maybe if I already knew what and where… But I don’t, so I resort to the lame GUI. Since my Raspberry Pi is running headless, I had to enable remote administration:

$ sudo cupsctl --remote-admin
$ sudo service cups restart

Now you can open http://eir:631/admin in your browser. Depending on your configuration the host name will vary or it will be an IP address. I assume you know how to talk to your Pi. One thing to note – you have to have appropriate rights to add a printer. I didn’t really investigate it but the easiest way is to set a password for root user and use it to login to CUPS interface when prompted.
Click Add printer and you’ll be presented a screen like this (again, sorry for Polish localization): CUPS Add Printer page Your device should be among Local printers (note, that I have sometimes double entries on the screenshots because I have already set it up once (on anther Pi device – eir is more a toy / experimental playground)).
CUPS Printer name, location and sharing On this page the only really important thing is the tick next to Share this printer. Rest is just a description really.
CUPS choose printer driver The last but very important step – choose the correct driver (I have highlighted it just in case 😉 ). Before splix took it over one had to extract the PPD file from the original driver and put it here. And even then it sometimes didn’t work. Thankfully it’s all over now. Anyway, click Add printer and you’re done.

Add remote printer

There are probably various ways of doing this. I’m going to use the MATE’s build-in method. Again because it’s the fastest one. The manager is hidden in System->Administration menu.

Example printer manager windows As said before, I’ve configured it once on my other device. Depending on your setup, you may have more printers displayed or none. Just click the + sign.
CUPS find network printer
On the left side pick find network printer and put your Pi name / IP in the search field. Click find and you should be presented a similar screen:CUPS find network printer Just click Next. A quick look into a manager’s windows confirms that we have succeeded: CUPS another printer added All that’s left is to print a test page 🙂

Scanner

I’m really pleased how easy it was this time. Normally I’ve struggled with this damn scanner for few hours. This doesn’t mean that everything is straight-forward though.

First let’s check if the scanner is visible at all. My pi is not in the scanner group and I don’t need it to be. The most important thing is that saned user have access to it:

$ sudo -u saned scanimage -L
device `xerox_mfp:libusb:001:005' is a SAMSUNG ORION multi-function peripheral

Success? You wish! Second attempt reveals a surprise.

$ sudo -u saned 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 (if appropriate). Please read the documentation
which came with this software (README, FAQ, manpages).
$ 

Originally I have set it up on my old Pi and after some time it stopped working. For a long time I didn’t feel like spending too much time investigating. That is until I end up bringing my laptop to the scanner few times a day… Anyway, I have found a bug on launchpad – not very specific but with enough information for me to start. I have checked commits on ‘GitHub’ in the suspected timeframe hoping that I’ll know when I find a clue. Finally found this: https://github.com/raspberrypi/firmware/commit/b7ac7cb62a5a471f280b488c1b9d693cbb9d4e83 quick search on the Internet revealed many problems with usblp and many recommendations to blacklist it. So let’s try:

$ lsmod
Module                  Size  Used by
usblp                  12313  0 
snd_bcm2835            21342  0 
snd_pcm                93100  1 snd_bcm2835
snd_seq                61097  0 
snd_seq_device          7209  1 snd_seq
snd_timer              23007  2 snd_pcm,snd_seq
snd                    67211  5 snd_bcm2835,snd_timer,snd_pcm,snd_seq,snd_seq_device
uio_pdrv_genirq         3666  0 
uio                     9897  1 uio_pdrv_genirq

$ sudo rmmod usblp
$ sudo scanimage -L
device `xerox_mfp:libusb:001:005' is a SAMSUNG ORION multi-function peripheral
$ sudo scanimage -L
device `xerox_mfp:libusb:001:005' is a SAMSUNG ORION multi-function peripheral
$

Now you're talking! Let's blacklist it once and for all:

$ sudo echo 'blacklist usblp' >> /etc/modprobe.d/raspi-blacklist.conf

Enable remote operation

First of all we have to let the SANE daemon start. Edit /etc/default/saned so it looks like below. Most probably you’ll have to change the value of RUN option.

cat /etc/default/saned
# 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

Then allow remote hosts to access exported devices by editing /etc/sane.d/saned.conf. Only the Access list section is interesting. In the example I have allowed entire 192.168.125.0 subnetwork to scan:

## Access list
# A list of host names, IP addresses or IP subnets (CIDR notation) that
# are permitted to use local SANE devices. IPv6 addresses must be enclosed
# in brackets, and should always be specified in their compressed form.
#
# The hostname matching is not case-sensitive.

#scan-client.somedomain.firm
#192.168.0.1
192.168.125.0/24
#[2001:7a8:185e::42:12]
#[2001:7a8:185e::42:12]/64

Client setup

This for one is extremely easy. Just edit /etc/sane.d/net.conf (in Gentoo) and add your Raspberry Pi DNS name or IP address in the saned hosts section like below (eir is the name of the Pi I have set up scanner on):

cat /etc/sane.d/net.conf
# This is the net backend config file.

## net backend options
# Timeout for the initial connection to saned. This will prevent the backend
# from blocking for several minutes trying to connect to an unresponsive
# saned host (network outage, host down, ...). Value in seconds.
# connect_timeout = 60

## saned hosts
# Each line names a host to attach to.
# If you list "localhost" then your backends can be accessed either
# directly or through the net backend.  Going through the net backend
# may be necessary to access devices that need special privileges.
# localhost

eir

That’s it! If you haven’t already done so, install Xsane and enjoy:
Xsane choose scanner device

Finishing touch

You probably want your devices to be available after your Raspberry Pi has rebooted. Just make sure they will be started at boot:

$ sudo update-rc.d cups enable
update-rc.d: using dependency based boot sequencing
$ sudo update-rc.d saned enable
update-rc.d: using dependency based boot sequencing
$ 
Advertisements

5 thoughts on “Raspberry Pi as remote print and scan server for SCX-4200

  1. hi!
    I’am just trying to achieve the same configuration and I am glad you succeeded .
    because I’m currently stuck.

    My problem is that cups doesn’t have the proper driver installed and I cant figure out how to update the list or find the proper ppd file for the scx4200.

    Can you help me ?

    thx.

    Like

    • Hi.

      Thanks for showing by.

      I do mention it in the post but I agree that nobody will understand that part unless he already knew it…
      What you’ll looking for is splix. On Rapberry Pi (and probably other Debian-ish distros) the package you need to install is printer-driver-splix.

      Hope that helps.
      Cheers.

      Like

  2. Hi, I’m currently trying to get the older SCX-4100 to work and have successfully followed your instructions and have installed the printer. However although the device shows up via lsusb and was selectable on the cups config menu, sane-find-scanner doesn’t find it and neither does scanimage -L. I’m using the latest raspbian jessie which is the hard float and from what I’m reading Samsung only provided the drivers for the armel/soft float version. Therefore is your pi running the older soft float version of raspbian? If not any ideas why the scanner isn’t being picked up? Cheers Rob

    Like

      • No problem, I managed to get a HP all in one from ebay for 99p. HP appear to compile the drivers for arm so have managed to get it working. Although for some reason the flatbed scans fine but the ADF appears to add some rows to the page which produces a corrupt image file. Running it through pamfixtrunc or setting the page height to be a few mm shorter appears to be workarounds for this. Cheers anyway.

        Like

Leave a comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s