我正在尝试使用
PHP class developed by Remy Sanchez通过串口与iRobot Roomba进行通信.我确信它正在发送数据,因为iRobot USB线正在接收数据并点亮,但是,Roomba似乎没有承认
Roomba Serial Command Interface (SCI) Specification manual中定义的命令.可能的原因是什么?该类是否以某种方式扭曲数据,或者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
";
$serial->sendMessage("$power");
$serial->deviceClose();