我们正在尝试使用php从com端口读取数据。目前,执行每项任务只需一分钟。有没有办法缩短这个等待期?
$bytesSent = dio_write($bbSerialPort, $dataToReboot);
$runForSeconds = new DateInterval("PT10S"); //10 seconds
$endTime = (new DateTime())->add($runForSeconds);
echoFlush( "Waiting for {$runForSeconds->format('%S')} seconds to recieve data on serial port" );
while (new DateTime() < $endTime) {
$data = dio_read($bbSerialPort); //this is a blocking call
if ($data) {
echoFlush( "Data Recieved: ". $data );
$dataToBeep = pack("H*","020816000033C61B");// beep 3
$bytesbeepSent = dio_write($bbSerialPort, $dataToBeep);
$databeep = dio_read($bbSerialPort);
}
}