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?

share|improve this question
    
If you can't be bothered to show your script don't expect any answers. See raspberrypi.stackexchange.com/help/how-to-ask – Milliways Aug 9 '16 at 0:03
    
It's not a code issue. just I need to check whether the serial interface is loaded or not, to run my script when it completely loaded. the script includes this same script: github.com/4dsystems/ViSi-Genie-RaspPi-Library/pull/1/… – Dani Aug 9 '16 at 5:39

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 :)

share|improve this answer
    
I already tried that, but it didn't worked... but I got the solution which is using crontab instead of rc.local file, just like this: sudo crontab -e, and adding @reboot python /home/pi/MyScript.py & to the end of the file – Dani Aug 10 '16 at 7:48
up vote 0 down vote accepted

I found the solution just in case someone else faced the same issue, the solution is to use crontab instead of rc.local file:

sudo crontab -e

Scroll to the buttom and add this line:

@reboot python /home/pi/MyScript.py &
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.