Mailing List Archive

lirc woes with serial_ir kernel module
At some point Fedora dropped the lirc_serial module in favor of the
serial_ir module and while I can make it work, I haven't found the right
incantation to make it work on boot without manual intervention.

My initial attempts were to update /etc/modprobe.d/lirc.conf to:

# Lirc module settings, /dev/ttyS0
options serial_ir type=0 irq=4 io=0x3f8

Unfortuantely it won't work properly on boot because "setserial /dev/ttyS0
uart none" needs to be run first, otherwise you get:

# dmesg | grep serial_ir
[ 1.730353] serial_ir serial_ir.0: port 03f8 already in use
[ 1.730399] serial_ir serial_ir.0: use 'setserial /dev/ttySX uart none'
[ 1.730400] serial_ir serial_ir.0: or compile the serial port driver as
module and
[ 1.730401] serial_ir serial_ir.0: make sure this module is loaded first
[ 1.730412] serial_ir: probe of serial_ir.0 failed with error -16

I tried adding the setserial command to /etc/sysconfig/modules but I'm
guessing it doesn't run early enough in the process (I assume the serial_ir
module is loaded from the initrd before setserial is even available).

I've also tried using the code lines for lirc in lirc_options.conf to
replicate the needed order but it doesn't seem to actually get run:

[modinit]
code1 = /usr/sbin/rmmod serial_ir
code1 = /usr/bin/setserial /dev/ttyS0 uart none
code2 = /usr/sbin/modprobe serial_ir

So now every time I reboot my frontend I have to manually perform the above
commands prior to starting lircd or I don't get a working remote.

Any ideas?

Thanks,
Richard
Re: lirc woes with serial_ir kernel module [ In reply to ]
On Thu, Jun 1, 2017 at 3:19 PM, Richard Shaw <hobbes1069@gmail.com> wrote:

> At some point Fedora dropped the lirc_serial module in favor of the
> serial_ir module and while I can make it work, I haven't found the right
> incantation to make it work on boot without manual intervention.
>
> My initial attempts were to update /etc/modprobe.d/lirc.conf to:
>
> # Lirc module settings, /dev/ttyS0
> options serial_ir type=0 irq=4 io=0x3f8
>
> Unfortuantely it won't work properly on boot because "setserial /dev/ttyS0
> uart none" needs to be run first, otherwise you get:
>
> # dmesg | grep serial_ir
> [ 1.730353] serial_ir serial_ir.0: port 03f8 already in use
> [ 1.730399] serial_ir serial_ir.0: use 'setserial /dev/ttySX uart none'
> [ 1.730400] serial_ir serial_ir.0: or compile the serial port driver as
> module and
> [ 1.730401] serial_ir serial_ir.0: make sure this module is loaded first
> [ 1.730412] serial_ir: probe of serial_ir.0 failed with error -16
>
> I tried adding the setserial command to /etc/sysconfig/modules but I'm
> guessing it doesn't run early enough in the process (I assume the serial_ir
> module is loaded from the initrd before setserial is even available).
>
> I've also tried using the code lines for lirc in lirc_options.conf to
> replicate the needed order but it doesn't seem to actually get run:
>
> [modinit]
> code1 = /usr/sbin/rmmod serial_ir
> code1 = /usr/bin/setserial /dev/ttyS0 uart none
> code2 = /usr/sbin/modprobe serial_ir
>
> So now every time I reboot my frontend I have to manually perform the
> above commands prior to starting lircd or I don't get a working remote.
>
> Any ideas?
>

Sorry, no. But, after wasting way to many hours debugging similar issues
when rebuilding my frontends, I switched to a “Flirc” IR receiver. You
basically configure the USB device to emit the right keycodes for your IR
signals, and have zero dependency on lirc, linux kernel, or mythtv config.
If I ever rebuild/replace a frontend, I have no issues, the config is
persisted in the Flirc device, no re-config needed just plug in the usb
device and I’m done.

I think it costs ~ $20. For me, the time saved makes it a no-brainer.
Re: lirc woes with serial_ir kernel module [ In reply to ]
On Thu, 1 Jun 2017 17:19:51 -0500, you wrote:

>At some point Fedora dropped the lirc_serial module in favor of the
>serial_ir module and while I can make it work, I haven't found the right
>incantation to make it work on boot without manual intervention.
>
>My initial attempts were to update /etc/modprobe.d/lirc.conf to:
>
># Lirc module settings, /dev/ttyS0
>options serial_ir type=0 irq=4 io=0x3f8
>
>Unfortuantely it won't work properly on boot because "setserial /dev/ttyS0
>uart none" needs to be run first, otherwise you get:
>
># dmesg | grep serial_ir
>[ 1.730353] serial_ir serial_ir.0: port 03f8 already in use
>[ 1.730399] serial_ir serial_ir.0: use 'setserial /dev/ttySX uart none'
>[ 1.730400] serial_ir serial_ir.0: or compile the serial port driver as
>module and
>[ 1.730401] serial_ir serial_ir.0: make sure this module is loaded first
>[ 1.730412] serial_ir: probe of serial_ir.0 failed with error -16
>
>I tried adding the setserial command to /etc/sysconfig/modules but I'm
>guessing it doesn't run early enough in the process (I assume the serial_ir
>module is loaded from the initrd before setserial is even available).
>
>I've also tried using the code lines for lirc in lirc_options.conf to
>replicate the needed order but it doesn't seem to actually get run:
>
>[modinit]
>code1 = /usr/sbin/rmmod serial_ir
>code1 = /usr/bin/setserial /dev/ttyS0 uart none
>code2 = /usr/sbin/modprobe serial_ir
>
>So now every time I reboot my frontend I have to manually perform the above
>commands prior to starting lircd or I don't get a working remote.
>
>Any ideas?
>
>Thanks,
>Richard

You probably need to be doing things with the systemd unit that starts
lirc. That allows you to run things before lirc is started. I do not
know Fedora at all, but in Mythbuntu 16.04, you create override files
in a subdirectory of /etc/systemd/system to alter the builtin systemd
units. So if the unit for starting lirc is lirc.system, then you
would create a subdirectory lirc.service.d and any *.conf files in
that directory would be read in and used to override the settings in
the main lirc.service file. Here is an example of what I do to
override the standard mythtv-backend.service file:

root@mypvr:/etc/systemd/system/mythtv-backend.service.d# cat
mythtv-backend-override.conf
[Unit]

Wants=mysql.service
After=mysql.service

Wants=dev-dvb-adapter0-frontend0.device
After=dev-dvb-adapter0-frontend0.device
Wants=dev-dvb-adapter1-frontend0.device
After=dev-dvb-adapter1-frontend0.device
Wants=dev-dvb-adapter2-frontend0.device
After=dev-dvb-adapter2-frontend0.device
Wants=dev-dvb-adapter3-frontend0.device
After=dev-dvb-adapter3-frontend0.device

Wants=mnt-rec1.mount
After=mnt-rec1.mount
Wants=mnt-rec2.mount
After=mnt-rec2.mount
Wants=mnt-rec3.mount
After=mnt-rec3.mount
Wants=mnt-rec4.mount
After=mnt-rec4.mount
Wants=mnt-rec5.mount
After=mnt-rec5.mount
Wants=mnt-rec6.mount
After=mnt-rec6.mount
Wants=mnt-rec7.mount
#After=mnt-rec7.mount

Wants=mnt-vid1.mount
Wants=mnt-vid2.mount
Wants=mnt-vid3.mount

Wants=minisatip.service
After=minisatip.service

[Service]
ExecStartPre=-/bin/bash /usr/local/bin/rm.test
StartLimitBurst=10
StartLimitInterval=10s
SendSIGKILL=yes
TimeoutStopSec=10


I think what you would need to do is create a bash script like my
rm.test script and run it from an ExecStartPre line as I am doing.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 02/06/17 00:19, Richard Shaw wrote:

> I've also tried using the code lines for lirc in lirc_options.conf to
> replicate the needed order but it doesn't seem to actually get run:
>
> [modinit]
> code1 = /usr/sbin/rmmod serial_ir
> code1 = /usr/bin/setserial /dev/ttyS0 uart none
> code2 = /usr/sbin/modprobe serial_ir

Hmpf... if the commands above does not run it should be easy to debug:

- lircd.service wants the one-shot lircd-setup.service. 'systemctl
status lircd-setup.service' reveals last time lircd-setup.service ran.
- lircd-setup.service could be run manually as a test: sudo systemctl
start lircd-setuo.service
- lircd-setup.service just runs the /usr/sbin/lircd-setup script.
This can also be run manually without any command line options.
- Adding a code line like '/bin/sh -c "date > /tmp/code3.log"' should
put a simple log mark when lircd-setup runs. Or use logger(1).

If there is a bug, please file it at the lirc upstream http://sf.net/p/lirc


Cheers!

--alec


_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
Stephen Worthington wrote:

> You probably need to be doing things with the systemd unit that starts
> lirc. That allows you to run things before lirc is started.

The issue here is that lircd.service runs as the regular lirc user.
That's the reason for the lircd-setup.service which is run as root
before lircd.service.

Cheers!

--alec
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 01/06/17 23:19, Richard Shaw wrote:
> At some point Fedora dropped the lirc_serial module in favor of the
> serial_ir module and while I can make it work, I haven't found the right
> incantation to make it work on boot without manual intervention.
>
> My initial attempts were to update /etc/modprobe.d/lirc.conf to:
>
> # Lirc module settings, /dev/ttyS0
> options serial_ir type=0 irq=4 io=0x3f8
>
> Unfortuantely it won't work properly on boot because "setserial
> /dev/ttyS0 uart none" needs to be run first, otherwise you get:
>
> # dmesg | grep serial_ir
> [ 1.730353] serial_ir serial_ir.0: port 03f8 already in use
> [ 1.730399] serial_ir serial_ir.0: use 'setserial /dev/ttySX uart none'
> [ 1.730400] serial_ir serial_ir.0: or compile the serial port driver
> as module and
> [ 1.730401] serial_ir serial_ir.0: make sure this module is loaded first
> [ 1.730412] serial_ir: probe of serial_ir.0 failed with error -16
>
> I tried adding the setserial command to /etc/sysconfig/modules but I'm
> guessing it doesn't run early enough in the process (I assume the
> serial_ir module is loaded from the initrd before setserial is even
> available).
>

There is an `install` option you can use in the modprobe configuration
which allows you to specify what to run.

In this case you could use it to first run setserial, and then modprobe
serial_ir

see `man modprobe.conf` for details


Regards
Stuart

> I've also tried using the code lines for lirc in lirc_options.conf to
> replicate the needed order but it doesn't seem to actually get run:
>
> [modinit]
> code1 = /usr/sbin/rmmod serial_ir
> code1 = /usr/bin/setserial /dev/ttyS0 uart none
> code2 = /usr/sbin/modprobe serial_ir
>
> So now every time I reboot my frontend I have to manually perform the
> above commands prior to starting lircd or I don't get a working remote.
>
> Any ideas?
>
> Thanks,
> Richard
>
>
> _______________________________________________
> mythtv-users mailing list
> mythtv-users@mythtv.org
> http://lists.mythtv.org/mailman/listinfo/mythtv-users
> http://wiki.mythtv.org/Mailing_List_etiquette
> MythTV Forums: https://forum.mythtv.org
>

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 02/06/17 11:56, Stuart Auchterlonie wrote:
> On 01/06/17 23:19, Richard Shaw wrote:
>> At some point Fedora dropped the lirc_serial module in favor of the
>> serial_ir module and while I can make it work, I haven't found the right
>> incantation to make it work on boot without manual intervention.
>>
>> My initial attempts were to update /etc/modprobe.d/lirc.conf to:
>>
>> # Lirc module settings, /dev/ttyS0
>> options serial_ir type=0 irq=4 io=0x3f8
>>
>> Unfortuantely it won't work properly on boot because "setserial
>> /dev/ttyS0 uart none" needs to be run first, otherwise you get:
>>
>> # dmesg | grep serial_ir
>> [ 1.730353] serial_ir serial_ir.0: port 03f8 already in use
>> [ 1.730399] serial_ir serial_ir.0: use 'setserial /dev/ttySX uart none'
>> [ 1.730400] serial_ir serial_ir.0: or compile the serial port driver
>> as module and
>> [ 1.730401] serial_ir serial_ir.0: make sure this module is loaded first
>> [ 1.730412] serial_ir: probe of serial_ir.0 failed with error -16
>>
>> I tried adding the setserial command to /etc/sysconfig/modules but I'm
>> guessing it doesn't run early enough in the process (I assume the
>> serial_ir module is loaded from the initrd before setserial is even
>> available).
>>
>
> There is an `install` option you can use in the modprobe configuration
> which allows you to specify what to run.
>
> In this case you could use it to first run setserial, and then modprobe
> serial_ir
>
> see `man modprobe.conf` for details
>

Oh and you probably need to rebuild your initrd as there is some
modprobe work done in the initrd (primarily for storage drivers etc)

Regards
Stuart

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 02/06/17 07:55, Alec Leamas wrote:

> - Adding a code line like '/bin/sh -c "date > /tmp/code3.log"' should
> put a simple log mark when lircd-setup runs. Or use logger(1).


Looking at the code, the /bin/sh -c"" envelope is not required, a plain
"date > /tmp/code3.log" should do it. It's invoked using /bin/sh -c ...

The manpage could be more clear on this.

--alec
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
Ahh... the plot thickens...

# lircd-setup
Cannot parse file /etc/lirc/lirc_options.conf

But I can't see anything obvious it's choking on...

# cat /etc/lirc/lirc_options.conf
# These are the default options to lircd, if installed as
# /etc/lirc/lirc_options.conf. See the lircd(8) and lircmd(8)
# manpages for info on the different options.
#
# Some tools including mode2 and irw uses values such as
# driver, device, plugindir and loglevel as fallback values
# in not defined elsewhere.

[lircd]
nodaemon = False
driver = default
device = auto
output = /var/run/lirc/lircd
pidfile = /var/run/lirc/lircd.pid
plugindir = /usr/lib64/lirc/plugins
permission = 666
allow-simulate = No
repeat-max = 600
#effective-user = lirc
effective-user = root
#listen = [address:]port
#connect = host[:port]
#loglevel = 6
#uinput = ...
#release = ...
#logfile = ...

[lircmd]
uinput = False
nodaemon = False

[modinit]
code1 = /usr/sbin/rmmod serial_ir
code1 = /usr/bin/setserial /dev/ttyS0 uart none
code2 = /usr/sbin/modprobe serial_ir

# [lircd-uinput]
# release-timeout = 200

---

Thanks,
Richard
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 02/06/17 14:27, Richard Shaw wrote:
> Ahh... the plot thickens...
>
> # lircd-setup
> Cannot parse file /etc/lirc/lirc_options.conf

> [modinit]
> code1 = /usr/sbin/rmmod serial_ir
> code1 = /usr/bin/setserial /dev/ttyS0 uart none
> code2 = /usr/sbin/modprobe serial_ir


That was not the best error message, for sure. But each key needs to be
unique, you cannot have two code1. Will check in a patch with an
enhanced message

--alec
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
Hoi Alec,

Friday, June 2, 2017, 6:24:33 PM, you wrote:

> On 02/06/17 14:27, Richard Shaw wrote:
>> Ahh... the plot thickens...
>>
>> # lircd-setup
>> Cannot parse file /etc/lirc/lirc_options.conf

>> [modinit]
>> code1 = /usr/sbin/rmmod serial_ir
>> code1 = /usr/bin/setserial /dev/ttyS0 uart none
>> code2 = /usr/sbin/modprobe serial_ir


> That was not the best error message, for sure. But each key needs to be
> unique, you cannot have two code1. Will check in a patch with an
> enhanced message

> --alec
> _______________________________________________

Why not instead of failing, taking the first or last occurrence and
adding a message to the log "Ignoring second occurrence of ....". It's
more friendly by not failing and still clear.


Tot mails,
Hika mailto:hikavdh@gmail.com

"Zonder hoop kun je niet leven
Zonder leven is er geen hoop
Het eeuwige dilemma
Zeker als je hoop moet vernietigen om te kunnen overleven!"

De lerende Mens

_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 02/06/17 18:37, Hika van den Hoven wrote:
_______
>
> Why not instead of failing, taking the first or last occurrence and
> adding a message to the log "Ignoring second occurrence of ....". It's
> more friendly by not failing and still clear.

Partly because this is using the standard python ConfigParser which
doesn't easily lend itself to such things.

And partly because trying to understand the user's intent in cases like
this too easily leads to madness. There are reasons compilers fails even
for simple errors like a missing semicolon rather then trying to guess
what should be there.

The patch I just checked in generates the correct error message:
"while reading from 'foo.conf' [line 34]: option 'code1' in section
'modinit' already exists". IMHO, this is the proper fix. The message is
generated by ConfigParser, so it's not only for this case.


Cheers!

--alec
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 02/06/17 08:27 AM, Richard Shaw wrote:
> Ahh... the plot thickens...
>
> # lircd-setup
> Cannot parse file /etc/lirc/lirc_options.conf
>
> But I can't see anything obvious it's choking on...
>
> # cat /etc/lirc/lirc_options.conf
> # These are the default options to lircd, if installed as
> # /etc/lirc/lirc_options.conf. See the lircd(8) and lircmd(8)
> # manpages for info on the different options.
> #
> # Some tools including mode2 and irw uses values such as
> # driver, device, plugindir and loglevel as fallback values
> # in not defined elsewhere.
>
> [lircd]
> nodaemon = False
> driver = default
> device = auto
> output = /var/run/lirc/lircd
> pidfile = /var/run/lirc/lircd.pid
> plugindir = /usr/lib64/lirc/plugins
> permission = 666
> allow-simulate = No
> repeat-max = 600
> #effective-user = lirc
> effective-user = root
> #listen = [address:]port
> #connect = host[:port]
> #loglevel = 6
> #uinput = ...
> #release = ...
> #logfile = ...
>
> [lircmd]
> uinput = False
> nodaemon = False
>
> [modinit]
> code1 = /usr/sbin/rmmod serial_ir
> code1 = /usr/bin/setserial /dev/ttyS0 uart none
> code2 = /usr/sbin/modprobe serial_ir
>
> # [lircd-uinput]
> # release-timeout = 200
>
> ---
>
> Thanks,
> Richard
>
I'm not sure what's up with lirc[d]'s conf file handling, but I've had a
couple times over the years where it just wouldn't read it. Looked for
invalid characters, deleted lines, finally re-create the file from
scratch, and voila, it works.
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
On 11/06/17 20:08, Andrew Stadt wrote:
> On 02/06/17 08:27 AM, Richard Shaw wrote:
>> Ahh... the plot thickens...
>>
>> # lircd-setup
>> Cannot parse file /etc/lirc/lirc_options.conf
>>
>> But I can't see anything obvious it's choking on...

>> [modinit]
>> code1 = /usr/sbin/rmmod serial_ir
>> code1 = /usr/bin/setserial /dev/ttyS0 uart none


It's a bad error message...

--alec
_______________________________________________
mythtv-users mailing list
mythtv-users@mythtv.org
http://lists.mythtv.org/mailman/listinfo/mythtv-users
http://wiki.mythtv.org/Mailing_List_etiquette
MythTV Forums: https://forum.mythtv.org
Re: lirc woes with serial_ir kernel module [ In reply to ]
And just to close the thread, after I numbered the "code" entries correctly
all is well again.

Thanks,
Richard