You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
<?php error_reporting( E_ALL );
function microtime_float(){ list($usec, $sec) = explode(" ", microtime()); return ((float) $usec + (float) $sec); };
require_once('uartPort.php'); $myPort = new uartPort(); $myPort->deviceSet('/dev/ttyUSB0'); $myPort->confBaudRate(9600); $myPort->confParity("none"); $myPort->confCharacterLength(8); $myPort->confStopBits(1); $myPort->confFlowControl("none"); print_r( $myPort ); // Then we need to open it
if( $myPort->deviceOpen() ){ $read = ''; $start = microtime_float(); while ( ($read == '') && (microtime_float() <= $start + 2.5) ) { $read = trim( $myPort->readPort() ); if ($read != '') { echo '['.trim($read) . "]\n"; $theResult .= $read; $read = ''; }; }; // If you want to change the configuration, the device must be closed
$myPort->deviceClose(); } else echo "Error oppening device \n";
?>
|