My goal is to write a string through the serial of my Raspberry Pi which will then be sent towards an Arduino and I'll read it through the Serial Monitor.
I got my Python script working and it works perfectly when I execute it on the Raspberry Pi's terminal. As soon as I run it through the website, it does not work.
To test it out, I made the PHP code run the script as soon as the site was launched. This is what the code looks like:
<?php
exec('/usr/bin/python /var/www/UART3.py test');
?>
The test at the end of the exec() sends that string through the serial communication. I can copy and paste that code into the terminal and it works perfectly.
Things I have done:
- Tested the code individually (works)
- Gave rights to www-data by doing
chmod +x UART3.py
Any ideas?
exec
function?ls -l UART3.py
?ls -l UART3.py
reads-rwxr-xr-x
. And yes I normally can execute things with exec function. Just now i redid my entire code in C, compiled it, and ran that through through the website using the sameexec
function and it works perfect. Now I'm curious as to why it worked when I did it with the C compiled file as opposed to the python file.echo exec('/usr/bin/python /var/www/UART3.py test');
in your php fileecho exec( 'chmod +x' )
it doesn't change anything or show anything on the website. Am i supposed to type that into a specific program? Just to be clear, I'm doing all of this headless on my Raspberry Pi Rasbian Jessie and then checking the results out via website and Arduino serial monitor