Tuesday, October 29, 2013

primefilm 7250u scanner - fuduntu

Links: CLI scanning w/scanimage :: sane-config options :: extracting .nal from Windows driver :: deeper on the .nal

Relevant folders: 1) dev/bus/usb [device]; 2) etc/sane.d [daemon only]; 3) etc/udev/rules.d [custom rules]; 4) usr/lib/sane [backends]; 5) usr/lib/udev/rules.d [default rules]; 6) usr/share/sane


A friend recently purchased a Primefilm 7250u to scan old slides. Closed-source Windows and Mac software came with it. Difficulty: No software for Linux, not even Vue-Scan. Fuduntu has no access to repos. A kludge of interacting files, as one can see from the folders above.

The most important steps

The first two steps need to happen in order. We need to be sure, 1) the scanner is detected and, 2) the correct backend is called. For detection, /usr/lib/udev/rules.d/49-sane.rules, or (user-created) /etc/udev/rules.d/[custom].rules must contain the vendor ID. These files then call the correct backend(s).

hardware detection

Sane-find-scanner does not check the backend, it simply verifies the scanner is connected and that it's vendor ID is one of the rules files. This is hardware detection, pure and simple. Scanimage does both detection and backend pointing but, unfortunately, it will fail with the same message whether hardware detection fails or backend fails. Accordingly, even though scanimage must be working smoothly in order to use GUI frontends (eg Xsane), sane-find-scanner is very useful to troubleshoot hardware detection.
$ sane-find-scanner
...found USB scanner (vendor=0x05e3, product=0x0145) at libusb:002:009

$ 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).
Success with hardware. However, scanimage -L subsequently failed, meaning the backend is misconfigured or missing. To solve this, we have two options -- modify the rules or force scanimage to call backends (stored in /usr/lib/sane) using CLI switches.

software

Before writing a rule, we'd like to see how the kernel names the device, ie, what is the /dev device node's name? I typically use dmesg but, in my friend's system, dmesg was not supplying it. Also, his /dev folder had no "usb" folder. I located the usb folder /dev/bus/usb...
$ ls /dev/bus/usb
001 002 003 004 005 006
Opening /dev/bus/usb/002/ revealed "009". Taken together, these correlate with lsusb:
$ lsusb
Bus 002 Device 009: ID 05e3:0145 Genesys Logic, Inc.
So I had enough to go after the necessary /etc/udev/rules.d information:
# udevadm info -a -p $(udevadm info -q path -n /dev/bus/usb/002/009)

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

looking at device '/devices/pci0000:00/0000:00:12.2/usb2/2-2':
KERNEL=="2-2"
SUBSYSTEM=="usb"
DRIVER=="usb"
ATTR{bDeviceSubClass}=="ff"
ATTR{bDeviceProtocol}=="ff"
ATTR{devpath}=="2"
ATTR{idVendor}=="05e3"
[snip]

looking at parent device '/devices/pci0000:00/0000:00:12.2/usb2':
KERNELS=="usb2"
SUBSYSTEMS=="usb"
DRIVERS=="usb"
ATTRS{bDeviceSubClass}=="00"
ATTRS{bDeviceProtocol}=="00"
ATTRS{devpath}=="0"
ATTRS{idVendor}=="1d6b"
[snip]

looking at parent device '/devices/pci0000:00/0000:00:12.2':
KERNELS=="0000:00:12.2"
SUBSYSTEMS=="pci"
DRIVERS=="ehci-pci"
ATTRS{irq}=="17"
ATTRS{subsystem_vendor}=="0x1179"
[snip]

looking at parent device '/devices/pci0000:00':
KERNELS=="pci0000:00"
SUBSYSTEMS==""
DRIVERS==""

/etc/udev/rules.d

Tried this rule...
# nano /etc/udev/rules.d/10-primefilm.rules

# Custom for Primefilm scanner
KERNEL=="2-2", SUBSYSTEM=="usb", \
ATTRS{idVendor}=="05e3", ATTRS{idProduct}=="0145", \
GROUP="scanner", MODE="0664", \
ENV{libsane_matched}="yes"
This rule worked correctly, as tested with...
# udevadm test $(udevadm info -q path -n /dev/bus/usb/002/009) 2>&1
...however I continued to see scanimage -L fails. This means backend trouble -- typically complicated.

scanimage and sane-config

In /usr/lib/sane, I noted two libsanes which might work as backends, viz libsane-pie, and libsane-genesys. Sane wasn't automatically pointing to either of these, so they hadn't been used. We can make it do that with the CLI. Neither appeared to work:
$ scanimage --device=pie:/dev/bus/usb/002/009
scanimage: open of device pie failed: Invalid argument

$ scanimage --device=genesys:/dev/bus/usb/002/009
scanimage: open of device genesys failed: Invalid argument

No comments: