We are trying to read data from com port using php. Currently it takes exactly one minute to execute each task. Is there a way to cut short this waiting period?
$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);
}
}