| 
 | 
 
 Edited by wwwlu at 2017-2-24 17:54  
 
I use an arduino to shutdown (and start) my Orange Pi pc plus (on Lubuntu) by sending "stop" via the serial port 
The following python script works fine when I launch it manually  (sudo python off.py) 
#!/usr/bin/env python 
# -*- coding: latin-1 -*- 
import serial 
import os 
ser = serial.Serial('/dev/ttyS0', 9600) 
while True : 
        data = ser.readline() 
        if "stop" in data: 
                os.system('sudo shutdown -h now') 
 
 
Now I try to execute this script automatically at startup 
 
I entered the following line: 
sudo python off.py 
 at the end of: 
 sudo nano /etc/profile 
 
result: 
Error found when loading /etc/profile: 
sudo: no tty present and no askpass program specified 
as a result the session will not be configured correctly 
you should fix the problem as soon as feasible 
 
It seems the serial port is not yet open when the script is executed 
 
So I tried to launch the script via "default applications for LXSession" but the shutdown instruction requires to be super user (so it cannot be automatic) 
 
In conclusion: before opening the session the serial port is closed, and after the script cannot shutdown the OPI 
 
Anyone has a solution please ? 
 
 |   
 
 
 
 |