我在fedora 13中安装了xampp.我正在尝试通过串口使用php串口与微控制器通信.我的代码是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();
?>
Run Code Online (Sandbox Code Playgroud)
php脚本被执行但提供以下警告.
警告:指定的串行端口在第147行的/opt/lampp/htdocs/xampp/php_serial.class.php中无效警告:无法设置波特率:未在/ opt/lampp/htdocs中设置或打开设备第241行/xampp/php_serial.class.php警告:无法设置奇偶校验:设备未在第295行的/opt/lampp/htdocs/xampp/php_serial.class.php中设置或打开
...我使用了命令:chmod 0777/dev/ttyUSB0来授予权限.我还尝试使用命令将apache用户"prudhvi"添加到拨出组:$ usermod …