linuxprintinglsusb

Obtaining information about /dev/usb/lp* devices


I have a problem obtaining information about /dev/usb/lp* devices.

The lsusb command gives me USB bus and device IDs, and a name of the device but I can't figure out how to get it to tell me the name of the corresponding /dev/usb/lp* device.

I don't have CUPS available.


Solution

  • You can use libudev to get the equivalent of the following command:

    $ udevadm info -a /dev/usb/lp*
    

    In my PC it prints something like:

      looking at device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3:1.1/usbmisc/lp2':
        KERNEL=="lp2"
        SUBSYSTEM=="usbmisc"
        DRIVER==""
    
      looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3:1.1':
        KERNELS=="1-1.3:1.1"
        SUBSYSTEMS=="usb"
        DRIVERS=="usblp"
        ...
    
      looking at parent device '/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3':
        KERNELS=="1-1.3"
        SUBSYSTEMS=="usb"
        DRIVERS=="usb"
        ...
        ATTRS{idProduct}=="341b"
        ATTRS{idVendor}=="04e8"
        ...
    

    And there they are! The wanted idProduct and the idVendor

    You can also get the information by navigating the /sys directory manually:

    $ ls -l /dev/usb/lp2
    crw-rw---- 1 root lp 180, 2 Sep 27 11:46 /dev/usb/lp2
    
    $ readlink -f /sys/dev/char/180:2
    /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/1-1.3:1.1/usbmisc/lp2
    
    $ cat /sys/devices/pci0000:00/0000:00:1a.0/usb1/1-1/1-1.3/{idVendor,idProduct}
    04e8
    341b