PHP - Ubuntu - php_serial.class.php - Issues [Solved]

Hi all,
i'm try to use:

  • Wmplayer with Ubuntu --> php and apache correctly installed and working
  • php_serial.class.php --> download and save into the same directory where I've my test.php file
  • /dev/ttyACM0 --> ubuntu serial port --> working with a simply skecth

so inside the test.php file I've that:

<html>
<body>
<h1>It works!</h1>
<p>ARDUINO PHP.</p>
<p>The web server software is running but no content has been added, yet.</p>

<p>dentro allo script</p>

<?php
require("php_serial.class.php"); 

function writeToArduino($str){

     $serial = new phpSerial();
     $serial->deviceSet("/dev/ttyACM0");
     $serial->confBaudRate(9600);
     $serial->confCharacterLength(8);

     $serial->deviceOpen();
           for ($i=0; $i<strlen($str); $i++){
                 $serial->sendMessage($str[$i]);
           }

     $serial->deviceClose();


}

$tmptext = "12345ABCDE";
writeToArduino($tmptext);

?> 

</body>
</html>

and on my arduino scheth I've that:

int incomingByte = 0;   // for incoming serial data

void setup() {
        Serial.begin(9600);     // opens serial port, sets data rate to 9600 bps
}

void loop() {

        // send data only when you receive data:
        if (Serial.available() > 0) {
                // read the incoming byte:
                incomingByte = Serial.read();

                // say what you got:
                Serial.print("I received: ");
                Serial.println(incomingByte, DEC);
        }
}

so due the fact seems that doesn't send the data to the serial port ... what I can check ?
thanks Andrea

I think the issues is related to php script, because I've tried to do same on my mac not virtualized and I've the same results ...

Please help me ,

gnusso

the solution is that ... give the right permissione with the command

sudo chmod 755 /dev/tty.ACM0

Regards,
Andrea