[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: [sane-devel] Calling a script after USB scanner is plugged



Am Mittwoch, 23. April 2008 schrieb Julien BLACHE:
> Johannes Meixner <jsmeix@suse.de> wrote:
>
> Hi,
>
> >> umax1220u scripts are started in a sequence (i.e. not in parallel, when
> >> one is completed the next one starts).
>
> When troubleshooting udev rules, use udevmonitor to actually see
> what's happening in terms of udev events and their properties.
>

That was a very good hint, thanks. A single scanimage -L causes these events:

UEVENT[1208979136.171525] remove   /class/usb_endpoint/usbdev1.5_ep01 
(usb_endpoint)
UEVENT[1208979136.171696] remove   /class/usb_endpoint/usbdev1.5_ep82 
(usb_endpoint)
UEVENT[1208979136.171702] remove   /class/usb_endpoint/usbdev1.5_ep83 
(usb_endpoint)
UEVENT[1208979136.171707] add      /class/usb_endpoint/usbdev1.5_ep01 
(usb_endpoint)
UEVENT[1208979136.171712] add      /class/usb_endpoint/usbdev1.5_ep82 
(usb_endpoint)
UEVENT[1208979136.171717] add      /class/usb_endpoint/usbdev1.5_ep83 
(usb_endpoint)
UDEV  [1208979136.172276] remove   /class/usb_endpoint/usbdev1.5_ep01 
(usb_endpoint)
UDEV  [1208979136.172803] remove   /class/usb_endpoint/usbdev1.5_ep82 
(usb_endpoint)
UDEV  [1208979136.173239] remove   /class/usb_endpoint/usbdev1.5_ep83 
(usb_endpoint)
UDEV  [1208979136.174020] add      /class/usb_endpoint/usbdev1.5_ep01 
(usb_endpoint)
UDEV  [1208979136.174831] add      /class/usb_endpoint/usbdev1.5_ep82 
(usb_endpoint)
UDEV  [1208979136.175619] add      /class/usb_endpoint/usbdev1.5_ep83 
(usb_endpoint)

>
> > ACTION!="add", GOTO="end"
> > SYSFS{idVendor}=="04b8", SYSFS{idProduct}=="010b", RUN+="..."
> > LABEL="end"
>
> Be careful with the labels you use. Always use a unique label name, or
> you're asking for troubles. (been there, done that, accidentally
> rendered a number of systems unbootable due to that ...)

I tried that before after I saw the z60_libsane.rules

ACTION!="add", GOTO="post_lamp_off"
SYSFS{idVendor}=="1606", SYSFS{idProduct}=="0010", MODE="0664", 
GROUP="scanner", NAME="umax%n", RUN+="/usr/local/bin/umax1220u start", 
ENV{lamp_off}="yes"
LABEL="post_lamp_off"

But given the events, it is obvious not surprising that this is not working.

> > Welcome in the hell of udev, HAL and whatever else sophisticated
> > stuff which is required to make users happy or so they say...
>
> <aol />

I added now in my script a file system lock:

if [ ! -e /tmp/umax1220u-plugged ]; then

  touch /tmp/umax1220u-plugged

Is anybody aware of a more elegant solution for this problem?

Thanks,
Rainer


-- 
Rainer Dorsch
Lärchenstr. 6
D-72135 Dettenhausen
07157-734133
email: rdorsch@web.de
jabber: rdorsch@jabber.org
GPG Fingerprint: 5966 C54C 2B3C 42CC 1F4F  8F59 E3A8 C538 7519 141E
Full GPG key: http://pgp.mit.edu/


Reply to: