Wpadłem na pomysł aby 'sterować' silnikiem z przeglądarki. Schemat działania wygląda następująco:
skrypt php --> skrypt bash --> minicom --> uart --> mikrokontroler atmega8
Niestety php nie chce uruchomić minicoma. Tworzy dwa pliki (run.runscript i efekt) a następnie je usuwa i zwraca zero. Samego minicoma prawdopodobnie nie uruchamia (sprawdzałem w aktywnych procesach). Macie jakiś pomysł na rozwiązanie tego problemu? Poniżej zamieszczam wszystkie źródła i wyedytowany plik sudoers.
skrypt php:
<?php ?>
skrypt bash:
Kod
#!/bin/bash
function opusc
{
echo 'send d' > run.runscript
echo 'expect {' >> run.runscript
echo '"o"' >> run.runscript
echo 'timeout 10' >> run.runscript
echo '}' >> run.runscript
echo 'sleep 2' >> run.runscript
echo '! killall -15 minicom' >> run.runscript
sudo /usr/bin/minicom -S run.runscript -C efekt
rm run.runscript
cat efekt
rm efekt
}
case "$1" in
"a") opusc;;
*) echo "nic nie wybrales"
esac
function opusc
{
echo 'send d' > run.runscript
echo 'expect {' >> run.runscript
echo '"o"' >> run.runscript
echo 'timeout 10' >> run.runscript
echo '}' >> run.runscript
echo 'sleep 2' >> run.runscript
echo '! killall -15 minicom' >> run.runscript
sudo /usr/bin/minicom -S run.runscript -C efekt
rm run.runscript
cat efekt
rm efekt
}
case "$1" in
"a") opusc;;
*) echo "nic nie wybrales"
esac
plik /etc/sudoers:
Kod
# /etc/sudoers
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
www-data ALL=(ALL) NOPASSWD: /var/www/wykon.sh
www-data ALL=(ALL) NOPASSWD: /usr/bin/minicom
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
#
# This file MUST be edited with the 'visudo' command as root.
#
# See the man page for details on how to write a sudoers file.
#
Defaults env_reset
# Host alias specification
# User alias specification
# Cmnd alias specification
# User privilege specification
root ALL=(ALL) ALL
www-data ALL=(ALL) NOPASSWD: /var/www/wykon.sh
www-data ALL=(ALL) NOPASSWD: /usr/bin/minicom
# Uncomment to allow members of group sudo to not need a password
# (Note that later entries override this, so you might need to move
# it further down)
# %sudo ALL=NOPASSWD: ALL
# Members of the admin group may gain root privileges
%admin ALL=(ALL) ALL
Proszę o pomoc w rozwiązaniu tego problemu.