The following is a library for serial communication through PHP: http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html . The problem is that the readPort method is not fully implemented. It can read in * nix, but apparently not in Windows. Method:
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") { $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") { } trigger_error("Reading serial port is not implemented for Windows", E_USER_WARNING); return false; }
The author declares:
==> /! \ WARNING /! \: it works with linux for r / w, but with windows I could only write work. If you are a windows user, try accessing the serial port over the network using serproxy instead.
The limitation of the PHP class library has already been mentioned in SO several times. I did not find a decent solution. Reading is a must for my application.
Does anyone know what to do?
source share