E
E
elisey4742015-10-06 19:40:18
linux
elisey474, 2015-10-06 19:40:18

Why is php not working?

Arduino Uno is connected to the server via UART. Everything is configured so that when executing a command in ssh
echo "1" > /dev/ttyS0 the
LED turns on.
And the php script can't turn on the LED.
<?php
exec('echo "1" > /dev/ttyS0');
?>
Why?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Alexey Romanenko, 2015-10-06
@elisey474

most likely not enough rights. what user and what permissions on /dev/ttyS0?

T
Tlito, 2015-10-06
@tlito

exec('echo "1" > 1.txt');
set it to 1.txt in the folder where the script is right 777
if it works, then you need to figure out the rights,
and if it doesn’t work, then you need to give PHP the ability to call system functions.

V
vanyamba-electronics, 2015-10-15
@vanyamba-electronics

Turn on error reporting and try to open the port:

error_reporting(E_ALL);
fopen('/dev/ttyS0', 'w');

If it's a matter of user rights, then it will write Permission denied. If it's not about user rights, then before opening /dev/ttyS0, you need to configure USART using stty.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question