tus*_*ark 5 php serial-port virtual-serial-port
我正在尝试使用Remy Sanchez开发的PHP类通过串口与iRobot Roomba进行通信.我确信它正在发送数据,因为iRobot USB电缆正在接收数据并点亮,但是,Roomba似乎没有确认Roomba串行命令接口(SCI)规范手册中定义的命令.这有可能的原因吗?该类是否以某种方式扭曲数据,或者Roomba是否需要将某种数据类型发送给PHP不支持?
附加信息(我不确定这是否相关)
使用RealTerm,我可以使用Send Numbers功能直接与Roomba通信(如果我尝试以任何其他方式进行通信,它会发送每个按键).使用PuTTY,即使我可以强制进行本地回显+行编辑,Roomba也不接受我的命令.它接收命令,但即使正确配置了波特率,它也不会对它们执行任何操作.
码
require("php_serial.class.php");
$serial = new phpSerial();
$serial->deviceSet("COM1");
$serial->confBaudRate(115200); //Baud rate: 115200
$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
$serial->deviceOpen();
$start = sprintf("%c",128);
$power = sprintf("%c",133);
$serial->sendMessage("$start");
$time_start = microtime(true);
// Sleep for a while
usleep(1000000);
$time_end = microtime(true);
$time = $time_end - $time_start;
echo "Did nothing in $time seconds <br>";
$serial->sendMessage("$power");
$serial->deviceClose();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2739 次 |
| 最近记录: |