// Change Parms on Comport: Linux: Windows $command = (PHP_OS == 'Linux') ? 'mode /dev/ttyS1: BAUD=9600 PARITY=N data=8 stop=1 XON=off TO=on' : 'mode COM1: BAUD=9600 PARITY=N data=8 stop=1 XON=off TO=on'; system($command, $retVar); if($retVar == '127'){ echo("Command not found:$command<br>"); // May want to exit here. } //Create the resource id: Linux: Windows $path = (PHP_OS == 'Linux') ? '/dev/ttyS1' : 'COM1'; $fp = fopen($path, 'r+'); if(!$fp){ echo"Port not accessible"; exit(); } else { echo"Port COM1 opened successfully"; } //Read from port: $buffer = fgets($fp); echo "<br>Data read from buffer: $buffer";
mode
fopen()
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)