I need a simple script to read the information from a serial port (ttyS0 / ttyUSB0) using PHP on Ubuntu Linux.
I have tried th following code but the code hangs and no results are returned, also tried php_serial class found on [url removed, login to view] and keep getting errors.
$myFile = "/dev/ttyUSB0";
$handle = fopen($myFile, 'rb+');
$Data = fread($handle, 15);
Information from the serial port could come at anytime so there needs to be some sort of continuous polling waiting to receive the data from serial port.
I also need to be able to set board rate, stop bits, parity etc
The information I'm expecting to receive from the comport should look something like 000118110001001
CAN ANYONE HELP ME?
First, you need to set time-limit to unlimited, so your script wont be expired in waiting. Second, you should "clean" out the buffer every-cycle reading. This is default setting for continue reading on web-based applic Daha Fazla