linux-hotplug.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Stefan Schweizer <sschweizer@gmail.com>
To: linux-hotplug@vger.kernel.org
Subject: Re: Run hotplug scripts after device node is created?
Date: Tue, 23 Aug 2005 21:34:20 +0000	[thread overview]
Message-ID: <e7963922050823143473323124@mail.gmail.com> (raw)
In-Reply-To: <e796392205082213456c05e1b@mail.gmail.com>

[-- 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

  parent reply	other threads:[~2005-08-23 21:34 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
2005-08-23 21:52 ` Marco d'Itri

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=e7963922050823143473323124@mail.gmail.com \
    --to=sschweizer@gmail.com \
    --cc=linux-hotplug@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).