Difference between revisions of "SANE"

From ArchWiki
Jump to navigation Jump to search
Line 20: Line 20:
  
 
=== For HP hardware ===
 
=== For HP hardware ===
For HP hardware you may also need to install the {{Ic|hplip}} package which is in the {{Ic|extra}} repository:
+
For HP hardware you may also need to install the {{Ic|hplip}} package and/or {{Ic|hpoj}} which is in the {{Ic|extra}} repository:
  # pacman -S hplip
+
  pacman -S hplip hpoj
  
* Don't forget to uncomment {{Ic|hpaio}} in {{ic|/etc/sane.d/dll.conf}}.
+
* Don't forget to uncomment/add {{Ic|hpaio}} and {{Ic|hpoj}} to a new line in {{ic|/etc/sane.d/dll.conf}}.
 
* Running {{Ic|hp-setup}} as root may help you add your device.
 
* Running {{Ic|hp-setup}} as root may help you add your device.
 
* {{Ic|hp-plugin}} is the 'HPLIP Plugin Download and Install Utility'.
 
* {{Ic|hp-plugin}} is the 'HPLIP Plugin Download and Install Utility'.
 
* {{Ic|hp-scan}} is the 'HPLIP Scan Utility'.
 
* {{Ic|hp-scan}} is the 'HPLIP Scan Utility'.
 +
For Hewlett-Packard OfficeJet, PSC, LaserJet, and PhotoSmart printer multi-function peripherals, run ptal-init setup as root and follow instructions:
 +
ptal-init setup
  
 
=== For Brother hardware ===
 
=== For Brother hardware ===

Revision as of 23:23, 23 September 2012

zh-CN:Sane Sane provides a library and a command-line tool to use scanners under GNU/Linux. Here you can check if sane supports your scanner.

Installation

sane is available in the [extra] repository so:

# pacman -S sane

Configuration

Users that need to use a scanner should be part of the group scanner. Use gpasswd to add a user to a group:

# gpasswd -a username scanner
Note: You need to logout/login for this to take effect.

Now you can try to see if sane recognizes your scanner

$ scanimage -L

If that fails, check that your scanner is plugged into the computer. You also might have to unplug/plug your scanner for /etc/udev/rules.d/sane.rules to recognize your scanner.

For HP hardware

For HP hardware you may also need to install the hplip package and/or hpoj which is in the extra repository:

pacman -S hplip hpoj
  • Don't forget to uncomment/add hpaio and hpoj to a new line in /etc/sane.d/dll.conf.
  • Running hp-setup as root may help you add your device.
  • hp-plugin is the 'HPLIP Plugin Download and Install Utility'.
  • hp-scan is the 'HPLIP Scan Utility'.

For Hewlett-Packard OfficeJet, PSC, LaserJet, and PhotoSmart printer multi-function peripherals, run ptal-init setup as root and follow instructions:

ptal-init setup

For Brother hardware

In order to install a Brother Scanner or Printer/Scanner Combo you need the right driver (which can be found in the AUR). There are only four drivers to choose from (brscan1-4). In order to find the right one you should search for your model at the brother linux scanner page.

After you installed the driver you need to run

# /usr/local/Brother/sane/setupSaneScan1 -i

so the drivers/scanner are recognized by sane.

For network scanners, Brother provides a configuration tool:

# brsaneconfig2 -a name=<ScannerName> model=<ScannerModel> ip=<ScannerIP>

Example:

# brsaneconfig2 -a name=SCANNER_DCP770CW model=DCP-770CW ip=192.168.0.110

For Epson hardware

For Wi-Fi and/or network scanners, you can use "Image Scan! for Linux".

Install iscanAUR and iscan-plugin-networkAUR from the AUR, then update /etc/sane.d/epkowa.conf and add the line:

net {IP_OF_SCANNER}

Firmware

Note: This section is only needed if you need to upload firmware to your scanner.

Get the firmware

Note: If you do not have an install CD, you might find the required software on the scanner manufacturer's website.

Firmwares usually have the .bin extension.

But it may also be in:

  • a .exe file; in this case maybe it is just a zip archive, install and run unzip to find out.
  • a .cab file; install and run cabextract to extract it.

Install the firmware

Firstly you need to put the firmware someplace safe, it is recommended to put it in a subdirectory of /usr/share/sane.

Then you need to tell sane where the firmware is:

  • Find the name of the backend for your scanner from the sane supported devices list.
  • Open the file /etc/sane.d/<backend-name>.conf.
  • Make sure the firmware entry is uncommented and let the file-path point to where you put the firmware file for your scanner. Be sure that members of the group scanner can access the /etc/sane.d/<backend-name>.conf file.

If the backend of your scanner is not part of the sane package (such as hpaio.conf which is part of hplip), you need to uncomment the relevant entry in /etc/sane.d/dll.d/hplip.

Install some frontend(s)

XSane provides a GTK-based frontend to Sane. It is available in the extra repository.

# pacman -S xsane

Hint: Xsane can save directly to pdf file format. This works only in 8bit colour depth mode! (16bit mode produces corrupted files)

Other frontends exist, to find them you can:

  • use pacman -Ss to search for keywords such as "sane" or "scanner"
  • see the list of frontends on the sane-project website

xsane has an OCR(Optical character recognition) function. To use it, you need to install "gocr".

# pacman -S gocr

Troubleshooting

Invalid argument

If you get an "Invalid argument" error with xsane or another sane front-end, this could be caused by one of the following reasons:

Missing firmware file

No firmware file was provided for the used scanner (see above for details).

Wrong firmware file permissions

The permissions for the used firmware file are wrong. Correct them using

# chown root:scanner /usr/share/sane/SCANNER_MODEL/FIRMWARE_FILE
# chmod ug+r /usr/share/sane/SCANNER_MODEL/FIRMWARE_FILE

Multiple backends claim scanner

It may happen, that multiple backends support (or pretend to support) your scanner, and sane chooses one that doesn't do after all (the scanner won't be displayed by scanimage -L then). This has happend with older Epson scanners and the epson2 resp. epson backends. In this case, the solution is to comment out the unwanted backend in /etc/sane.d/dll.conf. In the Epson case, that would be to change

 epson2
 #epson

to

 #epson2
 epson

Permission problem

If you see your scanner only when doing sudo lsusb you might get it working by adding your user to scanner and/or lp group.

# gpasswd -a username scanner
# gpasswd -a username lp

This is reported to work on HP all-in-one models (e.g., PSC 1315 and PSC 2355).

Also you could try to change permission of usb device but this is not recommended, a better solution is to fix the Udev rules so that your scanner is recognized.

Example:

First, switch to root and check connected usb devices with command 'lsusb'

#[root@archlinux ~]# lsusb 
#Bus 006 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
#Bus 005 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
#Bus 004 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
#Bus 003 Device 003: ID 04d9:1603 Holtek Semiconductor, Inc. 
#Bus 003 Device 002: ID 04fc:0538 Sunplus Technology Co., Ltd 
#Bus 003 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
#Bus 002 Device 001: ID 1d6b:0001 Linux Foundation 1.1 root hub
#Bus 001 Device 006: ID 03f0:2504 Hewlett-Packard 
#Bus 001 Device 002: ID 046d:0802 Logitech, Inc. Webcam C200
#Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
#[root@archlinux ~]# 

In our example we see scanner - 'Bus 001 Device 006: ID 03f0:2504 Hewlett-Packard'

Now edit the file vi /lib/udev/rules.d/53-sane.rules and look for the first part of the ID number found previously and check if there is a line that also reports the second part of the number (model numer), in this example 2504. If not found change or copy a line and enter the idVendor and idProduct of your scanner, in this example it would be:

# Hewlett-Packard ScanJet 4100C
ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="2504", MODE="0664", GROUP="scanner",
  ENV{libsane_matched}="yes"

Save the file, plug out and back in your scanner and the file permissions should be now correct.


Another tip, is that you can add your device (scanner) in backend file:

In example we add string 'usb 0x03f0 0x2504' to file '/etc/sane.d/hp4200.conf'

Now file looks like this:

#[root@archlinux ~]# cat /etc/sane.d/hp4200.conf
#
# Configuration file for the hp4200 backend
#
#
# HP4200
#usb 0x03f0 0x0105
usb 0x03f0 0x2504
[root@archlinux ~]#

DBus problem

If you get following problem:

arguments to dbus_connection_send() were incorrect, assertion "connection != NULL" failed in file dbus-connection.c

Make sure the dbus user is in the groups lp and scanner:

$ groups dbus
dbus
# gpasswd -a dbus lp
# gpasswd -a dbus scanner

(Note that dbus must be stopped and started for the group changes take effect.)

Make sure the system dbus is running:

$ rc.d list dbus
[STARTED][AUTO] dbus

If it isn't, start it with:

# rc.d start dbus

A session dbus alone seems to be insufficient for scanner operation.

Slow startup

If you encounter slow startup issue (e.g. xsane or scanimage -L take a lot to find scanner) it may be that more than one driver supporting it is available.

Have a look at /etc/sane.d/dll.conf and try commenting out one (e.g. you may have epson, epson2 and epkowa enabled at the same time, try leaving only epson or epkowa uncommented)