Network scanning and printing

From NBSWiki

Jump to: navigation, search

This document is intended to provide the steps to set up a network accessible print and scanning server under Gentoo. Presently, these steps only apply to HP printer/scanner...because that is all I have access to and they give some quite decent driver support and they use HP specific tools. Make sure you read the HPLIP README which you should be able to find in /usr/share/doc/hplip-0.9.4/hplip_readme.html

Contents

Required packages

net-print/hplip
net-print/cups
net-fs/samba

Installation documents

  1. HOWTO Install a USB scanner
  2. HOWTO: HPLIP & CUPS
  3. HOWTO Native Windows Printing with CUPS/Samba

Package installation

Note: at the moment of editing this procedure, hplip is masked.so you have to add it to /etc/portage/package.keywords
After installing hplip and sane, you must add hpaio to /etc/sane.d/dll.conf. Also make sure /etc/hp/hplip.conf is world readable.

Code: The quick copy-paste sequence ;P
# First amerge all the required packages

echo "net-print/hplip ~x86" >> /etc/portage/package.keywords
emerge net-print/hplip xsane cups -av

# Correct some missing entries in the sane configs and check some permissions (I have umask 007)

echo hpaio >> /etc/sane.d/dll.conf
chmod a+r /etc/hp/hplip.conf

# Add and start the hplip service

rc-update add hplip default
/etc/init.d/hplip start

Scanning

Getting the scanner to work

scanimage -L

The command scanimage -L, or xsane for that matter, both have to work as a normal user! This is mandatory for everything to fall into place and there shouldn't have to specifying the device in the command line (well...unless you have more than one scanner and only want to use scanimage...for button scrips for example, not covered here for the moment).

Debugging

I personnaly lost many hours because I didn't go through the "obvious" debuging path (RTFM RTFM RTFM!). In the example below, you see why scanimage -L didn't work. Turns out my pedentic umask 0007 setting caused the /etc/sane.d/dll.conf to be unreadable by world, which is necessary (easily fixed by chmod a+r /etc/sane.d/dll.conf. Here is the output before I fixed the problem:

Code: Debuging scanimage -L and xsane auto-detection
saned@kyron ~ $ export SANE_DEBUG_DLL=128 
saned@kyron ~ $ scanimage -L
[sanei_debug] Setting debug level of dll to 128.
[dll] sane_init: SANE dll backend version 1.0.11 from sane-backends 1.0.15
[dll] sane_init: Couldn't open config file (dll.conf): Permission denied
[dll] sane_get_devices
[dll] sane_get_devices: found 0 devices

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).
[dll] sane_exit: exiting
[dll] sane_exit: finished

NOTE: If you get a line that looks like this in your /var/log/messages:

scanimage: hp-option.c:3710: hp_optset_fix_geometry_options: Assertion `tl_x && tl_y && br_x && br_y' failed

It's indicative that your scanner needs to be powercycled.
You should now be able to start hp-toolbox.

Scanning Over the Network

saned configuration

The saned daemon comes with the sane-backedns package but, for some reason, the xinetd.con file and the user/groups associated to it aren't created.

References

SANE Network Daemon

Quickly
  • The user and group saned must exist:
groupadd saned; useradd -g saned saned
  • Make sure /etc/services contains a line like this (use grep sane-port /etc/services):
sane-port       6566/tcp                        # SANE Network Scanner Control Port
sane-port       6566/udp
  • Your /etc/xinetd.d/saned should contain a block like this:
File: /etc/xinetd.d/saned
service sane-port
{
    socket_type = stream
    server = /usr/local/sbin/saned
    protocol = tcp
    user = saned
    group = saned
    wait = no
    disable = no
}

And make sure your network has proper access to all xinetd daemons:

File: /etc/xinetd.conf
defaults
{
        only_from      = 192.168.1.0/24 127.0.0.1
        instances      = 60
        log_type       = SYSLOG authpriv info
        log_on_success = HOST PID
        log_on_failure = HOST
        cps            = 25 30
}

The only_from is the line of interest here.

  • Now restart xinetd and make sure saned got it's port:
Code: Restarting xinetd and checking for saned
kyron ~ # /etc/init.d/xinetd restart; netstat -tulp|grep sane
 * Stopping xinetd ...                                                          [ ok ]
 * Starting xinetd ...                                                          [ ok ]
tcp        0      0 *:sane-port             *:*                     LISTEN      596/xinetd

Make sure you get that last line. Now the last test is to telnet into the saned port. you should get the following:

Code: Telneting into saned
kyron@kyron ~ $ telnet localhost 6566
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
Connection closed by foreign host.

Press CTRL-C to exit.

Client installation

Win32

Selecting the client

There is a list of frontends on sane's web page. I WOULD HAVE preferred XSane WIN32 version over other software for many reasons. Some of them being:

  • GUI constance across platforms,
  • Simplicity
  • Flexibility
  • Completeness

... Unfortunately, it doesn't work for the moment. In short, I get "Couldnot create filenames for preview files" that pops up when I start xsane on the win32 client. It's able to scan a preview, the preview is momentarely seen in the preview window but is then replaced by the default xsane logo (the one that shows up when starting xsane). I tried debugging but get no more info from the debug trail (screenshot). Don't hesitate to contact me if you get this resolved/working!

Installing XSane (WIN32 version)

Just follow the instructions on the official XSane WIN32 version ;P I used the xsane-win32-0.96-sane-1.0.14-net-no-gimp.zip file.

Well... the win32 client doesn't work for the moment. I get "Could not create temporary file" errors and "Could not create filenames for preview" with that.... so I'll start the write-up of the Samba printing section of this server document ...and come back to this once I finish compiling the lates xsane win32 off my very slow Windows 2000 machine with Cygwin ;)

Reverting to SaneTwain

In the meantime... I decided to try out SaneTwain and it turns out quite decent, fast but obviously not as featureful as xsane (note that you should use an external program to play with graphics (obviously, Gimp comes to mind). The instructions and it's use is straight forward and I don't think any more explaining as an added value.

Printing

My intent is to make this as simple and painless as possible for the end user. This setup is _not_ intended for a corporate network or an untrusted network where anyone will abuse of the shared printers. Though some basic authentification might be simple and all, it's not my present priority,

Problems

Saned broke my scanner!

Of course Sane didn't break it but here is what happened:
Actually, here is what happened, I left SaneTwain turned on and it's connection to the saned daemon eventually timed out. After that, the scanner was completely lost and even after rebooting the scanner, the hplip drivers and xinetd many times in different ordre, my scanner wouldn't work. One of the obvious symptoms is that the display showed "Lamp worming up" and stuck there each time I tried to start a scan job. It didn't take time for me to fall upon a similar situation lived by users on the HP tech forum (click here to see the article). The unplug-plug-unplug procedure to reposition the lamp worked and my scanner was back (few!). The actual "culprit" I would say is the hplip driver...but before I start pointing fingures, I'll reproduce the problem and report it to the hplip team ;).

Assertion Failed

If you get a message that contains something like this:

Assertion `tl_x && tl_y && br_x && br_y' failed.

It might be one of the _other_ drivers conflicting with your scanner (ie: the hp driver in /etc/sane.d/dll.conf. My suggestion is that you comment or delete all drivers you won't use.

Personal tools