salve a tutti, ho ripreso l'esempio in rete per controllare da php un arduino collegato alla seriale.
dopo un pò di peripezie,(installazione ubuntu, apache,e php5, e permessi vari per accedere a dialout) "funziona nel senso che dalla pagina php ho 2 bottoni che inviano 2 caratteri a arduino, che li riceve e fa quello che deve fare.
il problema è che ogni volta che premo uno dei 2 bottoni si riavvia arduino.
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
define("PORT","/dev/ttyACM0");
if (isset($_GET['action'])) {
include "/usr/share/php5/php_serial.class.php";
$serial = new phpSerial;
$serial->deviceSet(PORT);
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(

;
$serial->confStopBits(1);
$serial->confFlowControl("none");
$serial->deviceOpen();
sleep(2);
if ($_GET['action'] == "on") {
$serial->sendMessage("1");
} else if ($_GET['action'] == "off") {
$serial->sendMessage("2");
}
$read = $serial->readPort();
echo $read;
$serial->deviceClose();
}
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"
http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<title>Test Arduino</title>
</head>
<body>
<br>
<h1>Test Arduino</h1>
<a href="<?=$_SERVER['PHP_SELF'] . "?action=on" ?>">
<button style="width:100px""><h1>ON</h1></button></a>
<a href="<?=$_SERVER['PHP_SELF'] . "?action=off" ?>">
<button style="width:100px""><h1>OFF</h1></button></a>
</body>
</html>
ho provato come diceva un utente a mettere sleep(1); ma niente arduino si resetta sempre.
forse è anche normale visto che nel codice php ogni volta che premo uno dei 2 bottoni ho l'apertura della seriale...come risolvere?