You are not logged in.

#1 2013-02-12 06:57:05

bowshock
Member
From: Indonesia
Registered: 2013-02-08
Posts: 26

[SOLVED] UDEV custom rule for HP P1102

Folks,

The printer works, but I have to modify the permission manually (as suggested by Arch Wiki & a post on this forum that I stumbled upon) each time my computer reboots. I read that udev would allow me to automate this process, but it seems that my attempt to create the following custom udev rule for this printer fails miserably.

SUBSYSTEM=="usbmisc", SUBSYSTEMS=="usb", SUBSYSTEMS=="usb", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="002a", GROUP="lp", MODE="0666"

I tried removing the first two items, or changing the ATTRS to ATTR, but none of those worked. I also disabled HP Smart Utility through a Windows machine to no avail.

I'm also attaching the information from udevadm -a -n /dev/usb/lp0 in case someone could spot the fundamental mistakes that I've made. Any help would be appreciated.

udevadm info -a -n /dev/usb/lp0

Udevadm info starts with the device specified by the devpath and then
walks up the chain of parent devices. It prints for every device
found, all possible attributes in the udev rules key format.
A rule to match, can be composed by the attributes of the device
and the attributes from one single parent device.

  looking at device '/devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4:1.0/usbmisc/lp0':
    KERNEL=="lp0"
    SUBSYSTEM=="usbmisc"
    DRIVER==""

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-4/1-4:1.0':
    KERNELS=="1-4:1.0"
    SUBSYSTEMS=="usb"
    DRIVERS=="usblp"
    ATTRS{bInterfaceClass}=="07"
    ATTRS{bInterfaceSubClass}=="01"
    ATTRS{bInterfaceProtocol}=="02"
    ATTRS{bNumEndpoints}=="02"
    ATTRS{supports_autosuspend}=="1"
    ATTRS{bAlternateSetting}==" 0"
    ATTRS{bInterfaceNumber}=="00"
    ATTRS{interface}=="Printer"
    ATTRS{ieee1284_id}=="MFG:Hewlett-Packard;MDL:HP LaserJet Professional P1102;CMD:ZJS,PJL,ACL,HTTP;CLS:PRINTER;DES:HP LaserJet Professional P1102;FWVER:20110526;"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1/1-4':
    KERNELS=="1-4"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="4"
    ATTRS{idVendor}=="03f0"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 2"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="3"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}==" 98mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="c0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="0"
    ATTRS{bcdDevice}=="0100"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="000000000Q84STR3PR1a"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="16"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Hewlett-Packard"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="002a"
    ATTRS{bDeviceClass}=="00"
    ATTRS{product}=="HP LaserJet Professional P1102"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7/usb1':
    KERNELS=="usb1"
    SUBSYSTEMS=="usb"
    DRIVERS=="usb"
    ATTRS{bDeviceSubClass}=="00"
    ATTRS{bDeviceProtocol}=="00"
    ATTRS{devpath}=="0"
    ATTRS{idVendor}=="1d6b"
    ATTRS{speed}=="480"
    ATTRS{bNumInterfaces}==" 1"
    ATTRS{bConfigurationValue}=="1"
    ATTRS{bMaxPacketSize0}=="64"
    ATTRS{authorized_default}=="1"
    ATTRS{busnum}=="1"
    ATTRS{devnum}=="1"
    ATTRS{configuration}==""
    ATTRS{bMaxPower}=="  0mA"
    ATTRS{authorized}=="1"
    ATTRS{bmAttributes}=="e0"
    ATTRS{bNumConfigurations}=="1"
    ATTRS{maxchild}=="8"
    ATTRS{bcdDevice}=="0307"
    ATTRS{avoid_reset_quirk}=="0"
    ATTRS{quirks}=="0x0"
    ATTRS{serial}=="0000:00:1d.7"
    ATTRS{version}==" 2.00"
    ATTRS{urbnum}=="52"
    ATTRS{ltm_capable}=="no"
    ATTRS{manufacturer}=="Linux 3.7.5-1-ARCH ehci_hcd"
    ATTRS{removable}=="unknown"
    ATTRS{idProduct}=="0002"
    ATTRS{bDeviceClass}=="09"
    ATTRS{product}=="EHCI Host Controller"

  looking at parent device '/devices/pci0000:00/0000:00:1d.7':
    KERNELS=="0000:00:1d.7"
    SUBSYSTEMS=="pci"
    DRIVERS=="ehci_hcd"
    ATTRS{irq}=="23"
    ATTRS{subsystem_vendor}=="0x8086"
    ATTRS{broken_parity_status}=="0"
    ATTRS{class}=="0x0c0320"
    ATTRS{companion}==""
    ATTRS{consistent_dma_mask_bits}=="32"
    ATTRS{dma_mask_bits}=="32"
    ATTRS{local_cpus}=="00000000,00000003"
    ATTRS{device}=="0x27cc"
    ATTRS{uframe_periodic_max}=="100"
    ATTRS{enable}=="1"
    ATTRS{msi_bus}==""
    ATTRS{local_cpulist}=="0-1"
    ATTRS{vendor}=="0x8086"
    ATTRS{subsystem_device}=="0x464c"
    ATTRS{numa_node}=="-1"
    ATTRS{d3cold_allowed}=="1"

  looking at parent device '/devices/pci0000:00':
    KERNELS=="pci0000:00"
    SUBSYSTEMS==""
    DRIVERS==""

Thank you for reading.

Last edited by bowshock (2013-02-21 05:29:50)

Offline

#2 2013-02-12 10:01:39

brebs
Member
Registered: 2007-04-03
Posts: 3,439

Re: [SOLVED] UDEV custom rule for HP P1102

How about the nice & simple:

KERNEL=="lp*", DRIVERS=="usblp", GROUP="lp", MODE="664"

Offline

#3 2013-02-13 12:34:24

bowshock
Member
From: Indonesia
Registered: 2013-02-08
Posts: 26

Re: [SOLVED] UDEV custom rule for HP P1102

Thanks for the reply, but the solution doesn't work. It seems that I'm not the only one with the udev permission change problem. Darn, I thought I was getting close.

Offline

#4 2013-02-13 13:06:48

brebs
Member
Registered: 2007-04-03
Posts: 3,439

Re: [SOLVED] UDEV custom rule for HP P1102

Put the rule I gave into /etc/udev/rules.d/91-local.rules

The filename is crucial, for the rules to be applied in the right order.

If that still doesn't work, google "udev debugging" and get to work wink

Offline

#5 2013-02-14 09:19:38

bowshock
Member
From: Indonesia
Registered: 2013-02-08
Posts: 26

Re: [SOLVED] UDEV custom rule for HP P1102

I finally understand what the problem was. I'm going to explain for those who wants to replicate or test my solution.

The udev rule that brebs has recommended only affects /dev/usb/lp*, and the aforementioned file's permission did indeed change. However, hplip only considers /dev/bus/usb/$BUSNUM/$DEVNUM; therefore, the rule must be altered in order to influence the said filepath.

ATTENTION: Replace both $BUSNUM & $DEVNUM with the numbers obtained from lsusb command.

The following two commands

udevadm info -a -n /dev/bus/usb/$BUSNUM/$DEVNUM
udevadm test $(udevadm info -q path -n /dev/bus/usb/$BUSNUM/$DEVNUM) 2>&1

would tell which SUBSYSTEM that /dev/bus/usb/$BUSNUM/$DEVNUM is using, and in my case it is usb.

Finally, replace the custom udev rule with the appropriate line, which is:

SUBSYSTEM=="usb", ATTRS{idVendor}=="03f0", ATTRS{idProduct}=="002a", GROUP="lp", MODE:="666"

Verify the result using the command below after reloading the udev rules.

ls -l /dev/bus/usb/$BUSNUM/$DEVNUM

If everything goes well, the permission should reflect the result from the manual method.

Last edited by bowshock (2013-02-14 11:15:50)

Offline

Board footer

Powered by FluxBB