php-general | 2005051

[PHP] dio_read timeout? From: AC (alcastle <email protected>)
Date: 05/10/05

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

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php