LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (http://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Scanner has stopped working - Xsane reports 'no devices found' (http://www.linuxquestions.org/questions/linux-hardware-18/scanner-has-stopped-working-xsane-reports-no-devices-found-928927/)

gonesouthwest 02-12-2012 05:16 AM

Scanner has stopped working - Xsane reports 'no devices found'
 
This issue is similar to several previous threads, which did not have a solution for me.

I'm using Debian Squeeze, kept bang up to date with patches. I have two scanners, my original Canon N670U, and a later Epson SX425W, either of which can be connected to a USB port.

The Canon worked reliably for several years with XSane. Then I replaced it when I changed my printer for the Epson 'all in one' printer/scanner. That prints and for a while also scanned with XSane. However a few days ago I found Xsane wouldn't recognise it, with the "no devices found" message. So I swapped it out with the original, previously reliable, Canon, and now I get the same message!

When the Canon is plugged in, dmesg shows:

[ 3298.312069] usb 6-1: new full speed USB device using uhci_hcd and address 7
[ 3298.487725] usb 6-1: New USB device found, idVendor=04a9, idProduct=220d
[ 3298.487732] usb 6-1: New USB device strings: Mfr=64, Product=77, SerialNumber=0
[ 3298.487736] usb 6-1: Product: CanoScan
[ 3298.487739] usb 6-1: Manufacturer: Canon
[ 3298.487976] usb 6-1: configuration #1 chosen from 1 choice

/etc/sane.d/plustek.conf has the following (abridged):

[usb]
device auto

Result from "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)......

Result from "sane-find-scanner":

found USB scanner (vendor=0x04a9, product=0x220d, chip=LM983x?) at libusb:006:007

I've changed /etc/sane.d/plustek.conf to

[usb] 0x04a9 0x220d
device libusb:006:007

as suggested in the comment, with no improvement. I've also changed USB ports, changed to an old USB1.1 port. None of this makes any difference.

The experience is no different when run as root.

I am currently using kernel "Linux debian 2.6.32-5-686 #1 SMP Mon Jan 16 16:04:25 UTC 2012 i686 GNU/Linux"

One thing I have noticed is that /proc/bus/usb has no entries (I was looking for /proc/bus/usb/006/007).

Can anyone help me through this problem?

frankbell 02-12-2012 09:10 PM

I see you tested the ports and the machine is seeing the scanner, which were my two first thoughts. Have you swapped out the cable?

I would suggest booting to a Live CD of something and seeing whether you can use the scanner. If you can, that would narrow it to your software load. If you can't, it's likely a hardware problem of some sort.

hpfeil 02-16-2012 10:05 AM

(There have been lots of similar problems reported elsewhere [https://duckduckgo.com]. This could be a rough draft for a tutorial.)
The usual suspects, `sane-find-scanner -q` and `scanimage -L` produce the correct results for root, but not for anyone else. Usbfs, which used to be mounted in /proc/bus/usb, is now deprecated; hotplug is deprecated, devfs is deprecated; HAL is deprecated. The kernel developers have been migrating to udev for device detection and initialization for nearly a decade. Udev now populates /dev, which is mounted as filetype tempfs during startup and vanishes upon power-off. Things that used to be in procfs are now in sysfs, which is mounted as /sys and populated by udev. Udev rules are in /lib/udev/rules.d and /etc/udev/rules.d. Scanner manufacturers send their scanner <mfg>.desc description files to the sane folks, who add those descriptions the sane db, then scripts which run as part of the makefile/compile process, like tools/sane-desc, reference those <mfg>.desc files to populate /etc/sane.d with <backend>.conf files and create /lib/udev/rules.d/xx-libsane.rules.
Although it may seem that somewhere along the way things kind of went haywire, once the migration to udev and dracut is complete, such matters will be a lot easier to manage.

I'll use my HP Scanjet 5307C as an example, hoping that someone will write a script that does all this setup automagically.
I looked in /etc/sane.d, but found no custom conf file dedicated to that model. I eventually discovered that the avision backend includes my scanner, with no configuration options needed, that is, leave all the lines in avision.conf commented out.
The default rule for the Avision back-end (most HP flatbed scanners) creates the device links either during startup or when the scanner is turned on and/or the usb cable is plugged into a usb port.
First invoke `lsusb` to get the bus and id assignments: "Bus 002 Device 002: ID 03f0:0701 Hewlett-Packard ScanJet 5300c/5370c" for my scanner. When I invoked `ls -l /dev/bus/usb/002/002`, I discovered that root:root owned it with mode 0664 permissions, which explains the fact that when logged in as root, `scanimage -L` finds the scanner, but not using my user account.
While getting lost among the recursive loops in /sys, I learned that `udevadm info` is your friend.
There is probably a more elegant way to do this, but I dumped the entire udev dabase into a pipe, then grepped the device ID using the `less` command :/3f0.
`udevadm info --export-db | less`
Copy/paste everything from the parent node {P:} to the last environment attribute {E:}, I had everything needed for the next step.
If you create a file in /etc/udev/rules.d with the same name as the scanner rules file in /lib/udev/rules.d, the one in /etc/udev takes precedence. I copied 65-libsane.rules from /lib/udev to /etc/udev, opened /etc/udev/rules.d/65-libsane.rules in a convenient text editor, deleted the entries for other usb and all the scsi devices, uncommented the ENV line because the distribution /boot/config file had commented out the usb device class (#CONFIG_USB_DEVICE_CLASS=n), then created a rule to let me scan.

The extracted udev database entry for my libusb:002:002 device contains attribue-value pairs. I added a line above the libsane_matched rule using idVendor and ifProduct:

ATTRS{manufacturer}=="Hewlett Packard", ATTRS{product}=="Hewlett Packard ScanJet 5300C/5370C ", OWNER="root", GROUP="scanner"

Now all I had to do was create a group named "scanner" and add my user name to that group. I rebooted, (there's a more elegant way to update udev's rules.d) and started scanning, from the command line, then xsane and gimp.
If you are brave of heart, you might proceed as outlined, or just wait for an update that includes a udev rule that changes the scanner group from root. Meanwhile, you can `chmod o+w` the /dev/bus/usb entry for your scanner every startup.

gonesouthwest 02-17-2012 06:40 AM

Thanks for that, but:

>>I discovered that root:root owned it with mode 0664 permissions, which explains the fact that when logged in as root, `scanimage -L` finds the scanner, but not using my user account.

For me the experience is no different when run as root, so it doesn't look like a simple permissions issue.

hpfeil 02-26-2012 11:10 AM

Forget sane for a bit. Does the output from `lsusb` match dmesg? Can you find the /dev/bus/usb/006/001 file? If udev doesn't add it to devfs, nothing will work. BTW, mounting usbfs in /proc is deprecated. Everything is now in sysfs mounted under /sys, which is populated by udev. That's why you need udevadm to find it, not /proc/bus/usb. Once you get the attributes from /sys, then you can add a new rule under /etc/udev/rules.d. Poke around /lib/systemd/system using `systemctl` to make sure your uhci driver is loaded into ram.

There's a lot of obsolete info that will turn up in search engines. As soon as you get up to speed so you don't have to read the manual, they change everything so you have to start over. Sysadmin job security. (Check out dice.com, there's a strong demand for linux sysadmins, programmers and all.)

hpfeil 11-28-2012 12:05 PM

The information I posted works for systems that do not use systemd. Ever since systemd took over, my scanner no longer works. I had to hack the cupsd service to get my network printer working, since systemd sits there and waits for someone to plug in a printer before activating cups. But, I digress. My scanner works fine when I boot into my home-grown system that still uses /etc/rc.d scripts. Systemd didn't break sane-find-scanner, lsusb, or the sysfs entries, but scanimage eventually times out, and front-ends like xsane or gimp don't know where the scanner went. No worries, I drop into a virtual machine whenever I need to scan images, 35mm slides, and all. I'll start a new thread if I ever get around to debugging systemd's ability to baffle my usb scanner.


All times are GMT -5. The time now is 05:32 PM.