[systemd-devel] udev/command/module/service

Colin Guthrie gmane at colin.guthr.ie
Sun Sep 2 07:04:35 PDT 2012

'Twas brillig, and Вечный Студент at 02/09/12 14:47 did gyre and gimble:
> The aim is to use LIRC with lirc_serial module. To get it these operations must take place in a given order:
> - udev must name a serial port
> - serial port must be freed from (built in) kernel serial driver with command 'setserial /dev/ttyS0 uart none'
> - lirc_serial driver must be loaded
> - lircd service must be started
> I have tried to add 'setserial ...' command into udev rule (RUN+=), add lirc_serial module to /etc/modules-load and enable lircd service - all these under systemd - but needed sequence of operation takes place randomly only. Currently I use custom script which I start manually after booting (and, of course, it does work always):
> ~ $ cat `which mylirc.sh`
> #!/bin/bash
> /usr/bin/systemctl stop lircd.service
> /usr/bin/rmmod lirc_serial
> /usr/bin/setserial /dev/ttyS0 uart none
> /sbin/modprobe lirc_serial
> /usr/bin/systemctl start lircd.service
> Can anybody suggest legal systemd/udev way to get needed sequence of operations?

Can you use a templated unit for lircd? e.g. lircd at ttyS0.service,
afterall I presume you have to run a separate licrd for each serial port
you have.

If so, then your licrd at .service file would contain something like:

ExecStartPre=-/usr/bin/rmmod lirc_serial
ExecStartPre=-/usr/bin/setserial /dev/%i uart none
ExecStartPre=-/sbin/modprobe lirc_serial

Not sure it's the most graceful of solutions and if you do have multiple
remotes connected (admittedly a somewhat uncommon setup) then the rmmod
will likely fail).

Still you might be able to do what you need to do with ExecStartPre even
in a non-templated unit that will do what you need it to.



Colin Guthrie

Day Job:
  Tribalogic Limited http://www.tribalogic.net/
Open Source:
  Mageia Contributor http://www.mageia.org/
  PulseAudio Hacker http://www.pulseaudio.org/
  Trac Hacker http://trac.edgewall.org/

More information about the systemd-devel mailing list