Modbus RTU PHP中的响应字符串为Null

时间:2019-09-30 13:58:45

标签: modbus

https://github.com/toggio/PhpSerialModbus

我们正在使用以上API从PLC读取数据。

  1. 我们能够初始化并打开端口并发送查询,但是我们得到的响应为NULL。

  2. 最后,在绝望中直接传递以下查询,以尝试读取保持寄存器4237

$modbus->sendQuery(1,3,"108D",1); 

(查询正确吗?) 响应仍然为Null。

  1. 我们来到了以下断点,发现该断点没有执行:
// 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。

0 个答案:

没有答案