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.
 
 
 
 
 
 

54 lines
1.1 KiB

<?php
require_once('uartPort.php');
class gpsController extends Thread {
var $_uart_port = '';
var $_thread_state = 0;
function __construct( $port ){
$this->_uart_port = $port;
$this->start();
}
function __destruct(){
if( $this->_thread_state > 1 ){
$this->_thread_state = 3;
while( $this->_thread_state == 3 ) usleep( 10 );
};
}
function init_gps(){
return true;
}
private function parse_message( $msg ){
echo $msg . "\n";
}
public function run(){
$uart = new uartPort();
if( $uart ){
if( $uart->deviceSet( $this->_uart_port ) ){
$uart->confBaudRate(9600);
$uart->confParity("none");
$uart->confCharacterLength(8);
$uart->confStopBits(1);
$uart->confFlowControl("none");
if( $uart->deviceOpen() ){
$this->_thread_state = 2;
echo "Thread Started\n";
while( $this->_thread_state < 3 ){
$read = trim( $uart->readPort() );
if( $read != '' ){
$this->parse_message( $read );
};
usleep(10);
};
$uart->deviceClose();
};
};
};
echo "Thread Finished\n";
$this->_thread_state = 4;
}
}
?>