So I have a python script that is using the raspberry pi serial RX,TX to communicate with a 4D System Display. It is working just as I want it to work, BUT, when I modify the /etc/rc.local to let this script run automatically at startup, and apply a reboot, the screen which uses the serial interface is not working. Knowing that all other tasks are working correctly, just the serial interface didn't work. So the problem might be that my script is running before serial interface is booting completely. so is there any workaround for such situation?
I had a similar issue. My script calls the serial ports ttyACM* and I use
.config/lxsession/LXDE-pi/autostart to launch it at startup. As I
was having problems with this approach, I checked the
.cache/lxsesion/LXDE-pi/rpi.log and I found out my script was not able to open the serial port only at startup, right after boot. It was not a matter of permissions or timing. After few negative attempts playing with
lxsession, I removed
sudo apt-get purge modemmanager as suggested in the Arduino forum and now my script works as expected.
In the Python file, import time and add a time.sleep(seconds) in the beginning of the code. Also in the /etc/rc.local file, add a "&" sign together with the line starting the python script.
This will allow the pi to boot completely while still starting the python file automatically, this should work :)