I havent debugged your example in any way but get an error Fatal error: Maximum execution time of 30 seconds exceeded in /var/www/php_serial.class.php on line 516
Ill look into it later tonight. I supposed to be doing real work right now
I do see this in the serial class.
/**
* Reads the port until no new datas are availible, then return the content.
*
* @pararm int $count number of characters to be read (will stop before
* if less characters are in the buffer)
* @return string
*/
function readPort ($count = 0)
{
if ($this->_dState !== SERIAL_DEVICE_OPENED)
{
trigger_error("Device must be opened to read it", E_USER_WARNING);
return false;
}
if ($this->_os === "linux" || $this->_os === "osx")
{
// Behavior in OSX isn't to wait for new data to recover, but just grabs what's there!
// Doesn't always work perfectly for me in OSX
$content = ""; $i = 0;
if ($count !== 0)
{
do {
if ($i > $count) $content .= fread($this->_dHandle, ($count - $i));
else $content .= fread($this->_dHandle, 128);
} while (($i += 128) === strlen($content));
}
else
{
do {
$content .= fread($this->_dHandle, 128);
} while (($i += 128) === strlen($content));
}
return $content;
}
elseif ($this->_os === "windows")
{
/* Do nothing : not implented yet */
}
trigger_error("Reading serial port is not implemented for Windows", E_USER_WARNING);
return false;
}
Test PHP code
<?php
/* Script for Checking all the levels*/
// Load the serial port class
require("php_serial.class.php");
//Initialize the class
$serial = new phpSerial();
//Specify the serial port to use... in this case COM1
$serial->deviceSet("/dev/ttyUSB0");
//Set the serial port parameters. The documentation says 9600 8-N-1, so
$serial->confBaudRate(9600); //Baud rate: 9600
$serial->confParity("none");Â //Parity (this is the "N" in "8-N-1")
$serial->confCharacterLength(8); //Character length (this is the "8" in "8-N-1")
$serial->confStopBits(1);Â //Stop bits (this is the "1" in "8-N-1")
// Ask Arduino what the Air Temp is.
$serial->deviceOpen();
$serial->sendMessage(chr(10)); // start transmission
$serial->sendMessage(chr(50));
$serial->sendMessage(chr(13)); // end transmission
// $read = $serial->readPort(); // waiting for reply
$tries = 0;
$max_tries = 100;
while (!$read = $serial->readPort() && $tries < $max_tries) {
 // waiting for reply - do something else?
 $tries++;
}
if ($read) {
  $current_air_temp = $read;
$current_air_temp = (int)$current_air_temp;
//We're done, so close the serial port again
$serial->deviceClose();
mysql_query("INSERT INTO logging (stuff,Sensor) VALUES ($current_air_temp,'Air Temp')");
}
else {
$serial->deviceClose();
 die("Timeout limit reached - data unavailable.");
}
?>