Hi Mike, I have been a subscriber to this list for years, but I have to give first a specific disclaimer. I am not a developer for sane, nor any regular contributor. But I have been active for years in the Gphoto project and also have written several kernel drivers for webcams. Most particularly, I have supported a bunch of cheap cameras which are "dual mode" in nature, being able to function as webcams or also to be able to shoot photos which can be downloaded when the camera is hooked to the computer.
What I suspect is happening here is something that I have faced, too. It is the issue of having one USB device with one Vendor:Product code number, which can function in more than one way. As your printer is also a scanner, so the cameras I supported can either be webcams or stillcams. For these cameras, a problem arises. The webcam support is in the kernel, and the Gphoto support for the stillcam functions is in userspace, getting the access through libusb. The two must inevitably clash, since the userspace stuff cannot function so long as the kernel has grabbed the device. In the attempt partially to solve the problem, functionality has been added to libusb which can ask the kernel to let go of its lock on the camera. When a newer version of libusb is on the computer, and the camera is plugged in, the kernel grabs it immediately. But then if the access through libgphoto2 is initiated the kernel module goes into inactive status and the user can download the photos. The solution is not perfect, though. If the user wants next to use the camera in webcam mode it needs to be replugged in order to reactivate the kernel module. The problem has been greatly exacerbated, too, by some attempts to "simplify" things for users. Some distros have very much wanted to do that. Attempts to "simplify" have included such things as automatically recognizing a camera which is supported by libgphoto2 and then automatically starting up a still photo downloading program. Clearly, when such a thing has been done the camera can never be used as a webcam until that "improvement" has been turned off. Replugging is no answer, because what that does is to re-trigger the stillcam support, which disables the kernel module again. The only thing that the user can do is to turn the "user friendly" feature off and load the module by hand when wanting to use it. So, what I think you have run up against is a fundamental problem, namely to have one USB device which has more than one functionality and requires more than one kind of support. And if one kind of support is installed and active then the other one is locked out from working. The question is, what to do? The problem is in general not solved. But in order to confirm or to refute my suspicions, I ask a couple of questions, below, in you text, as you report things. I hope that these questions may also help the SANE team, too. If this is all obvious to them, I do ask pardon for my presumption. As I said I am not exactly a member of the SANE team even though not exactly a stranger, either. Questions follow, in line, below. Theodore Kilgore On Thu, 9 May 2013, Mike Cloaked wrote: > On Mon, May 6, 2013 at 9:12 PM, Mike Cloaked <mike.cloaked at gmail.com> > wrote: > I have a strange scanner failure to try to resolve, and I am > hoping that an expert on this list may be able to help me fix > the problem. > I have a Samsung SCX-4500W multifunction printer that is plugged in to > the usb port of my main machine running arch linux x86_64. ?The > printer part works fine with the Splix driver, but the scanner fails > to work. > > When I unplug the device and plug it into a laptop running arch linux, > it works fine. On a second laptop also running arch linux the scanner > functions also work fine (xsane). However plugging the same device > back in to my main desktop the scanner fails to work. What this looks like to me is that the support for a USB printer is permanently installed on your main desktop, but not on the laptops. Am I right about this? Is printer support installed on the laptops? Or not? If present on the laptops, is the printer support activated when you turn the laptop on? Or not? When you successfully scan on the laptop, when did you hook up the scanner? Before booting? Or after? Obviously, what I am suspecting is that your laptops are either not configured to talk to a printer, or they are not installing automatically whatever is needed to do that, and so you can go ahead and use the scanner. But on the main machine it is configured to access the printer. And if the printer access is "active" then in all likelihood the scanner access is blocked. The kernel support for printers has grabbed the hardware and will not let go. Based upon these suspicions, a couple more questions: Is the printer attached permanently to the main desktop system? In particular, is it detected during bootup and the support installed while the system is booting? If the above is "yes" then what happens if you hook it to the laptop, boot the laptop, and then try to use the scanner? Clearly, I am suspecting that you will suddenly not be able to access the scanner. But by all means do confirm that I am right or wrong. Conversely, what happens if you disconnect the printer/scanner from the main machine and then boot up, and plug in the printer/scanner after booting. Can you now get access to the scanner? Whether the answer to the previous question is yes, or no, can you do a print job? Probably, you can think of some more tests along the same lines now that I brought the question up. So I leave you to do that. > > Some information is as follows: > > sane-find-scanner works as either root or user and yields lines > including: > > found USB scanner (vendor=0x04e8 [Samsung Electronics Co., Ltd.], > product=0x342b [SCX-4500W Series]) at libusb:001:007 > ? # Your USB scanner was (probably) detected. It may or may not be > supported by > ? # SANE. Try scanimage -L and read the backend's manpage. > > scanimage -L works the first time I issue the command but then > subsequently fails: > > scanimage -L > device `xerox_mfp:libusb:001:006' is a Samsung Samsung SCX-4500W > Series multi-function peripheral > > 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). > I don't know enough of the details of sane to know why this is happening. But what appears to be happening is that the first attempt simply looks for the device, and the second one wants to see if it really is a scanner and it is "not a scanner" because it is a printer. Perhaps someone else who knows the sane codebase could enlighten us why this is happening. Another thing leaves me scratching the head, here, though. If sane is using libusb then why does it not disable and inactivate the /dev/lp* which the printer is using? Such disabling is exactly what happens with a dual-mode camera. Namely, the /dev/video* associated with the camera is disabled, and the program to download still photos can now work. Not that this would actually make you happy, of course, because after scanning you would need to re-plug the USB device in order to make it to be a printer again (if it is acting just like one of my cameras). Curious whether your distro is using an old version of libusb which does not support the userspace-disables-module feature, or whether they have taken that feature back out again, thinking it was not a good idea after all. I have not kept up with this stuff in the last few months so I do not know. > The device is listed correctly with the lsusb command: > Bus 001 Device 007: ID 04e8:342b Samsung Electronics Co., Ltd? > > > The file?/etc/sane.d/xerox_mfp.conf does have the correct line for the > device: > # Samsung SCX-4500W > usb 0x04e8 0x342b > > The system log files contain lines like: > May ?6 16:43:27 localhost kernel: [ 8041.053060] usb 1-4: usbfs: > interface 1 claimed by usblp while 'xsane' sets config #1 Yep. And apparently your libusb cannot grab the device, or else the printer is a special case and nobody gets to grab it. > > I have tried unplugging the device and replugging it but nothing I do > ever seems to make any difference. ? As I mentioned above, try leaving the printer unplugged during boot. Also try plugging the printer to the laptop before booting the laptop. I also removed the .sane directory > from the user and started from new and nothing changed. > > The udev rules file seems fine and in?less > /lib64/udev/rules.d/53-sane.rules the lines relevant to the device > are: > > # Samsung SCX-4500W > ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664", > GROUP="scanner", ENV{libsane_matched}="yes" > > > The system is fully up to date, and runs with systemd. The two laptops > one of which is x86_64 and the other i386 are both the same arch > setup, and both up to date. They work but the main machine does not. I do not claim familiarity with systemd. My distro does not use it. The udev rules are no help, either. If the kernel grabbed the hardware because it is a printer, these will be ignored. Unless your libusb can in turn disable the printer driver. Which might not make one very happy, either, and is therefore far from an ultimate solution to the problem. However, systemd could conceivably be part of the problem. If it has "decided" during boot that your USB peripheral is a printer, then that decision might well be irrevocable. I don't know enough about systemd to be able to say this for certain, of course. > > Can anyone suggest how I might be able to narrow down where the > problem may lie? > > Many thanks for any help. See above. It doesn't solve the problem, of course, only narrow it down if my suspicions are correct. Basically, it seems to me this is a problem which requires fundamental changes which have not yet occurred. (Speculating) It seems to me that what is needed is some changes in the kernel code for USB printers which can accommodate dual-mode printer-scanner or triple-mode printer-scanner-fax hardware. > > > Having tried to follow up on the post I saw about the?Pulstek OpticBook > 3800, I tried to do something analogous but it did not seem to work so I > probably did not have the correct syntax. > > However I tried (in arch linux): > > sudo sane-find-scanner > > which gave the device as: > found USB scanner (vendor=0x04e8 [Samsung Electronics Co., Ltd.], > product=0x342b [SCX-4500W Series]) at libusb:001:009 > > Then I tried the command: > sudo SANE_DEBUG_XEROX_MFP=256 ?scanimage -d xerox_mfp:libusb:001:009 -v -v > -v -v -v 2> scan-debug-1.txt > > and the file contains: > > [sanei_debug] Setting debug level of xerox_mfp to 256. > [xerox_mfp] sane_init: Xerox backend (build 13), version != null, authorize > != null > [xerox_mfp] sane_xerox_mfp_open: 'libusb:001:009' > [xerox_mfp] sane_xerox_mfp_get_devices: (nil), 1 > [xerox_mfp] list_one_device: libusb:001:009 > [xerox_mfp] usb_dev_open: open 0x21e93c0 > [xerox_mfp] :: dev_command(INQUIRY[0x12], 70) > [xerox_mfp] usb_dev_request: sanei_usb_read_bulk: Error during device I/O > [xerox_mfp] dev_command: dev_request: Error during device I/O > [xerox_mfp] usb_dev_close: closing dev 0x21e93c0 > [xerox_mfp] list_one_device: dev_inquiry(libusb:001:009): Error during > device I/O > scanimage: open of device xerox_mfp:libusb:001:009 failed: Invalid argument > Calling sane_exit > scanimage: finished > > Did I get the command syntax incorrect? ?I would appreciate any help with > this - but this seems to be unable to open the device so I don't know how to > proceed to get some definitive information about that is going wrong. > > Thanks for any help. > > > > -- > mike c > >