I added this "delayer". It doesnt help either. WTF this is driving me nuts. PHP is supposed to be the easy part for me.
Im getting results only about 20% of the time.
function microtime_float()
{
list($usec, $sec) = explode(" ", microtime());
return ((float)$usec + (float)$sec);
}
$read = '';
$theResult = '';
$start = microtime_float();
while ( ($read == '') && (microtime_float() <= $start + 1) ) {
$read = $serial->readPort();
if ($read != '') {
$theResult .= $read;
$read = '';
}
}
$serial->deviceClose();
// etc...
echo "Read data: ".$theResult."
";