I have written a daemon that manages a number of communication protocols over one, or multiple RS232 devices (typically FT232R usb2serial). Once a /dev/ttyUSB* device appears, if certain attributes are detected, systemd is told to start that daemon via udev:
ENV{SYSTEMD_WANTS}="%s{manufacturer}.service" Once the daemon has started, it needs to be told which device to open, which I do via udev:
RUN="/usr/bin/sercomc open %E{sd_name} %E{sd_proto} %N" So the complete udev rule reads like:
ACTION=="add", SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", ATTRS{idProduct}=="6001", ATTRS{manufacturer}=="sercomd", ENV{SYSTEMD_WANTS}="%s{manufacturer}.service", ENV{sd_proto}="%s{product}", ENV{sd_name}="%s{serial}", RUN="/usr/bin/sercomc open %E{sd_name} %E{sd_proto} %N" Now the problem is that RUN is executed before the daemon is started so that this command obviously has no effect:
systemd-udevd[1638]: starting '/usr/bin/sercomc open ctl-vk1 ctserial /dev/ttyUSB0' systemd-udevd[1632]: '/usr/bin/sercomc open ctl-vk1 ctserial /dev/ttyUSB0'(err) 'Couldn't connect to server: Connect failed: Connection refused' [...] sercomctl[1639]: [2015-10-12 03:05:39:291634] Serial communication daemon ver. 0.5 starting up Is there a recommended way in resolving this, i.e. trigger running the command once that systemd has finished starting the service?