Discussion:
Help needed diagnosing strange failure to scan with Samsung SCX-4500W
(too old to reply)
Mike Cloaked
2013-05-06 20:12:36 UTC
Permalink
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.

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).

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

I have tried unplugging the device and replugging it but nothing I do ever
seems to make any difference. 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.

Can anyone suggest how I might be able to narrow down where the problem may
lie?

Many thanks for any help.
--
mike c
Mike Cloaked
2013-05-09 15:50:39 UTC
Permalink
Post by Mike Cloaked
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.
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
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).
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
# Samsung SCX-4500W
usb 0x04e8 0x342b
May 6 16:43:27 localhost kernel: [ 8041.053060] usb 1-4: usbfs: interface
1 claimed by usblp while 'xsane' sets config #1
I have tried unplugging the device and replugging it but nothing I do ever
seems to make any difference. 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
# 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.
Can anyone suggest how I might be able to narrow down where the problem
may lie?
Many thanks for any help.
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
m. allan noah
2013-05-09 15:56:24 UTC
Permalink
Try uninstalling or disabling your print driver, or anything else that
might be trying to talk to the scanner.

allan
Post by Mike Cloaked
Post by Mike Cloaked
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.
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
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).
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
# Samsung SCX-4500W
usb 0x04e8 0x342b
May 6 16:43:27 localhost kernel: [ 8041.053060] usb 1-4: usbfs: interface
1 claimed by usblp while 'xsane' sets config #1
I have tried unplugging the device and replugging it but nothing I do ever
seems to make any difference. 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
# 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.
Can anyone suggest how I might be able to narrow down where the problem
may lie?
Many thanks for any help.
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.
sudo sane-find-scanner
found USB scanner (vendor=0x04e8 [Samsung Electronics Co., Ltd.],
product=0x342b [SCX-4500W Series]) at libusb:001:009
sudo SANE_DEBUG_XEROX_MFP=256 scanimage -d xerox_mfp:libusb:001:009 -v -v
-v -v -v 2> scan-debug-1.txt
[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
--
http://lists.alioth.debian.org/cgi-bin/mailman/listinfo/sane-devel
Unsubscribe: Send mail with subject "unsubscribe your_password"
--
"The truth is an offense, but not a sin"
Theodore Kilgore
2013-05-09 18:25:23 UTC
Permalink
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
Post by Mike Cloaked
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.
Post by Mike Cloaked
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
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.
Post by Mike Cloaked
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
# Samsung SCX-4500W
usb 0x04e8 0x342b
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.
Post by Mike Cloaked
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
Post by Mike Cloaked
from the user and started from new and nothing changed.
The udev rules file seems fine and in less
# 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.
Post by Mike Cloaked
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.
Post by Mike Cloaked
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.
sudo sane-find-scanner
found USB scanner (vendor=0x04e8 [Samsung Electronics Co., Ltd.],
product=0x342b [SCX-4500W Series]) at libusb:001:009
sudo SANE_DEBUG_XEROX_MFP=256  scanimage -d xerox_mfp:libusb:001:009 -v -v
-v -v -v 2> scan-debug-1.txt
[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
Mike Cloaked
2013-05-09 18:49:42 UTC
Permalink
Hi Theodore

Thank you very much for your long reply - much of what you say sounds right
to me, and indeed I had wondered myself whether there was a conflict
"somewhere" between the printer and scanner support within the system but I
don't know how to resolve it. I have googled and found a number of posts on
various mailing lists and forums which indicate that this problem is not a
new one, and is not specific to any one linux distro - and yet there seems
no real way to find out how to sort the conflict out.

I will answer your questions inline below and hope that this can begin to
yield some insight into where the problem lies and how to try to resolve it.
Post by Theodore Kilgore
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?
Correct - the laptops were set to use the shared printer via cups (with
avahi-daemon running), but not to use the usb printer plugged directly into
the laptops.
Post by Theodore Kilgore
Is printer support installed on the laptops? Or not?
General printer support is installed in the laptops but the specific
printer is not set up - i.e. the crucial line in
/etc/udev/rules.d/70-printers.rules is not present in the laptops.
Post by Theodore Kilgore
If present on the laptops, is the printer support activated when you turn the
laptop on? Or not?
Only the cups shared printer when the printer is plugged into the main
desktop machine. Not directly on the laptop usb port.
Post by Theodore Kilgore
When you successfully scan on the laptop, when did you hook up the
scanner? Before booting? Or after?
After booting.
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.
Yes that sounds reasonable - the printer only "autoconfigures" if the
crucial extra definition line is in the udev rules file. Since it is
missing on the laptops then when the printer is plugged in it does not get
set up. On the desktop with the crucial line in the printer autoconfigured
as soon as it was plugged in. However removing the printer and re-plugging
it with the extra line removed does not fix the issue (though I have not
rebooted in that configuration - which could conceivably make a difference)
Post by Theodore Kilgore
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?
Usually yes - I have booted without the printer switched on, and the
desktop still fails to get the scanner going when I do turn it on (since
the printer and scanner are both operating obviously once it is switched on)
Post by Theodore Kilgore
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.
I could certainly try that - but haven't yet. I guess you are suggesting
that a kernel module will be loaded at boot and then conflict with the
scanner?
Post by Theodore Kilgore
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?
If I do that with the extra line in the udev rules file then it will print
fine but not scan.
Post by Theodore Kilgore
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.
snip
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 version of libusb is as follows:

[***@home1 scan-debug]# pacman -Ss libusb
core/libusb-compat 0.1.4-2 [installed]
Library to enable user space application programs to communicate with
USB devices
core/libusbx 1.0.15-1 [installed]
Library that provides generic access to USB device
extra/libgusb 0.1.6-1 [installed]
GLib wrapper around libusb1
Post by Theodore Kilgore
Post by Mike Cloaked
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.
Post by Mike Cloaked
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.
Will try to run that test later this evening.
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.
I would certainly like to know the answer to that very question! I have
been using systemd with udev for some time without any problems apart from
this one!
Post by Theodore Kilgore
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.
Yes hopefully the answers to the questions will help narrow it down - but
whether any fundamental change in the udev and/or systemd code is necessary
before the two functions can both work without messing with re-plugging the
device and rebooting each time I don't know. If there was a workaround ,
say running a script, it would make life easier - but of course the
"proper" solution is to have whatever code is the underlying cause of the
issue properly fixed. I expect as you say that this is likely not an issue
with sane but with device handling in one or other of the
kernel/udev/systemd

Thanks
--
mike c
Mike Cloaked
2013-05-09 19:00:11 UTC
Permalink
Post by Mike Cloaked
Hi Theodore
Post by Theodore Kilgore
When you successfully scan on the laptop, when did you hook up the
scanner? Before booting? Or after?
After booting.
I just ran a new test with the printer already plugged in during boot - the
scanner worked fine. However since there is no definition line for the
printer in the udev rules file this is perhaps not a surprise.
Post by Mike Cloaked
Post by Theodore Kilgore
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.
I could certainly try that - but haven't yet. I guess you are suggesting
that a kernel module will be loaded at boot and then conflict with the
scanner?
As above - printer is hooked up to laptop which is then booted - scanning
works fine. The printer is not set up on that machine.
--
mike c
Mike Cloaked
2013-05-09 19:06:26 UTC
Permalink
Post by Mike Cloaked
As above - printer is hooked up to laptop which is then booted - scanning
works fine. The printer is not set up on that machine.
When I plugged the printer back into the desktop after running the laptop
test the system log contains:

May 9 20:02:00 localhost kernel: [83203.611876] usblp 1-4:1.1: usblp0:
USB Bidirectional printer dev 13 if 1 alt 0 proto 2 vid 0x04E8 pid 0x342B
May 9 20:02:00 localhost colord: Device added:
sysfs-Samsung_Electronics_Co.__Ltd.-SCX-4500W_Series
May 9 20:02:00 localhost systemd[1]: Starting Printer.
May 9 20:02:00 localhost systemd[1]: Reached target Printer.
May 9 20:02:00 localhost systemd[1]: Starting Configure Plugged-In
Printer...
May 9 20:02:00 localhost systemd[1]: Started Configure Plugged-In Printer.
May 9 20:02:00 localhost systemd[1]: configure-***@usb-001-013.service:
main process exited, code=exited, status=1/FAILURE
May 9 20:02:00 localhost systemd[1]: Unit
configure-***@usb-001-013.service entered failed state.

So there is a problem though the printer still works fine when sending
pages to print.
--
mike c
Theodore Kilgore
2013-05-10 00:58:07 UTC
Permalink
(answer at bottom)
Post by Mike Cloaked
As above - printer is hooked up to laptop which is then booted -
scanning works fine. The printer is not set up on that machine. 
When I plugged the printer back into the desktop after running the laptop
 May  9 20:02:00 localhost kernel: [83203.611876] usblp 1-4:1.1: usblp0: USB
Bidirectional printer dev 13 if 1 alt 0 proto 2 vid 0x04E8 pid 0x342B
sysfs-Samsung_Electronics_Co.__Ltd.-SCX-4500W_Series
May  9 20:02:00 localhost systemd[1]: Starting Printer.
May  9 20:02:00 localhost systemd[1]: Reached target Printer.
May  9 20:02:00 localhost systemd[1]: Starting Configure Plugged-In
Printer...
May  9 20:02:00 localhost systemd[1]: Started Configure Plugged-In Printer.
main process exited, code=exited, status=1/FAILURE
May  9 20:02:00 localhost systemd[1]: Unit
So there is a problem though the printer still works fine when sending pages
to print.
--
mike c
This is weird. The "configuration and setup of the printer allegedly
fails, but it works?

Anyhow, here is what I get from all this:

1. It is a device permissions problem pretty much like what I was
envisioning.

2. You say it is not recent, but has happened to others before, and is not
distro-specific. This would be very much in line with (1).

3. As far as testing is concerned, there is a big difference between the
laptops and the desktop system. The desktop system is hooked to the
printer by way of the USB, and the laptops are not configured to see an
attached USB printer, only a networked printer using CUPS (presumably
accessing the printer through the desktop system, in that case). So there
is not any conflict for the laptops.

Do I have all of this right?


It is an interesting problem and does not have an easy solution. That much
is obvious. But what you have is the old kernelspace-userspace conflict at
work yet again. It does tend to play merry hell with dual-mode or
multi-mode USB devices. We obviously need to think of something to handle
it. But in case that you are wondering how we got into such a mess, do
realize one thing: this problem arises because Linux makes a rigid
separation between kernel stuff and user stuff. That rigid separation is
part of the security model in Linux, and from that point of view is very
much the right thing to do. Other operating systems which do not trouble
themselves about such fine points are well known for the consequences to
their security, too. Thus nobody wants to abandon the separation because
to abandon it is to abandon the security model.

You do mention in one of your posts above the following:

[***@home1 scan-debug]# pacman -Ss libusb
core/libusb-compat 0.1.4-2 [installed]
Library to enable user space application programs to communicate with
USB devices
core/libusbx 1.0.15-1 [installed]
Library that provides generic access to USB device
extra/libgusb 0.1.6-1 [installed]
GLib wrapper around libusb1

My setup is slightly different. I am running Slackware and we have two
packages. The first one is

libusb-1.0.9-x86_64-1

and the second one is

libusb-compat-0.1.4-x86_64-1

The description of the second Slackware package contains the following
information:

PACKAGE NAME: libusb-compat-0.1.4-x86_64-1
COMPRESSED PACKAGE SIZE: 28K
UNCOMPRESSED PACKAGE SIZE: 100K
PACKAGE LOCATION: ./libusb-compat-0.1.4-x86_64-1.txz
PACKAGE DESCRIPTION:
libusb-compat: libusb-compat (Compatibility library for libusb-0.1 apps)
libusb-compat:
libusb-compat: A compatibility layer allowing applications written for
libusb-0.
1 to
libusb-compat: work with libusb-1.0. libusb-compat-0.1 attempts to retain
as much
libusb-compat: ABI and API compatibility with libusb-0.1 as possible.
libusb-compat:
libusb-compat: Homepage: http://libusb.org

Thus, my version of libusb probably does contain some bells and whistles
which yours does not. In particular, the stuff about disabling the kernel
moduld.

But in fact I myself believe that these new bells and whistles in libusb
are a patch job at best, so long as one has to replug the hardware after
using it in "userspace" mode. We are clearly not out of the woods just by
doing that, and a better cure is needed. I have heard rumors that libusb
was also going to go the further step of hooking the kernel module back up
again after the userspace-supported functionality is terminated and the
program which is doing it is turned off. But I am not sure whether that
feature is as yet implemented, or whether it will be (I am obviously not
an insider on the libusb team, any more than I am an insider at SANE).

So, one partial solution might be to upgrade the libusb. And that will
probably solve some of your problem, but not all of it.

The problem is quite intractable, in fact. It is a general problem, and I
am not so clever that I can see which way it ought to be handled. There
have been some case-by-case solutions, of course.

One of the similar problems is the USB modems (Some cable modems, in
particular) which are seen by the computer as a mass storage device. Why
is that? Because the first thing that has to be done in order to run the
modem is to load firmware onto it. But then the modem is locked as a USB
mass storage device. So they had to figure out a way to make the mass
storage driver to let go.

The other one is the one that I know something about, having done both the
kernel support and the Gphoto support for certain cheap cameras. This is
not completely solved. I am not completely convinced that the way to solve
the problem once and for all is to write into each individual kernel
driver for each individual affected webcam the code to let it be accessed
as a stillcam (perhaps creating a /dev/stillcam as well as a /dev/video
interface, and a lock to prevent either of them from being called while
the other is active) and then rewriting the relevant parts of libgphoto2
to hook to the kernel module instead of libusb. Some other people involved
in linux media support believe so, but I am not totally convinced. I think
that there has to be a more general solution, because this kind of thing
happens all the time and will happen more and more often. We need more to
support multi-mode devices as a class, but how?

One thing which impedes a general solution is the problem of someone
trying to use the two functions at the same time. Think of what might
happen, even in your situation, if you are running a print job from the
desk system and you simultaneously try to scan and the scanning were not
blocked. Or what if it let you scan and let someone else sitting at the
laptop to send a print job while the scanning is going on? There has to be
some kind of blocking mechanism, and it has to work and prevent any bad
thing from happening. Frankly, it is complicated. Hellishly complicated.


So, I have not solved your problems. I suspect that I can't. But perhaps
if you can see what the problem is you can help, too. Someone has to come
up with the bright idea and the clever solution, after all.

Cheers,

Theodore Kilgore
Mike Cloaked
2013-05-10 08:20:53 UTC
Permalink
On Fri, May 10, 2013 at 1:58 AM, Theodore Kilgore <
Post by Theodore Kilgore
This is weird. The "configuration and setup of the printer allegedly
fails, but it works?
Indeed! However I am now wondering if this is due to a udev conflict - I
will add details further down.
Post by Theodore Kilgore
1. It is a device permissions problem pretty much like what I was
envisioning.
2. You say it is not recent, but has happened to others before, and is not
distro-specific. This would be very much in line with (1).
3. As far as testing is concerned, there is a big difference between the
laptops and the desktop system. The desktop system is hooked to the
printer by way of the USB, and the laptops are not configured to see an
attached USB printer, only a networked printer using CUPS (presumably
accessing the printer through the desktop system, in that case). So there
is not any conflict for the laptops.
Do I have all of this right?
Yes
Post by Theodore Kilgore
Thus, my version of libusb probably does contain some bells and whistles
which yours does not. In particular, the stuff about disabling the kernel
moduld.
I am wondering now about udev more than libusb -

In /lib/udev/rules.d/53-sane.rules

there is a rule for the scanner:

# Samsung SCX-4500W
ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664",
GROUP="scanner", ENV{libsane_matched}="yes"

and I amended the rule that I have in /etc/udev/rules.d/70-printers.rules

# Samsung SCX-4500W
#ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664",
GROUP="scanner", ENV{libsane_matched}="yes"

What I don;t know is whether the scanner rule that will apply first since
the file name starts with 53, will then be overruled by the printer rule
since that will take precedence since it comes later (as the filename
starts with 70)?

I guess that this means that the printer becomes defined in udev since the
printers rule occurs last. I am guessing that this removes the scanner
definition which is then no longer defined (but in the laptops the scanner
remains defined since there is no printer udev rule?

I have also been looking at the udev rule writing definitions - and I am
not sure whether changing the "=" on some or all of these two rules to ":="
would make a difference - as I understand it the simple "=" means that
definitions can be overruled but ":=" makes them "stick".

Also I don't know if changing the ATTR to ATTRS matters and vice versa - it
seems that the udev rule writing is quite subtle and may matter. Also I
don't know if udev can cope with defining a device with the same
attributes, and whether other attributes can be found so that the device
definition for the printer and scanner can be properly different in udev?

This may well be the same kind of issue that you have with the cameras as
you point out - and it would be nice to get to the bottom of it!
--
mike c
Mike Cloaked
2013-05-10 09:38:54 UTC
Permalink
Post by Mike Cloaked
I am wondering now about udev more than libusb -
In /lib/udev/rules.d/53-sane.rules
# Samsung SCX-4500W
ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664",
GROUP="scanner", ENV{libsane_matched}="yes"
and I amended the rule that I have in /etc/udev/rules.d/70-printers.rules
# Samsung SCX-4500W
#ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664",
GROUP="scanner", ENV{libsane_matched}="yes"
The lines that are active in the 70-printers-rules file are not the above
two but:
# Samsung SCX-4500W printer MFP
ATTR{idVendor}=="04e8", ATTR{idProduct}=="342b", MODE:="0664", GROUP:="lp",
ENV{libsane_matched}:="yes"

This MFP printer was previously in use up to 6 months ago with both the
printer and scanner functions working without any need to tinker on a
desktop computer running Fedora F16 which was using udev although of course
in the interim both udev as well as the kernels and systemd have been
updated significantly since then, and this is now connected to an arch
linux system.

However I do wonder if there is a way to get the udev rules changed so that
the two functions of this device can work alongside each other. If this
can be resolved then it may well also lead to a solution for your camera
multifunction problem also.
--
mike c
Thorsten Müller
2013-06-13 13:26:46 UTC
Permalink
Hello,
Post by Mike Cloaked
Post by Mike Cloaked
I am wondering now about udev more than libusb -
In /lib/udev/rules.d/53-sane.rules
# Samsung SCX-4500W
ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664",
GROUP="scanner", ENV{libsane_matched}="yes"
and I amended the rule that I have in
/etc/udev/rules.d/70-printers.rules
# Samsung SCX-4500W
#ATTRS{idVendor}=="04e8", ATTRS{idProduct}=="342b", MODE="0664",
GROUP="scanner", ENV{libsane_matched}="yes"
The lines that are active in the 70-printers-rules file are not the
# Samsung SCX-4500W printer MFP
ATTR{idVendor}=="04e8", ATTR{idProduct}=="342b", MODE:="0664",
GROUP:="lp", ENV{libsane_matched}:="yes"
This MFP printer was previously in use up to 6 months ago with both
the
printer and scanner functions working without any need to tinker on a
desktop computer running Fedora F16 which was using udev although of
course in the interim both udev as well as the kernels and systemd
have been updated significantly since then, and this is now connected
to an arch linux system.
However I do wonder if there is a way to get the udev rules changed so
that the two functions of this device can work alongside each other.
If this can be resolved then it may well also lead to a solution for
your camera multifunction problem also.
I don't know if your problem still exists since it's about a month back
you wrote about it, but I did not find any post regarding a solution.

Since the automagic setup by your distro's predefined udev rules seems
to fail, we have to force udev doing our biding.

First, comment out the above line in 70-printers-rules.
Second, create a file /etc/udev/rules.d/99-samsung-scx4500w.rules

Third, add the follwing lines to the newly created file:

--- Start here ---
# ACL settings for Samsung SCX-4500W printer MFP
ATTR{idVendor}=="04e8", ATTR{idProduct}=="342b", GOTO="samsung"
GOTO="samsung_end"

LABEL="samsung"
RUN+="/bin/setfacl -m g:scanner:rw -m g:lp:rw $env{DEVNAME}"
TEST=="/var/run/ConsoleKit/database", \
RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"

LABEL="samsung_end"
--- Stop here ---

You can copy and paste the aboce lines. That should set the permissions
for your multi function device so that sane, cups and your logged in
users have complete access. Unplug and plug in again and see if that
works.

Greetings
Thorsten
Thorsten Müller
2013-06-14 10:25:56 UTC
Permalink
Hello Mike,
Post by Thorsten Müller
Hello,
I don't know if your problem still exists since it's about a month
back you wrote about it, but I did not find any post regarding a
solution.
Since the automagic setup by your distro's predefined udev rules
seems to fail, we have to force udev doing our biding.
First, comment out the above line in 70-printers-rules.
Second, create a file /etc/udev/rules.d/99-samsung-scx4500w.rules
--- Start here ---
# ACL settings for Samsung SCX-4500W printer MFP
ATTR{idVendor}=="04e8", ATTR{idProduct}=="342b", GOTO="samsung"
GOTO="samsung_end"
LABEL="samsung"
RUN+="/bin/setfacl -m g:scanner:rw -m g:lp:rw $env{DEVNAME}"
TEST=="/var/run/ConsoleKit/database", \
RUN+="udev-acl --action=$env{ACTION} --device=$env{DEVNAME}"
LABEL="samsung_end"
--- Stop here ---
You can copy and paste the aboce lines. That should set the
permissions for your multi function device so that sane, cups and
your logged in users have complete access. Unplug and plug in again
and see if that works.
Having re-read your proposed solution I can see that it will need some
amending because firstly setacl is in /usr/bin/setacl in arch now
(after a big move to /usr ) instead of /bin/setfacl- and also arch is
no longer using ConsoleKit so there is no /var/run/ConsoleKit/
So the setting of the necessary permissions will need to be achieved
with some differences in the lines in the new file
/etc/udev/rules.d/99-samsung-scx4500w.rules
When I get a chance I will have to do some reading but if you can see
the alternative lines that will likely work instead I would certainly
appreciate it.
I just did a quick google search. Since I don't know how archlinux
handles logins and security, I cannot offer lots of help at this point.
If you use systemd, then systemd can be used to set the ACLs, but since
I don't use systemd, I don't know much about it. Perhaps it's enough to
just set the group ACLs and no user ACLs, so you could just delete the
line starting with TEST.

HTH
Greetings
Thorsten
Mike Cloaked
2013-06-27 21:18:10 UTC
Permalink
Hi Thorsten
On Fri, Jun 14, 2013 at 11:25 AM, Thorsten Müller <
Post by Thorsten Müller
I just did a quick google search. Since I don't know how archlinux
handles logins and security, I cannot offer lots of help at this point.
If you use systemd, then systemd can be used to set the ACLs, but since
I don't use systemd, I don't know much about it. Perhaps it's enough to
just set the group ACLs and no user ACLs, so you could just delete the
line starting with TEST.
HTH
Greetings
Thorsten
Thanks for your help - I have a full weekend ahead but I will try to look
into the ACL issues once we are into next week. It would certainly be
worthwhile getting a solution since I have seen postings that other people
have written on other forums with similar issues to this but with other
makes of MFP so a solution would help others as well as my problem! Yes my
system certainly uses systemd and has done for quite a while. I am not very
familiar with the use of ACLs so I will need to do some reading!
I have been doing some more reading - and came across this link, which may
have some pointers to the direction to go, but I still need to do more work
on this:


http://enotty.pipebreaker.pl/2012/05/23/linux-automatic-user-acl-management/
--
mike c
Continue reading on narkive:
Loading...