linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Run hotplug scripts after device node is created?
@ 2005-08-22 20:45 Stefan Schweizer
  2005-08-22 21:15 ` Kay Sievers
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Stefan Schweizer @ 2005-08-22 20:45 UTC (permalink / raw)
  To: linux-hotplug

Hi,

I use a hotplug script to download the firmware to my hp printer. This
is needed for HP Laserjet 1000,1005 and 1020. The procedure is just
cat firmware > /dev/usb/lp*

The problem is that /dev/usb/lp* has to exist for the script to work.
In earlier udev versions I just added "sleep 20" to the script to be
sure that the device node exists. With the last version of udev this
seems to be no longer possiblee because udev waits for the hotplug
script to exit before creating the device node :(

How can I make sure that the hotplug script is run after usblp is
loaded and after the device is created?

Is there some hotplug-way to find out which device-node I am supposed
to load the firmware into?

Regards,
Stefan


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
@ 2005-08-22 21:15 ` Kay Sievers
  2005-08-22 21:23 ` Stefan Schweizer
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Kay Sievers @ 2005-08-22 21:15 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Aug 22, 2005 at 10:45:49PM +0200, Stefan Schweizer wrote:
> I use a hotplug script to download the firmware to my hp printer. This
> is needed for HP Laserjet 1000,1005 and 1020. The procedure is just
> cat firmware > /dev/usb/lp*
> 
> The problem is that /dev/usb/lp* has to exist for the script to work.
> In earlier udev versions I just added "sleep 20" to the script to be
> sure that the device node exists. With the last version of udev this
> seems to be no longer possiblee because udev waits for the hotplug
> script to exit before creating the device node :(

No, only PROGRAM and IMPORT runs before the node is created.

> How can I make sure that the hotplug script is run after usblp is
> loaded and after the device is created?

RUN runs definitely after the node handling is finished.

> Is there some hotplug-way to find out which device-node I am supposed
> to load the firmware into?

Don't understand the question.


And what udev version is it?
What does:
  cat /proc/sys/kernel/hotplug
print?

Kay


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
  2005-08-22 21:15 ` Kay Sievers
@ 2005-08-22 21:23 ` Stefan Schweizer
  2005-08-22 21:46 ` Marco d'Itri
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Stefan Schweizer @ 2005-08-22 21:23 UTC (permalink / raw)
  To: linux-hotplug

On 8/22/05, Kay Sievers <kay.sievers@vrfy.org> wrote:
> On Mon, Aug 22, 2005 at 10:45:49PM +0200, Stefan Schweizer wrote:
> > I use a hotplug script to download the firmware to my hp printer. This
> > is needed for HP Laserjet 1000,1005 and 1020. The procedure is just
> > cat firmware > /dev/usb/lp*
> >
> > The problem is that /dev/usb/lp* has to exist for the script to work.
> > In earlier udev versions I just added "sleep 20" to the script to be
> > sure that the device node exists. With the last version of udev this
> > seems to be no longer possiblee because udev waits for the hotplug
> > script to exit before creating the device node :(
> 
> No, only PROGRAM and IMPORT runs before the node is created.
> 
> > How can I make sure that the hotplug script is run after usblp is
> > loaded and after the device is created?
> 
> RUN runs definitely after the node handling is finished.
> 
I don't use either of those ..

this is just a plain old hotplug script with
/etc/hotplug/usb/hplj.usermap:
hplj1005 0x0003 0x03f0 0x1317 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00
0x00 0x00000000
/etc/hotplug/usb/hplj1005
waiting and catting the firmware into the device node.

> > Is there some hotplug-way to find out which device-node I am supposed
> > to load the firmware into?
> 
> Don't understand the question.
currently the script is scanning all devices for a supported one .. is
there some variable in a hotplug script to read out the device node?


> And what udev version is it?
udev-068

> What does:
>   cat /proc/sys/kernel/hotplug
> print?
/sbin/udevsend

thanks,
Stefan


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
  2005-08-22 21:15 ` Kay Sievers
  2005-08-22 21:23 ` Stefan Schweizer
@ 2005-08-22 21:46 ` Marco d'Itri
  2005-08-22 21:48 ` Kay Sievers
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Marco d'Itri @ 2005-08-22 21:46 UTC (permalink / raw)
  To: linux-hotplug

On Aug 22, Stefan Schweizer <sschweizer@gmail.com> wrote:

> this is just a plain old hotplug script with
> /etc/hotplug/usb/hplj.usermap:
Don't. Support for maps will be probably killed *soon*.

> currently the script is scanning all devices for a supported one .. is
> there some variable in a hotplug script to read out the device node?
udev can provide it on the command line.

-- 
ciao,
Marco


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (2 preceding siblings ...)
  2005-08-22 21:46 ` Marco d'Itri
@ 2005-08-22 21:48 ` Kay Sievers
  2005-08-23  5:26 ` Stefan Schweizer
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Kay Sievers @ 2005-08-22 21:48 UTC (permalink / raw)
  To: linux-hotplug

On Mon, Aug 22, 2005 at 11:23:44PM +0200, Stefan Schweizer wrote:
> On 8/22/05, Kay Sievers <kay.sievers@vrfy.org> wrote:
> > On Mon, Aug 22, 2005 at 10:45:49PM +0200, Stefan Schweizer wrote:
> > > I use a hotplug script to download the firmware to my hp printer. This
> > > is needed for HP Laserjet 1000,1005 and 1020. The procedure is just
> > > cat firmware > /dev/usb/lp*
> > >
> > > The problem is that /dev/usb/lp* has to exist for the script to work.
> > > In earlier udev versions I just added "sleep 20" to the script to be
> > > sure that the device node exists. With the last version of udev this
> > > seems to be no longer possiblee because udev waits for the hotplug
> > > script to exit before creating the device node :(
> > 
> > No, only PROGRAM and IMPORT runs before the node is created.
> > 
> > > How can I make sure that the hotplug script is run after usblp is
> > > loaded and after the device is created?
> > 
> > RUN runs definitely after the node handling is finished.
> > 
> I don't use either of those ..
> 
> this is just a plain old hotplug script with
> /etc/hotplug/usb/hplj.usermap:
> hplj1005 0x0003 0x03f0 0x1317 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00
> 0x00 0x00000000
> /etc/hotplug/usb/hplj1005
> waiting and catting the firmware into the device node.

Somewhere in your rules is a:
  RUN+="/sbin/udev_run_hotplugd"

right? If not, /etc/hotplug.d/ is not called.

> > > Is there some hotplug-way to find out which device-node I am supposed
> > > to load the firmware into?
> > 
> > Don't understand the question.
> currently the script is scanning all devices for a supported one .. is
> there some variable in a hotplug script to read out the device node?

Sure. DEVNAME.

Kay


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (3 preceding siblings ...)
  2005-08-22 21:48 ` Kay Sievers
@ 2005-08-23  5:26 ` Stefan Schweizer
  2005-08-23  5:29 ` Stefan Schweizer
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Stefan Schweizer @ 2005-08-23  5:26 UTC (permalink / raw)
  To: linux-hotplug

On 8/22/05, Marco d'Itri <md@linux.it> wrote:
> On Aug 22, Stefan Schweizer <sschweizer@gmail.com> wrote:
> 
> > this is just a plain old hotplug script with
> > /etc/hotplug/usb/hplj.usermap:
> Don't. Support for maps will be probably killed *soon*.
what am I supposed to be using now?

> > currently the script is scanning all devices for a supported one .. is
> > there some variable in a hotplug script to read out the device node?
> udev can provide it on the command line.
How can I use the cmdline?

Stefan


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (4 preceding siblings ...)
  2005-08-23  5:26 ` Stefan Schweizer
@ 2005-08-23  5:29 ` Stefan Schweizer
  2005-08-23  7:54 ` Marco d'Itri
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Stefan Schweizer @ 2005-08-23  5:29 UTC (permalink / raw)
  To: linux-hotplug

On 8/22/05, Kay Sievers <kay.sievers@vrfy.org> wrote:
> On Mon, Aug 22, 2005 at 11:23:44PM +0200, Stefan Schweizer wrote:
> > this is just a plain old hotplug script with
> > /etc/hotplug/usb/hplj.usermap:
> > hplj1005 0x0003 0x03f0 0x1317 0x0000 0x0000 0x00 0x00 0x00 0x00 0x00
> > 0x00 0x00000000
> > /etc/hotplug/usb/hplj1005
> > waiting and catting the firmware into the device node.
> 
> Somewhere in your rules is a:
>   RUN+="/sbin/udev_run_hotplugd"
> 
> right? If not, /etc/hotplug.d/ is not called.
Yes, right ..it is obviously default in Gentoo.

- Stefan


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (5 preceding siblings ...)
  2005-08-23  5:29 ` Stefan Schweizer
@ 2005-08-23  7:54 ` Marco d'Itri
  2005-08-23 11:32 ` Olivier Blin
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Marco d'Itri @ 2005-08-23  7:54 UTC (permalink / raw)
  To: linux-hotplug

On Aug 23, Stefan Schweizer <sschweizer@gmail.com> wrote:

> > > this is just a plain old hotplug script with
> > > /etc/hotplug/usb/hplj.usermap:
> > Don't. Support for maps will be probably killed *soon*.
> what am I supposed to be using now?
A udev RUN rule.

> > > currently the script is scanning all devices for a supported one .. is
> > > there some variable in a hotplug script to read out the device node?
> > udev can provide it on the command line.
> How can I use the cmdline?
udev.conf(5).

-- 
ciao,
Marco


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (6 preceding siblings ...)
  2005-08-23  7:54 ` Marco d'Itri
@ 2005-08-23 11:32 ` Olivier Blin
  2005-08-23 12:27 ` Marco d'Itri
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Olivier Blin @ 2005-08-23 11:32 UTC (permalink / raw)
  To: linux-hotplug

md@Linux.IT (Marco d'Itri) writes:

> On Aug 22, Stefan Schweizer <sschweizer@gmail.com> wrote:
>
>> this is just a plain old hotplug script with
>> /etc/hotplug/usb/hplj.usermap:
> Don't. Support for maps will be probably killed *soon*.

What should we do then? Write an udev rule per device ids?
This would end up in a huge number of rules, can udev manage that
without performance cost?
Wouldn't it be better to add some kind of map support in udev?

-- 
Olivier Blin
Mandriva
Mandrakesoft becomes Mandriva



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (7 preceding siblings ...)
  2005-08-23 11:32 ` Olivier Blin
@ 2005-08-23 12:27 ` Marco d'Itri
  2005-08-23 13:39 ` Sergey Vlasov
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Marco d'Itri @ 2005-08-23 12:27 UTC (permalink / raw)
  To: linux-hotplug

On Aug 23, Olivier Blin <oblin@mandriva.com> wrote:

> What should we do then? Write an udev rule per device ids?
Yes, or match on some other appropriate value.

> This would end up in a huge number of rules, can udev manage that
> without performance cost?
I doubt that the number or rules would be high.

> Wouldn't it be better to add some kind of map support in udev?
No.

-- 
ciao,
Marco


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (8 preceding siblings ...)
  2005-08-23 12:27 ` Marco d'Itri
@ 2005-08-23 13:39 ` Sergey Vlasov
  2005-08-23 14:10 ` Olivier Blin
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Sergey Vlasov @ 2005-08-23 13:39 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 692 bytes --]

On Tue, 23 Aug 2005 14:27:09 +0200 Marco d'Itri wrote:

> On Aug 23, Olivier Blin <oblin@mandriva.com> wrote:
> 
> > What should we do then? Write an udev rule per device ids?
> Yes, or match on some other appropriate value.
> 
> > This would end up in a huge number of rules, can udev manage that
> > without performance cost?
> I doubt that the number or rules would be high.

$ grep -v '^#' /etc/hotplug/usb/libsane.usermap | wc -l
210
$ grep -v '^#' /etc/hotplug/usb/usbcam.usermap | wc -l 
372

These are basically just a bunch of USB vendor/device IDs, and it is
likely that most devices don't have any reliable attributes which would
allow to match a group of them with a single rule.

[-- Attachment #2: Type: application/pgp-signature, Size: 189 bytes --]

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (9 preceding siblings ...)
  2005-08-23 13:39 ` Sergey Vlasov
@ 2005-08-23 14:10 ` Olivier Blin
  2005-08-23 18:25 ` Stefan Schweizer
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Olivier Blin @ 2005-08-23 14:10 UTC (permalink / raw)
  To: linux-hotplug

Sergey Vlasov <vsu@altlinux.ru> writes:

> On Tue, 23 Aug 2005 14:27:09 +0200 Marco d'Itri wrote:
>
>> On Aug 23, Olivier Blin <oblin@mandriva.com> wrote:
>> 
>> > What should we do then? Write an udev rule per device ids?
>> Yes, or match on some other appropriate value.
>> 
>> > This would end up in a huge number of rules, can udev manage that
>> > without performance cost?
>> I doubt that the number or rules would be high.
>
> $ grep -v '^#' /etc/hotplug/usb/libsane.usermap | wc -l
> 210
> $ grep -v '^#' /etc/hotplug/usb/usbcam.usermap | wc -l 
> 372

Same on Mandriva (mostly gphoto devices):
$ grep -v '^#' /etc/hotplug/usb.*map | wc -l
936

> These are basically just a bunch of USB vendor/device IDs, and it is
> likely that most devices don't have any reliable attributes which would
> allow to match a group of them with a single rule.

Right, it means as many rules as devices.

-- 
Olivier Blin
Mandriva
Mandrakesoft becomes Mandriva



-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (10 preceding siblings ...)
  2005-08-23 14:10 ` Olivier Blin
@ 2005-08-23 18:25 ` Stefan Schweizer
  2005-08-23 19:25 ` Kay Sievers
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Stefan Schweizer @ 2005-08-23 18:25 UTC (permalink / raw)
  To: linux-hotplug

On 8/22/05, Kay Sievers <kay.sievers@vrfy.org> wrote:
> > currently the script is scanning all devices for a supported one .. is
> > there some variable in a hotplug script to read out the device node?
> 
> Sure. DEVNAME.

thank you .. but I do not seem to be able to access DEVNAME :(

Any better idea than again guessing and sleeping?

relevant part of udev.conf:

SUBSYSTEM="usb", ACTION="add", ENV{PRODUCT}="3f0/0517*",
RUN+="/etc/hotplug/hplj-udev"
SUBSYSTEM="usb", ACTION="add", ENV{PRODUCT}="3f0/1317*",
RUN+="/etc/hotplug/hplj-udev"
SUBSYSTEM="usb", ACTION="add", ENV{PRODUCT}="3f0/2B17*",
RUN+="/etc/hotplug/hplj-udev"
SUBSYSTEM="usb", KERNEL="lp*", ACTION="add", NAME="usb/%k",
SYMLINK+="usb%k", GROUP="lp"
#BUS="usb", KERNEL="lp[0-9]*",        NAME="usb/%k", GROUP="lp"

env of the script:
SUBSYSTEM=usb
DEVPATH=/devices/pci0000:00/0000:00:0f.5/usb2/2-2/2-2.1/2-2.1:1.0
PATH=/sbin:/bin:/usr/sbin:/usr/bin
ACTION­d
MODALIAS=usb:v03F0p1317d0120dc00dsc00dp00ic07isc01ip02
PWD=/
UDEVD_EVENT=1
SHLVL=1
HOME=/
DEVICE=/proc/bus/usb/002/017
INTERFACE=7/1/2
PRODUCT?0/1317/120
TYPE=0/0/0
PHYSDEVBUS=usb
SEQNUM†3
_=/bin/env


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (11 preceding siblings ...)
  2005-08-23 18:25 ` Stefan Schweizer
@ 2005-08-23 19:25 ` Kay Sievers
  2005-08-23 21:34 ` Stefan Schweizer
  2005-08-23 21:52 ` Marco d'Itri
  14 siblings, 0 replies; 16+ messages in thread
From: Kay Sievers @ 2005-08-23 19:25 UTC (permalink / raw)
  To: linux-hotplug

On Tue, Aug 23, 2005 at 08:25:05PM +0200, Stefan Schweizer wrote:
> On 8/22/05, Kay Sievers <kay.sievers@vrfy.org> wrote:
> > > currently the script is scanning all devices for a supported one .. is
> > > there some variable in a hotplug script to read out the device node?
> > 
> > Sure. DEVNAME.
> 
> thank you .. but I do not seem to be able to access DEVNAME :(
> 
> Any better idea than again guessing and sleeping?
> 
> relevant part of udev.conf:
> 
> SUBSYSTEM="usb", ACTION="add", ENV{PRODUCT}="3f0/0517*",
> RUN+="/etc/hotplug/hplj-udev"
> SUBSYSTEM="usb", ACTION="add", ENV{PRODUCT}="3f0/1317*",
> RUN+="/etc/hotplug/hplj-udev"
> SUBSYSTEM="usb", ACTION="add", ENV{PRODUCT}="3f0/2B17*",
> RUN+="/etc/hotplug/hplj-udev"
> SUBSYSTEM="usb", KERNEL="lp*", ACTION="add", NAME="usb/%k",
> SYMLINK+="usb%k", GROUP="lp"
> #BUS="usb", KERNEL="lp[0-9]*",        NAME="usb/%k", GROUP="lp"
> 
> env of the script:
> SUBSYSTEM=usb
> DEVPATH=/devices/pci0000:00/0000:00:0f.5/usb2/2-2/2-2.1/2-2.1:1.0
> PATH=/sbin:/bin:/usr/sbin:/usr/bin
> ACTION­d
> MODALIAS=usb:v03F0p1317d0120dc00dsc00dp00ic07isc01ip02
> PWD=/
> UDEVD_EVENT=1
> SHLVL=1
> HOME=/
> DEVICE=/proc/bus/usb/002/017
> INTERFACE=7/1/2
> PRODUCT?0/1317/120
> TYPE=0/0/0
> PHYSDEVBUS=usb
> SEQNUM†3
> _=/bin/env

You are catching the event for the "raw" usb device here. I don't know what
device you need to upload the firmware too, but "raw" usb devices don't
have a device node in the current kernel only an interface in /proc.
You may need to catch the event for the printer interface, not sure.

Run "udevmonitor" while connecting the printer, it will show you all
events. And "udevmonitor --env" will print the whole environment, where
you can possibly see the DEVNAME.

Good luck,
Kay


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (12 preceding siblings ...)
  2005-08-23 19:25 ` Kay Sievers
@ 2005-08-23 21:34 ` Stefan Schweizer
  2005-08-23 21:52 ` Marco d'Itri
  14 siblings, 0 replies; 16+ messages in thread
From: Stefan Schweizer @ 2005-08-23 21:34 UTC (permalink / raw)
  To: linux-hotplug

[-- Attachment #1: Type: text/plain, Size: 1152 bytes --]

On 8/23/05, Kay Sievers <kay.sievers@vrfy.org> wrote:
> You are catching the event for the "raw" usb device here. I don't know what
> device you need to upload the firmware too, but "raw" usb devices don't
> have a device node in the current kernel only an interface in /proc.
> You may need to catch the event for the printer interface, not sure.
> 
> Run "udevmonitor" while connecting the printer, it will show you all
> events. And "udevmonitor --env" will print the whole environment, where
> you can possibly see the DEVNAME.

Thanks you very much, I got it working!

rules look like:
SUBSYSTEM=="usb", KERNEL=="lp*", ACTION=="add",
SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="0517",
RUN+="/etc/hotplug/hplj-udev 1000"
SUBSYSTEM=="usb", KERNEL=="lp*", ACTION=="add",
SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="1317",
RUN+="/etc/hotplug/hplj-udev 1005"
SUBSYSTEM=="usb", KERNEL=="lp*", ACTION=="add",
SYSFS{idVendor}=="03f0", SYSFS{idProduct}=="2B17",
RUN+="/etc/hotplug/hplj-udev 1020"

and the script is attached for those interested.
Comments? Improvements? Is /etc/hotplug a good dir for udev-run-scripts?

Regrads

[-- Attachment #2: hplj-udev --]
[-- Type: application/octet-stream, Size: 2296 bytes --]

#!/bin/sh

#	hplj1000:
#	hplj1005:
#	hplj1020:
#
#	Hotplug script for HP1000/1005/1020 USB laser printers. The model number
#	that this script deals with is determined from the udev env.
#
#	Used to download firmware automatically into the printer when it
#	is powered up or plugged into the USB port.
#
#	The inspiration fo this script is from:
#		Oscar Santacreu. Alicante-Spain (2002)
#		Mike Morgan (2004)
#	Modified by Stefan Schweizer (2005) to work as a udev-RUN-script

#
# Directory to find downloadable HP firmware files sihpMMMM.dl
#
FWDIR=/usr/share/foo2zjs/firmware

#
# Program used to determine USB id information
#
USBID=/usr/bin/usb_printerid

#
#	Figure out how to log our messages
#
if [ -t 1 ]; then
    # Running from a tty...
    log() {
	echo "$0: $@"
    }
elif [ -x /usr/bin/logger ]; then
    # Have logger...
    log() {
	logger -t "$0" -- "$@"
    }
else
    # No logger...
    log() {
	echo "$0: $@" >> /var/log/messages
    }
fi

#
#	Figure out the model number from the name of this script
#
case "$1" in
1000)
    MODEL=1000
    MODELNAME="hp LaserJet $MODEL"
    ;;
1005)
    MODEL=1005
    MODELNAME="hp LaserJet $MODEL"
    ;;
1020)
    MODEL=1020
    MODELNAME="HP LaserJet $MODEL"
    ;;
*)
    log "Only HP LaserJet 1000, 1005 and 1020 are supported"
    exit
    ;;
esac

#
#	Procedure to load a single device with firmware
#
load1() {
    fw="$FWDIR/sihp$MODEL.dl"
    if [ ! -f "$fw" ]; then
	log "Missing HP LaserJet $MODEL firmware file $fw"
	log "...read foo2zjs installation instructions and run ./getweb $MODEL"
	return 1
    fi

    log "loading HP LaserJet $MODEL firmware $fw to $DEVNAME ..."
    if cat $fw > $DEVNAME; then
	log "... download successful."
    else
	log "... download failed."
    fi
    return 0
}

#
#	OK, now download firmware to any printers that need it
#
if [ -x $USBID ]; then
	if $USBID $DEVNAME | grep "$MODELNAME" 2> /dev/null; then
	    # This is a LaserJet 100x
	    if $USBID $DEVNAME | grep 'FWVER' 2> /dev/null; then
		log "HP LaserJet $MODEL firmware already loaded into $DEVNAME"
	    else
		# Firmware is not yet loaded
		load1 "$DEVNAME"
	    fi
	else
	    log "Wrong printer detected .."
	fi
else
    log "HP LaserJet $MODEL firmware was not downloaded..."
    log "...couldn't find /usr/bin/usb_printerid"
fi

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Run hotplug scripts after device node is created?
  2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
                   ` (13 preceding siblings ...)
  2005-08-23 21:34 ` Stefan Schweizer
@ 2005-08-23 21:52 ` Marco d'Itri
  14 siblings, 0 replies; 16+ messages in thread
From: Marco d'Itri @ 2005-08-23 21:52 UTC (permalink / raw)
  To: linux-hotplug

On Aug 23, Stefan Schweizer <sschweizer@gmail.com> wrote:

> Comments? Improvements? Is /etc/hotplug a good dir for udev-run-scripts?
I suggest you use /lib/hotplug/ or /sbin/.

-- 
ciao,
Marco


-------------------------------------------------------
SF.Net email is Sponsored by the Better Software Conference & EXPO
September 19-22, 2005 * San Francisco, CA * Development Lifecycle Practices
Agile & Plan-Driven Development * Managing Projects & Teams * Testing & QA
Security * Process Improvement & Measurement * http://www.sqe.com/bsce5sf
_______________________________________________
Linux-hotplug-devel mailing list  http://linux-hotplug.sourceforge.net
Linux-hotplug-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linux-hotplug-devel

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2005-08-23 21:52 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-08-22 20:45 Run hotplug scripts after device node is created? Stefan Schweizer
2005-08-22 21:15 ` Kay Sievers
2005-08-22 21:23 ` Stefan Schweizer
2005-08-22 21:46 ` Marco d'Itri
2005-08-22 21:48 ` Kay Sievers
2005-08-23  5:26 ` Stefan Schweizer
2005-08-23  5:29 ` Stefan Schweizer
2005-08-23  7:54 ` Marco d'Itri
2005-08-23 11:32 ` Olivier Blin
2005-08-23 12:27 ` Marco d'Itri
2005-08-23 13:39 ` Sergey Vlasov
2005-08-23 14:10 ` Olivier Blin
2005-08-23 18:25 ` Stefan Schweizer
2005-08-23 19:25 ` Kay Sievers
2005-08-23 21:34 ` Stefan Schweizer
2005-08-23 21:52 ` Marco d'Itri

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).