Cannot run a program at boot that uses a serial device

Mark Barton mark at atldes.com
Tue Oct 16 11:46:07 UTC 2018


I have a couple of Python programs that will no 
longer start at boot time.  This was working until 
yesterday afternoon just after a did a reboot. 
There haven't been any changes to either program, 
but I did do an update (upgrade and dist-upgrade) 
a few days ago. I cannot recall if I did a reboot 
at the time though. I'm guessing that I did not do 
the reboot until yesterday and that my problem 
might be due to the upgrade.  Using systemctl 
status command revealed that  USB serial device 
could not be found which caused the abort. It 
seems my programs are getting executed before the 
devices are available. I can however manually 
start the programs using systemctl after the 
system is finish booting. After some searching I 
found what is needed to setup a udev rule to wait 
until a specific tty device is available, but it 
didn't work. The is a difference between my udev 
rule is that I am using a symlink device name and 
the example used the actual  ttyUSBx device name.

My udev rule:

SUBSYSTEM=="tty", ATTRS{idVendor}=="0403", 
ATTRS{idProduct}=="6001", 
ATTRS{serial}=="A10xxxx", SYMLINK+="ttyEmon", 
GROUP="dialout", OWNER="root"
SUBSYSTEM=="tty", KERNEL=="ttyEmon", 
TAG+="systemd", 
ENV{SYSTEMD_WANTS}+="home-energy.service"

And my systemd service:

#service file for starting/stopping home-energy.py

[Unit]
Description=home-energy startup

[Service]
Type=simple
ExecStart=/usr/local/bin/home-energy.py

[Install]
#commented out because a udev rule checks for 
/dev/tty... availability
#WantedBy=multi-user.target


Running Ubuntu 16.04

Any pointers on how the best to debug is appreciated

Mark





More information about the ubuntu-users mailing list