我正在尝试使用Remy Sanchez 开发的 PHP 类通过串行端口与 iRobot Roomba 通信。我确信它正在发送数据,因为 iRobot USB 电缆正在接收数据并亮起,但是,Roomba 似乎没有确认Roomba 串行命令接口 (SCI) 规范手册中定义的命令。这有可能的原因吗?该类是否以某种方式扭曲了数据,或者 Roomba 是否需要向其发送 PHP 不支持的某种数据类型?
附加信息(我不确定这是否相关)
使用 RealTerm,我可以使用发送号码功能直接与 Roomba 通信(如果我尝试以任何其他方式通信,它会发送每个按键)。使用 PuTTY,Roomba 不接受我的命令,即使我可以强制本地 echo + 行编辑。它接收命令,但即使波特率配置正确,也不会对它们做任何事情。
代码
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();