irserver add-on

  • My HTPC case is an OrigenAE S16V which contains a LCD/IR module (model "VF210") and requires the IRTrans driver to work.

    I noticed irserver (= IRTrans driver) is missing from LibreElec 8+ installation.
    I found this pull request explaining this. The conversation suggests an add-on would be created to replace the package. I have not been able to find this add-on...

    Can anyone help? Please.

    P.S.: I am new to LibreElec but have been using OpenElec for many years (until the Krypton upgrade messed up my config). LCD/IR module has been working perfectly with OpenElec (even after the Krypton upgrade).

    Edited once, last by apa (April 30, 2017 at 5:47 PM).

  • I'm trying to find out exactly what needs to happen to get irserver to work again (hoping this might be of value to anyone wanting to create an add-on for this). This is what I found out so far:

    • Download IRTrans server package from here.
    • Unpack IRTrans server package into /storage/.kodi/userdata/irtrans.
    • Modify the (binary) irserver64 using the vi text-editor and replace "xbmc.bin" by "kodi.bin". irserver looks for xbmc.bin in the list of running processes to enable its XBMC features. This little hack will make it look for kodi.bin instead...
      A cleaner approach would be to modify the irserver source-code and rebuild.
    • Execute the various chmod commands in-place (in /storage/.kodi/userdata/irtrans) in the same way as the "install.sh" script would.
    • Find out the device-name for IRTrans USB device (in my case, this was /dev/ttyUSB0).
      With OpenElec, I used /dev/irtrans0. This seems to have been a re-direct that was implemented in some script: it is not the name of your actual device.
    • Start irserver with the following command: ./irserver64 -logfile /var/log/irserver.log -pidfile /var/run/irserver.pid -daemon /dev/ttyUSB0

    A "ps -d | grep irserver" confirmed irserver was running.
    I created a /storage/.config/autostart.sh to start irserver with the above command. A reboot confirmed this to work.

    By this point, the VFD seems operational.
    The IR remote, however, still does not work.

    Next steps would be:

    • Disable LIRC daemon and tools since IRTrans seems to emulate LIRC (i.e. they cannot co-operate).
    • Modify the /run/libreelec/kodi.conf so KODI_ARGS directs Kodi to use the emulated LIRC daemon (lircd.irtrans) instead of the regular lircd.
      I tried modifying the kodi.conf from autostart.sh, but that does not seem to work (it did previously work with OpenElec): kodi.conf gets modified after autostart.sh (presumably by the script that launches Kodi?!).

    I hope that will be all?!
    Any help would be greatly appreciated!

    Edited once, last by apa (April 24, 2017 at 6:48 AM).

  • I got IRTrans working with LibreElec 8.0.1!
    I do not have the necessary expertise to turn this into an addon (yet), but I can explain what I did: hopefully this can help someone make an addon out of it...

    First, some background:

    • Kodi uses an API called LIRC to communicate with remotes. This API abstracts the actual hardware so that Kodi developers wouldn't have to bother with low-level communication with the hardware (which would require specific code per hardware implementation).
    • The LIRC API is exposed through a socket and requires a daemon/service to host that socket (and communicate with the underlying hardware).
      In the past, lircd was used for this purpose. lircd relies on drivers for the specific hardware implementation.
      Recent Linux kernels make it possible to use some IR remotes as regular input devices (without LIRC). eventlircd is currently used by OpenElec/LibreElec to expose these input devices as LIRC devices (and relies on the hardware-support baked into the Linux kernel).
    • IRTrans devices are not directly supported by the Linux kernel, hence they cannot be used through eventlircd. Interaction with IRTrans devices is performed through the irserver daemon/service. This irserver daemon/service can itself host a socket with support for the LIRC API.
      This means that IRTrans neither requires nor supports lircd or eventlircd!

    Steps to get IRTrans devices working on LibreElec:

    • Get the irserver package, copy it into /storage/.config/ on your LibreElec system and make sure it is executable (chmod +x irserver).
      The official version from the IRTrans website uses the same LIRC socket (/run/lirc/lircd) as eventlircd that comes with OpenElec/LibreElec and can therefore not be used alongside it.
      A custom version of irserver was previously distributed with LibreElec (and is still distributed with OpenElec) which uses a different socket (/run/lirc/lircd.irtrans) and can be used alongside eventlircd. I grabbed the compiled binary from my old OpenElec box (/usr/sbin/irserver). Make sure you also grab the remotes-files from /usr/share/irtrans/remotes/ on OpenElec and put them into /storage/.config/remotes/ on your LibreElec system.
    • Determine your device-name.
      This would typically be something like /dev/ttyUSB0. Unfortunately, USB device-names tend to change as hardware is modified. I have read reports of device-names changing as users inserted memory-cards or USB sticks.
      There is a way to dynamically find the device-name and create a symlink to it by defining appropriate udev.d rules. Create a file /etc/udev/rules.d/81-irtrans.rules with this content: it will create a symlink named /dev/irtrans0.
    • Create/modify /storage/.config/autostart.sh and add the following line to it: ./irserver -logfile /var/log/irserver.log -pidfile /var/run/irserver.pid - daemon /dev/irtrans0 and make sure it is executable (chmod +x autostart.sh).
    • Instruct Kodi to listen on the alternate LIRC socket (/run/lirc/lircd.itrans) by changing the Kodi command-line parameter with which it is launched.
      To do this, copy /usr/lib/kodi/kodi-config to /storage/.config/. Edit /storage/.config/kodi-config and replace the line reading KODI_ARGS="--lircdev /run/lirc/lircd" with the following

      Code
      if [ -e /run/lirc/lircd.irtrans ]; then
      KODI_ARGS="--lircdev /run/lirc/lircd.irtrans"
      else
      KODI_ARGS="--lircdev /run/lirc/lircd"
      fi


      This way, Kodi will only listen to /run/lirc/lircd.irtrans if it exists (and fallback to /run/lirc/lircd otherwise). Make sure to make /storage/.config/kodi-config executable (chmod +x kodi-config).
      Now copy /usr/lib/systemd/system/kodi.service to /storage/.config/system.d/kodi.service. Modify /storage/.config/system.d/kodi.service and change the line ExecStartPre=-/usr/lib/kodi/kodi-config to ExecStartPre=-/storage/.config/kodi-config. This will instruct LibreElec to launch your custom kodi-config instead of the default one.

    • In Kodi, install the add-on LCDProc from the LibreElec reposiroty and configure it to use the "irtrans" driver.
    • In Kodi, install the add-on "XBMC LCDProc" from the Kodi repository and configure it to use a remote connection to 127.0.0.1 and port 13666.
    • Reboot.
  • Addendum for LE9 (for whom this may concern):

    Found out that "--lircdev" parameter has been removed from KODI Leia. Instead, of the "kodi-config" step from my previous post above, you now need to modify /storage/.config/system.d/kodi.service and add the following line:

    Environment="LIRC_SOCKET_PATH=/var/run/lirc/lircd.irtrans"

    Add this as the first line in the [Service] domain of kodi.service.

  • Addendum for LE10 (again: for whom this may concern).

    Lost audio after upgrading to LE10. This appears to be caused by PulseAudio (I'm assuming PulseAudio somehow got enabled since LE10). I could get the audio to work again by launching LE10 with the following command:

    Code
    pasuspender -- env KODI_AE_SINK=ALSA /usr/lib/kodi/kodi.sh --standalone -fs

    That, however, caused the irtrans remote to stop working.

    To resolve this, I modified /storage/.config/system.d/kodi.service as follows

    Note the added line below [Service]:

    Code
    Environment=KODI_AE_SINK=ALSA

    As well as the modified line ExecStart:

    Code
    ExecStart=pasuspender -- /usr/lib/kodi/kodi.sh --standalone -fs $KODI_ARGS $KODI_DEBUG