我正在尝试使用PHP读取称重机的值(即重量)。每当我运行以下代码时,它都会显示
Fatal error: Maximum execution time of 300 seconds exceeded
我做错了什么,不知道在哪里吗?
PHP Serial类提供了一个readPort()
函数,不会返回(我的假设)。
我的PHP代码:
<html>
<body>
<h1>Works with php</h1>
<p>First Page in PHP</p>
<?php
include 'PhpSerial.php';
$serial = new phpSerial();
$serial->deviceSet("COM3");
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
$serial->deviceOpen();
$serial->sendMessage("s");
$read = $serial->readPort();
echo ("Weight--->".$read );
$serial->deviceClose();
?>
<p>Sent Data to server </p>
</body>
</html>
答案 0 :(得分:0)
尝试这样:
require_once 'PhpSerial.php';
$serial=new phpSerial();
$serial->deviceSet('/dev/ttyACM2');
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
$serial->deviceOpen();
if($_GET['status']){
$serial->sendMessage($_GET['status']);
$read=$serial->readPort();
var_dump($read);
echo $read;
}