Ciao ragazzi Ho un problema riguardante la trasmissione seriale da PHP ad Arduino.
I messaggi d'errore sono:
Warning: Unable to open the device in C:\xampp\htdocs\progetto\librerie\php_serial.class.php on line 187
Warning: Device must be opened in C:\xampp\htdocs\progetto\librerie\php_serial.class.php on line 608
Warning: Device must be opened to read it in C:\xampp\htdocs\progetto\librerie\php_serial.class.php on line 522
Utilizzo la libreria php_serial.class.php e Arduino è collegato alla porta COM13. Il file php è:
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
define("PORT","COM13");
if (isset($_GET['action'])) {
    include "librerie/php_serial.class.php";
$serial = new phpSerial;
$serial->deviceSet(PORT);
    $serial->confBaudRate(9600);
    $serial->confParity("none");
    $serial->confCharacterLength(8);
    $serial->confStopBits(1);
    $serial->confFlowControl("none");
    $serial->deviceOpen();
    if ($_GET['action'] == "on") {
      $serial->sendMessage("a");
  } else if ($_GET['action'] == "off") {
      $serial->sendMessage("s");
    }
  $read = $serial->readPort();
  print $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>
<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>
Quello di Arduino è:
int azione;
void setup() {
Â
}
void loop() {
 // Controllo: se la porta seriale sta trasmettendo informazioni...
 if (Serial.available() > 0) {
  // ... leggo l'ultimo carattere (byte) inviato.
  azione = Serial.read();
  // Decido cosa fare se il byte che leggo è 0 oppure 1
  if (azione == 'a') {
   Serial.write("led spento");
  }
  else if (azione == 's') {
   Serial.write(azione);
  }
 }
}
Penso che sia un problema di permessi di Apache, come posso risolvere?