|
Posted by Ac on 05/10/05 21:14
I'm using dio_read to read data from a serial port via a php cli script,
this works great.
However I'm unable to get dio_read to timeout if there's no data to
read. No matter how I formulate the while loop, set_time_out, etc I
can't seem to get it to stop reading and move on.
Anyone have a work around or ideas?
Example snippet, where $fd is a valid file descriptor.
function readData($fd) {
$startTime=microtime();
$endTime=$startTime+'.02';
$data=null;
$i=0;
#while($startTime < $endTime){
while($i < 5) {
$data.=dio_read($fd);
if($data) {
echo "Here's some data: $data\n";
break;
}
$i++;
}
} //end function
Navigation:
[Reply to this message]
|