You are not logged in.

#1 2012-09-02 09:26:03

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 616

[solved] udev/command/module/service

The story started here: https://bbs.archlinux.org/viewtopic.php?id=147745 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?

Last edited by student975 (2012-09-02 14:29:47)


"I exist" is the best myth I know..

Offline

#2 2012-09-02 14:29:24

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 616

Re: [solved] udev/command/module/service

Have got solutions here: systemd-devel@lists.freedesktop.org - just use ExecStartPre:

~ $ cat /etc/systemd/system/lircd.service 
[Unit]
Description=LIRC Daemon
After=network.target

[Service]
Type=forking
EnvironmentFile=/etc/conf.d/lircd.conf
PIDFile=/run/lirc/lircd.pid

ExecStartPre=/usr/bin/setserial /dev/ttyS0 uart none
ExecStartPre=/sbin/modprobe lirc_serial

ExecStartPre=/bin/mkdir -p /run/lirc
ExecStartPre=/bin/rm -f /dev/lircd
ExecStartPre=/bin/rm -f /run/lirc/lircd
ExecStartPre=/bin/ln -s /run/lirc/lircd /dev/lircd

ExecStart=/usr/sbin/lircd -d $LIRC_DEVICE -P /run/lirc/lircd.pid -H $LIRC_DRIVER $LIRC_CONFIGFILE
ExecStopPost=/bin/rm -f /dev/lircd
ExecStopPost=/bin/rm -fR /run/lirc

[Install]
WantedBy=multi-user.target

"I exist" is the best myth I know..

Offline

#3 2012-09-02 15:17:37

progandy
Member
Registered: 2012-05-17
Posts: 5,307

Re: [solved] udev/command/module/service

Does the serial port get a systemd-unit like sys-devices-...? Then you should add that as requirement to the unit.


| alias CUTF='LANG=en_XX.UTF-8@POSIX ' | alias ENGLISH='LANG=C.UTF-8 ' |

Offline

#4 2012-09-02 15:26:09

student975
Member
From: Russian Federation
Registered: 2011-03-05
Posts: 616

Re: [solved] udev/command/module/service

progandy wrote:

Does the serial port get a systemd-unit like sys-devices-...? Then you should add that as requirement to the unit.

No, there isn't. Kernel serial driver is built into kernel (rather made as mofule) and catches serial (hardware) port. The port must be freed from the driver with setserial.


"I exist" is the best myth I know..

Offline

Board footer

Powered by FluxBB