https://github.com/toggio/PhpSerialModbus
我们正在使用以上API从PLC读取数据。
我们能够初始化并打开端口并发送查询,但是我们得到的响应为NULL。
最后,在绝望中直接传递以下查询,以尝试读取保持寄存器4237
$modbus->sendQuery(1,3,"108D",1);
(查询正确吗?) 响应仍然为Null。
// Read serial port buffer (with three seconds timeout)
$responseString='';
while( ($byte = $this->serial->ReadPort()) && ((microtime(true)-$startTime)<3.0))
{
$byte = $this->serial->ReadPort();
$responseString=$responseString.$byte;
sleep(3);
}
$ responseString为NULL。