uart0.php... (透過 shell_exec 執行 python 碼)
===============================================
$cmd = escapeshellcmd ( '/usr/bin/python uart0.py' );
$output = shell_exec ( $cmd );
echo $output;
===============================================
===============================================
import serial
serialport = serial.Serial("/dev/ttyAMA0", 9600, timeout=0.5)
serialport.write( "TEST" )
response = serialport.readlines(None)
print response
===============================================
=1=暫時-reboot後無效==============================
sudo chmod 777 /dev/ttyAMA0
=2=============================================
sudo adduser youruser dialout
usermod -aG dialout youruser
===============================================
沒有留言:
張貼留言