USB-UIRT configuration

  • Hi, has anyone configured the USB-UIRT with LibreELEC?

    It seems to be found by the kernel:
    [ 25.789146] usb 2-1: FTDI USB Serial Device converter now attached to ttyUSB0
    And I can get lirc to work with :
    LIRCD_OPTIONS="-H uirt2_raw -d /dev/ttyUSB0"
    And I do see data coming from it:
    mode2 --driver=uirt2_raw --device=/dev/ttyUSB0
    space 1312950
    pulse 8900
    space 4300
    pulse 600

    However irkeytable fails with a /sys/class/rc/: No such file or directory.
    I'm thinking this is because the USBUIRT does not have a evdev driver, but was wondering if there was any other way to get it to work within the LibreELEC system?

    Thanks.

    --- Bill

  • Can you do a test with the latest Milhouse build?
    LibreELEC Testbuilds for RaspberryPi (Kodi 18.0)

    LE9 adds support for setting lircd options via /storage/.config/lirc_options.conf and thus make it a lot easier to configure the driver and device (just copy /etc/lircd/lirc_options.conf to the .config dir and change driver= and device=).

    You might also need to create a /storage/.config/lircd.conf file, by default lircd is configured to support MCE and xbox remote codes.

    BTW: with userspace lirc you won't use ir-keytable, configuration is handled by lircd.conf and lirc_options.conf.

    so long,

    Hias

  • @Hias: that support would be helpful. I will test it soon. In the meantime I was able to get it to work in Krypton. I'm not sure if this is the proper way to get one of these old non-event devices working but here's what I did in case it is helpful to somebody else.

    Code
    cd /storage

    Get aremote profile that matches what you are using. I used the one below since it most closely resembled the default kodi default config. In my URC-R50 remote I just use one of the Windows remote profiles.

    Code
    wget https://sourceforge.net/p/lirc-remotes/code/ci/master/tree/remotes/microsoft/Xbox.lircd.conf?format=raw -O lircd.conf.orig

    Oddly this did not match the one for Xbox in /etc/lircd. Anyway to avoid modifying the kodi configuration I removed the KEY prefix from this lircd file because the default Lircmap.xml in Kodi refers to the Xbox codes without KEY.

    Code
    sed 's/KEY_//' < lircd.conf.orig > lircd.conf

    I also added a "suppress_repeat 5" at the begininng of my lircd.conf because autorepeat was going too fast.

    Then I just set it to autostart automatically.

    Code
    cd .config
    cat > autostart.sh <<xxEOFxx
      #!/bin/sh
      ( systemctl stop eventlircd ; \
        lircd -n -d /dev/ttyUSB0 --driver=uirt2_raw /storage/lircd.conf ; \
      ) &
    xxEOFxx
    chmod +x autostart.sh

    Not sure if that's the best way to do things in the current version but it works for me, and I saved $20 by not having to buy a flirc :)

  • Hi I tried the latest Milhouse build May 8th (for x86 not pi) and it does not seem to work for overriding lircd parameters -- well at least for the startup which is what I need to do. To debug I created a ./config/lirc_options.conf which was identical to the one in /etc/lirc
    but changing
    output = /run/lirc/lircd.socket2

    and only /run/lirc/lircd.socket was created (no "2").

    If I try connecting to ircd.socket it just gives a connection reset error.
    /run/lirc/lircd is there as well and I can connect to it (and that is what kodi is configured for), but there is no output when I press buttons on the remote.

    lircd itself doesn;t seem to run, as in v8.0.1. eventlircd is running instead . I'm not familiar with how to debug that.
    If I stop eventlircd and run
    lircd -n -d /dev/ttyUSB0 --driver=uirt2_raw /storage/.config/lircd.conf

    Then I see all my codes if I use " irw //run/lirc/lircd.socket "(btw I think the old default was /run/lirc/lircd (without the .socket).

    If anyone wants me to do any more tests I'll stay on this build for a few days. Just let me know. I would be nice to get it to work without an autostart.


  • To debug I created a ./config/lirc_options.conf which was identical to the one in /etc/lirc
    but changing
    output = /run/lirc/lircd.socket2

    and only /run/lirc/lircd.socket was created (no "2").


    The socket is the one thing you shouldn't change in lirc_options.conf - it's managed by systemd. Actually lircd is a socket managed service, systemd creates the socket and when the first client, lircd-uinput in this case, connects to it systemd will start lircd - that's exactly the same setup as in other linux distributions.

    I'd also recommend to keep eventlircd running, this picks up the input events generated by lircd-uinput, translates these again into lirc events and feeds them to the standard lirc socket which is used by kodi.

    You could change the kodi startup to use the /run/lirc/lircd.socket directly, but then kodi can't be controlled by other IR remotes (eg USB IR receivers which send out input events).

    Yes, the setup is rather awkward, but as kodi doesn't play too well with linux input events it's currently the only way to support all remotes in kodi.

    so long,

    Hias

  • I don't see lircd-uinput running. I changed back to the default and now I have.


    But nothing works. irw just shows nothing when I press remote keys, and the log file is not created. There is no pid file and lircd itself is not running.

    ├─kodi.service
    │ ├─626 /bin/sh /usr/lib/kodi/kodi.sh --standalone -fs --lircdev /run/lirc/lircd
    │ └─631 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /run/lirc/lircd
    ├─eventlircd.service
    │ └─263 /usr/sbin/eventlircd -f --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd

    LibreELEC:/run/lirc # pidof lircd
    LibreELEC:/run/lirc # pidof lircd-uinput

    Removing both lircd.conf and lirc_options.conf from ./config does not change anything.

    Again,what I am trying to emulate is
    lircd -d /dev/ttyUSB0 --driver=uirt2_raw /storage/.config/lircd.conf

    Which works fine if I start it from autostart.sh , and stop eventlircd beforehand. I can keep it that way, just trying to see if there was a more supportable way to do it.

  • Did you enable lircd in LE settings?

    Just did a quick test, Milhouse build 0508 on RPi3, with some FTDI serial dongle, a lircd.conf file in .config and this lirc_options.conf and it worked fine:

    lircd and lircd-uinput started up fine:

    Code
    349 root       2:54 /usr/sbin/lircd -O /storage/.config/lirc_options.conf --nodaemon --release /storage/.config/lircd.conf
      350 root       0:00 /usr/sbin/lircd-uinput -O /storage/.config/lirc_options.conf

    But of course lircd was logging errors because there was no UIRT2 adapter connected:

    so long,

    Hias

  • First, thanks again Hias for all your help. I was able to get it to work and learn a lot about how libreelec and kodi work. I had to change the kodi startup to listen on /run/lirc/lircd.socket rather than /run/lircd/lircd.
    My problem was that since lircd is managed by systemd it always creates this socket even if you tell the lircd.conf to use a different socket. Kodi unfortunately always listens to /run/lirc/lircd and it does not appear to have a simple configuration file to change this, so I had to change its startup script. Here is the complete procedure that I followed in Millhouse.

    1. Enabled lirc in Settings->libreelect->services->Enable lirc
    2. Create ./config/lircd.conf with the configuration for the non-ev remote, possibly downloading the configration from lirc-remotes
    3. Create ./config/lirc_options with the configuration needed for the remote. In my case I had to change device and driver.
    4. Copy /usr/lib/kodi/kodi-config to /storage/.config/ and modify this file making KODI_ARGS="--lircdev /run/lirc/lircd.socket" Make sure the execute bit is set.
    5. and copy /usr/lib/systemd/system/kodi.service to /storage/.config/system.d/kodi.service and modify this file so that the script in step 4 is executed, by making ExecStartPre=-/storage/.config/kodi-config


    I hope this is the right way to do it. My concern with this method over just having an autostart.sh is that I have to make copies of kodi-config and kodi.service, and therefore may not maintain currency with future changes. If there was a supported way to change KODI_ARGS I suppose thatmight be better. Maybe remove it entirely from the kodi-config and just let the systemd startup set it -- that way I only have to do Environment=KODI_ARGS="--lircdev /run/lirc/lircd.socket", but right now the kodi-startup will override it.
    Also deleting /run/lirc/lircd and making a hardlink to /run/lirc/lircd.socket also works to avoid copying the startup files, but then I have to go back to using autostart.sh -- maybe not be so bad anyway since I think I still need to use autostart to change the wakeup-power options so I can resume kodi from S3 sleep using the remote.

    Thanks again.

  • In LE9 / Milhouse builds I'd recommend sticking to the stock configuration: only enable lirc in settings, and setup lircd.conf and lirc_options.conf (with driver and device) in .config, leave everything else as it is.

    In general there's no need to change the lircd socket used by kodi. LE setup (with eventlircd running in background) will take care of bridging the remote events into kodi.

    If something's not working as expected with that setup please report here, we'll then have a look at it and try to fix it.

    so long,

    Hias

    Edited once, last by HiassofT (May 14, 2017 at 10:01 AM).

  • Hi Hias, the problem that I have with Millhouse is that /usr/lib/kodi/kodi-config has the hardcoded line:
    KODI_ARGS="--lircdev /run/lirc/lircd"
    So Kodi is always listending to /run/lirc/lircd.

    Systemd is managing lircd and creating /run/lirc/lircd.socket. All the IR codes from lircd are getting sent to /run/lirc/lircd.socket and not /run/lirc/lircd (where kodi is listening) so kodi never receives any codes. If you do irw /run/lirc/lircd nothing ever comes out. I do see eventlircd running in the background configured to use /run/lirc/lircd but again nothing is seen by kodi and irw /run/lirc/lircd gives no output.

    Changing "output" in lirc_options.conf to /run/lirc/lircd instead of lircd.socket does not work either, because systemd keeps creating /run/lirc/lircd.socket.

    You should be able to reproduce this with a remote that is not supported by the kernel, such as the USB UIRT.

    Possibly remove the hardcoding of KODI_ARGS and allow it to be set in ./config/systemd/kodi.service, or change whatever is making systemd create/require the lircd.socket, or let me know how I should troubleshoot eventlircd because it does not seem to be sending anything to /run/lirc/lircd when the codes are being received by lircd.

    LibreELEC:/run/lirc # ps -aef | grep lirc
    269 root 0:00 /usr/sbin/eventlircd -f --evmap=/etc/eventlircd.d --socket=/run/lirc/lircd
    294 root 0:00 /usr/sbin/lircd -O /storage/.config/lirc_options.conf --nodaemon --release /storage/.config/lircd.conf
    298 root 0:00 /usr/sbin/lircd-uinput -O /storage/.config/lirc_options.conf
    637 root 0:00 {kodi.sh} /bin/sh /usr/lib/kodi/kodi.sh --standalone -fs --lircdev /run/lirc/lircd
    642 root 0:42 /usr/lib/kodi/kodi.bin --standalone -fs --lircdev /run/lirc/lircd

    LibreELEC:~/.config # cat lirc_options.conf
    [lircd]
    nodaemon = False
    driver = uirt2_raw
    device = /dev/ttyUSB0
    output = /run/lirc/lircd.socket
    pidfile = /run/lirc/lircd.pid
    plugindir = /usr/lib/lirc/plugins
    permission = 666
    allow-simulate = No
    repeat-max = 600
    #effective-user =
    #listen = [address:]port
    #connect = host[:port]
    #loglevel = 6
    #uinput = ...
    #release = ...
    logfile = /var/log/lircd.log

    LibreELEC:~/.config # irw /run/lirc/lircd.socket
    0000000000559aa6 00 UP Microsoft_Xbox
    0000000000559aa6 00 UP_EVUP Microsoft_Xbox
    0000000000558aa7 00 DOWN Microsoft_Xbox
    0000000000558aa7 00 DOWN_EVUP Microsoft_Xbox
    0000000000557aa8 00 RIGHT Microsoft_Xbox
    0000000000557aa8 00 RIGHT_EVUP Microsoft_Xbox
    0000000000556aa9 00 LEFT Microsoft_Xbox
    0000000000556aa9 00 LEFT_EVUP Microsoft_Xbox

    LibreELEC:~/.config # irw /run/lirc/lircd
    [ no output]


  • This is quite certainly the culprit. You should use KEY_UP, KEY_DOWN etc in lircd.conf, not only "UP", "DOWN", ...

    Can you change your lircd.conf so that the keynames match the officially supported ones?
    See linux/input-event-codes.h at master · torvalds/linux · GitHub

    BTW: You can also get a list of supported keynames by running "irrecord -l"

    so long,

    Hias

  • That works! Thanks for all your help. Back up in post #3 I mentioned that I had removed the KEY_ prefix from the codes downloaded from lirc-remotes download | SourceForge.net. I did this because I thought I should send and receive codes via Microsoft_Xbox and those codes in the /usr/share/kodi/system/Lircmap.xml just have UP,DOWN,LEFT,RIGHT ,etc...
    I didn't realize that if I left eventlircd running then the codes would get transferred to "devinput" rather than Xbox, and the devinput codes do have the KEY prefix.
    It is a bit confusing :)
    Thanks!


  • That works! Thanks for all your help. Back up in post #3 I mentioned that I had removed the KEY_ prefix from the codes downloaded from lirc-remotes download | SourceForge.net.


    Ah, sorry, I had missed that before...

    But I'm glad you got it working, and thanks a lot for the feedback!

    As for key naming: using non-standard key names is deprecated for quite some time now. Lircd still accepts arbitrary key names, but eg irrecord will refuse key names that aren't standard when creating a new lircd.conf.

    The standard naming scheme makes it a lot easier for programs to support remotes, especially via lirc sockets. Before people could eg configure the volume keys to generate VOLUME_UP, VOLUMEUP, VOLUP etc which led to quite a mess :)

    so long,

    Hias