udev-ish replacement for hal-cups-utils?

Martin Pitt martin.pitt at ubuntu.com
Mon Jul 20 08:21:30 PDT 2009


Hello Tim,

sorry for long delay, was away over the weekend.

Tim Waugh [2009-07-17 12:08 +0100]:
> I'm trying to use libudev to read the ieee1284_id attribute but am
> failing.  The devpath I'm given is:
>   /devices/pci0000:00/0000:00:1d.3/usb5/5-1
> 
> I can see that the file I need is:
>   /sys/devices/pci0000:00/0000:00:1d.3/usb5/5-1/5-1:1.0/ieee1284_id

Right, 5-1 is the USB device (which has vendor/product ID, name,
etc.). Every USB device has a number of "interfaces" (e. g. a printer
and a scanner service for a multi-function-printer, or mass-storage
partition and a PTP interface for a digicam). 5-1:1.0 is the printer
(07/01) interface of that device.

> but I can't see how to get to it.  How do I find out the name "5-1:1.0"?
> (The code is currently trying usb_interface which is obviously wrong.)

I looked at

  ACTION=="add", SUBSYSTEM=="usb", ENV{ID_USB_INTERFACES}=="*:0701*:*", IMPORT{program}+="udev-configure-printer add %p"

and for some reason I don't even have that ID_USB_INTERFACES attribute
on my printer. For me, it works if I write the rule like

  ACTION=="add", SUBSYSTEM=="usb", ATTR{bInterfaceClass}=="07", ATTR{bInterfaceSubClass}=="01", IMPORT{program}+="udev-configure-printer add %p"

This could be because the printer I'm testing this with is attached to
a computer which still runs udev 141. (However, I do have
ID_USB_INTERFACES=:030102: for my mouse, hmm)

This rule works with and without the usblp module (i. e. after rmmod usblp,
the ieee1284_id disappears). After reading the discussion, and seeing
that apparently usblp is being deprecated and the world is moving
towards libusb, I guess udev-configure-printer could just test if
sysfs has an ieee1284_id attribute (since that's faster to get), and
if not, use libusb to read it?

I think it's easier to match on the printer interface with udev rules; if
you need the USB device, that's just the parent directory. If you
match on the device, your code had to walk over all the interfaces and
check which one is class 7, subclass 1 (also possible, of course).

Thanks,

Martin

-- 
Martin Pitt                        | http://www.piware.de
Ubuntu Developer (www.ubuntu.com)  | Debian Developer  (www.debian.org)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 197 bytes
Desc: Digital signature
Url : http://lists.freedesktop.org/archives/devkit-devel/attachments/20090720/b6f05e18/attachment.pgp 


More information about the devkit-devel mailing list