_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; } } ?>