Pages: [1]   Go Down
Author Topic: PHP - Ubuntu - php_serial.class.php - Issues [Solved]  (Read 2051 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Sr. Member
****
Karma: 2
Posts: 408
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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:

Code:
<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:

Code:
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








« Last Edit: April 24, 2012, 02:44:07 am by gnusso » Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 408
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Offline Offline
Sr. Member
****
Karma: 2
Posts: 408
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

sudo chmod 755 /dev/tty.ACM0

Regards,
Andrea
Logged

Pages: [1]   Go Up
Jump to: