我正在尝试使用来自http://code.google.com/p/phpmodbus/的phpmodbus从modbus寄存器读取寄存器146和601
脚本成功加载第一条记录,但在第二条记录时失败 我得到的错误是:致命错误:超出最长执行时间
我的代码如下:
require_once dirname(__FILE__) . '/Phpmodbus/Phpmodbus/ModbusMaster.php';
$modbus = new ModbusMaster("10.234.6.11", "TCP");
//the sql contaions the two records 146 and 601
$sql = "SELECT num FROM `main`";
$result = mysqli_query($con,$sql);
while($row = mysqli_fetch_array($result)) {
echo $row['num'] . "<br>";
$recData = $modbus->readMultipleRegisters(1, $row['num'], 1);
//modbus status
echo $modbus;
//converting
$values = array_chunk($recData, 2);
foreach($values as $bytes) {
echo PhpType::bytes2signedInt($bytes) . "<br>";
}
}