I installed xampp in fedora 13. I am trying to communicate with the microcontroller via the serial port using the php serial class. My code example.php
include("php_serial.class.php"); $serial = new phpSerial(); $serial->deviceSet("0"); $serial->confBaudRate(9600); //Baud rate: 9600 $serial->confParity("none"); //Parity (this is the "N" in "8-N-1") $serial->confCharacterLength(8); //Character length (this is the "8" in "8-N-1") $serial->confStopBits(1); //Stop bits (this is the "1" in "8-N-1") $serial->confFlowControl("none"); //Device does not support flow control of any kind, so set it to none. //Now we "open" the serial port so we can write to it $serial->deviceOpen(); $serial->sendMessage("*1" ); //sleep(1); // echo "hi"; $serial->deviceClose(); ?>
The PHP script runs, but gives the following warnings.
Caution: the specified serial port is not valid in / opt / lampp / htdocs / xampp / php _serial.class.php on line 147 Warning. Cannot set baud rate: device is either not installed or open in / opt / lampp / htdocs / xampp / php _serial.class.php on line 241 Warning: parity cannot be set: device is either not installed or open in / opt / lampp / htdocs / xampp / php _serial.class.php on line 295
... I used the command: chmod 0777 / dev / ttyUSB0 to grant permissions. I also tried adding apache user "prudhvi" to the dialout group using the command: $ usermod -a -G dialout prudhvi
But that does not work. When I send a command directly from the terminal using the command: echo 1> / dev / ttyUSB0, it works, and "1" is sent to the serial port. But using php, I get the above warnings.
I used "$ whoami" to verify the username and added this user "prudhvi" to the dialout group. It is still not working. Please help me guys.
linux php serial-communication
prudhvi09
source share