Ubuntu: Set the lirc order of devices


I have two remote devices. One USB MCE remote dongle, that I want to use, and a built-in device on my satellite PCI-E card that I neither use or want to.

When things boot up, lirc assigns these devices a /dev/lircX device (where X is a number). Take this dmesg output as an example:

[...] rc rc0: lirc_dev: driver ir-lirc-codec (saa716x) registered at minor = 0  [...] rc rc1: lirc_dev: driver ir-lirc-codec (mceusb) registered at minor = 1  

Above, my MCE remote is under /dev/lirc1. The problem is next time I boot, it'll be /dev/lirc0. This makes configuring applications that much harder.

I want one of these things:

  1. To set my mceusb device as /dev/lirc0 forever, or,
  2. Achieve the same by disabling lirc processing the saa716x device. Note that this is a multi-feature device module that also handles the video for TV streaming.
    Blacklisting saa716x is not an option.
  3. Somehow "put things right" after booting... I've looked into this before but I've no idea how to work out what module a /dev/lircX is, let alone swap them over.

I'm open to anything. You should be able to see what I'm after.

Solution:1 Device naming order changes randomly after rebooting

This is due to the fact that Udev, by design, handles uevents and loads modules in parallel, and thus in an unpredictable order. This will never be “fixed”. You should not rely upon the kernel device names being stable. Instead, create your own rules that make symlinks with stable names based on some stable attributes of the device, such as a serial number or the output of various *_id utilities installed by Udev. See Section 7.4, “Managing Devices” and Section 7.5, “General Network Configuration” for examples.

Source: Linux From Scratch: 7.3. Overview of Device and Module Handling

  1. Check for attributes of target node and its parent nodes

    udevadm info -a /dev/lirc1  
  2. Check the environment variables of the target node (something different that can be used for rule match)

    udevadm info /dev/lirc1  
  3. Create new UDEV rules file

    sudo nano /etc/udev/rules.d/99-lirc-symlinks.rules

    #2 or only setup link for usb device  ACTION=="add", KERNEL=="lirc?", ATTRS{idVendor}=="1934", ATTRS{idProduct}=="5168", SYMLINK+="lirc90"  

    lirc90 which is far away to be reached anyway.

  4. Reload rules

    sudo udevadm control -R  
  5. Trigger event request, replug the USB device or you may need reboot.

    sudo udevadm trigger  
  6. Setup your application to use /dev/lirc90


  • There are many many ways to implement a rule for same device. So I can write another one for USB dongle:

    ACTION=="add", KERNEL=="lirc?", DRIVERS="mceusb", SYMLINK+="lirc90"  
  • KERNELS, SUBSYSTEMS, DRIVERS, ATTRS search the devpath upwards for a matching. see man udev.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »