Problems with lirc serial and autostart.sh

  • EDIT: Solved, no bug, issue was windows line endings

    Today I was setting up my system again with a clean install of Libreelec 9.0.0. I stumbled upon some weird behaviour with Lirc serial and the autostart.sh file.

    System specs are: Core i3 540, 2GB RAM, no dedicated GPU

    The Libreelec wiki tells you to setup Lirc on a serial port as following:

    Quote

    Create a /storage/.config/autostart.sh file with the following content:

    Code
    setserial /dev/ttyS0 uart unknown
    modprobe serial_ir

    This didn't work for me. In an attempt to find out what was going wrong I tried to redirect the output of those two commands to a file. No file was created but now my remote did work.

    I did some further tests to see what was going on. Somehow the two commands only work, if their output is redirect to somewhere else. So my current setup for the autostart.sh file is:

    Code
    python /storage/.config/volume_control.py &
    
    setserial /dev/ttyS0 uart unknown > /dev/null
    modprobe serial_ir > /dev/null

    Redirecting both to /dev/null makes lirc work as expected. :/

    The python command has nothing to do with lirc. It does not need to be redirected though (maybe because it creates no output).

    Also it does not influence the other two as the behaviour is exactly the same without it.

    Here is a full debug log: http://ix.io/1ato


    It obviously is not a critical issue, but something seems to be wrong.

    At least the wiki should be updated IF what I did is the proper fix (I don't believe so)

    Edited once, last by theOehrly (February 13, 2019 at 6:55 PM).

  • could you try to add:

    #!/bin/sh

    as the first line to your autostart.sh file and remove the redirects and see if that fixes something?

    For example:

    Bash
    #!/bin/sh
    (
    setserial /dev/ttyS0 uart unknown
    modprobe serial_ir
    )&

    if you don't use parantheses before and after the commands the startup process will be hold until those commands have been finished. Adding them and use the "&" after them causes the commands to be run in background.

  • EDIT: Now it works. Need to find out why

    Just tried, it doesn't help. The redirects are still required to make it work.

    New Debug Log: http://ix.io/1az8 (looks basically the same to me)

    Content of the autostart.sh file:

    Bash
    #!/bin/sh
    
    python /storage/.config/volume_control.py &
    
    (
    setserial /dev/ttyS0 uart unknown
    modprobe serial_ir
    )&
  • From the logfiles it looks like you created the autostart.sh file with Windows line endings, which causes all sorts of weird errors.

    Use nano or vi on your LibreELEC box or Notepad++ on Windows and make sure you save the file with Unix line endings.

    so long,

    Hias

  • Yes, that was the issue. I had created it with Notepad++ and copied it over to Samba network folder for convenience reasons at first. But I had not specifically set it to Unix line endings.

    I had thought of that problem at some point and deleted the content of the file and manually retyped it in nano over ssh but I never deleted the file completely. So nano kept the windows line endings....

    Now after deleting and recreating it with nano everything is fine. I'm sorry, a bit of a stupid mistake.