X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fserial%2Fserial.cxx;h=3fa85bdc1b7f9fd4508fdae46872dd5038838c75;hb=e2b4c0787a4398199ef2d35e05963acd58b7a04c;hp=72e4cdef970c056e9852419c0a7f870270a5d589;hpb=689a942f193c1c15b4ddb4009958b7782cde44e7;p=simgear.git diff --git a/simgear/serial/serial.cxx b/simgear/serial/serial.cxx index 72e4cdef..3fa85bdc 100644 --- a/simgear/serial/serial.cxx +++ b/simgear/serial/serial.cxx @@ -4,30 +4,27 @@ // // Copyright (C) 1998 Curtis L. Olson - curt@flightgear.org // -// This program is free software; you can redistribute it and/or -// modify it under the terms of the GNU General Public License as -// published by the Free Software Foundation; either version 2 of the -// License, or (at your option) any later version. +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Library General Public +// License as published by the Free Software Foundation; either +// version 2 of the License, or (at your option) any later version. // -// This program is distributed in the hope that it will be useful, but -// WITHOUT ANY WARRANTY; without even the implied warranty of +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -// General Public License for more details. +// Library General Public License for more details. // -// You should have received a copy of the GNU General Public License -// along with this program; if not, write to the Free Software -// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +// You should have received a copy of the GNU Library General Public +// License along with this library; if not, write to the +// Free Software Foundation, Inc., 59 Temple Place - Suite 330, +// Boston, MA 02111-1307, USA. // // $Id$ -#ifdef HAVE_CONFIG_H -# include -#endif - #include -#ifdef FG_HAVE_STD_INCLUDE +#ifdef SG_HAVE_STD_INCLUDE # include #else # include @@ -93,7 +90,7 @@ bool FGSerialPort::open_port(const string& device) { 0, NULL ); - FG_LOG( FG_IO, FG_ALERT, "Error opening serial device \"" + SG_LOG( SG_IO, SG_ALERT, "Error opening serial device \"" << device << "\" " << (const char*) lpMsgBuf ); LocalFree( lpMsgBuf ); return false; @@ -110,7 +107,7 @@ bool FGSerialPort::open_port(const string& device) { cout << "Serial fd created = " << fd << endl; if ( fd == -1 ) { - FG_LOG( FG_IO, FG_ALERT, "Cannot open " << device + SG_LOG( SG_IO, SG_ALERT, "Cannot open " << device << " for serial I/O" ); return false; } else { @@ -119,7 +116,7 @@ bool FGSerialPort::open_port(const string& device) { // set required port parameters if ( tcgetattr( fd, &config ) != 0 ) { - FG_LOG( FG_IO, FG_ALERT, "Unable to poll port settings" ); + SG_LOG( SG_IO, SG_ALERT, "Unable to poll port settings" ); return false; } @@ -141,7 +138,7 @@ bool FGSerialPort::open_port(const string& device) { // cout << "config.c_iflag = " << config.c_iflag << endl; if ( tcsetattr( fd, TCSANOW, &config ) != 0 ) { - FG_LOG( FG_IO, FG_ALERT, "Unable to update port settings" ); + SG_LOG( SG_IO, SG_ALERT, "Unable to update port settings" ); return false; } @@ -175,7 +172,7 @@ bool FGSerialPort::set_baud(int baud) { speed_t speed = B9600; if ( tcgetattr( fd, &config ) != 0 ) { - FG_LOG( FG_IO, FG_ALERT, "Unable to poll port settings" ); + SG_LOG( SG_IO, SG_ALERT, "Unable to poll port settings" ); return false; } @@ -202,22 +199,22 @@ bool FGSerialPort::set_baud(int baud) { speed = B230400; #endif } else { - FG_LOG( FG_IO, FG_ALERT, "Unsupported baud rate " << baud ); + SG_LOG( SG_IO, SG_ALERT, "Unsupported baud rate " << baud ); return false; } if ( cfsetispeed( &config, speed ) != 0 ) { - FG_LOG( FG_IO, FG_ALERT, "Problem setting input baud rate" ); + SG_LOG( SG_IO, SG_ALERT, "Problem setting input baud rate" ); return false; } if ( cfsetospeed( &config, speed ) != 0 ) { - FG_LOG( FG_IO, FG_ALERT, "Problem setting output baud rate" ); + SG_LOG( SG_IO, SG_ALERT, "Problem setting output baud rate" ); return false; } if ( tcsetattr( fd, TCSANOW, &config ) != 0 ) { - FG_LOG( FG_IO, FG_ALERT, "Unable to update port settings" ); + SG_LOG( SG_IO, SG_ALERT, "Unable to update port settings" ); return false; } @@ -247,7 +244,7 @@ string FGSerialPort::read_port() { if ( count < 0 ) { // error condition if ( errno != EAGAIN ) { - FG_LOG( FG_IO, FG_ALERT, + SG_LOG( SG_IO, SG_ALERT, "Serial I/O on read, error number = " << errno ); } @@ -280,7 +277,7 @@ int FGSerialPort::read_port(char *buf, int len) { if ( count < 0 ) { // error condition if ( errno != EAGAIN ) { - FG_LOG( FG_IO, FG_ALERT, + SG_LOG( SG_IO, SG_ALERT, "Serial I/O on read, error number = " << errno ); } @@ -324,7 +321,7 @@ int FGSerialPort::write_port(const string& value) { 0, NULL ); - FG_LOG( FG_IO, FG_ALERT, "Serial I/O write error: " + SG_LOG( SG_IO, SG_ALERT, "Serial I/O write error: " << (const char*) lpMsgBuf ); LocalFree( lpMsgBuf ); return int(lpNumberOfBytesWritten); @@ -338,7 +335,7 @@ int FGSerialPort::write_port(const string& value) { int count; if ( error ) { - FG_LOG( FG_IO, FG_ALERT, "attempting serial write error recovery" ); + SG_LOG( SG_IO, SG_ALERT, "attempting serial write error recovery" ); // attempt some sort of error recovery count = write(fd, "\n", 1); if ( count == 1 ) { @@ -361,7 +358,7 @@ int FGSerialPort::write_port(const string& value) { error = false; } else { error = true; - FG_LOG( FG_IO, FG_ALERT, + SG_LOG( SG_IO, SG_ALERT, "Serial I/O on write, error number = " << errno ); } } @@ -399,7 +396,7 @@ int FGSerialPort::write_port(const char* buf, int len) { 0, NULL ); - FG_LOG( FG_IO, FG_ALERT, "Serial I/O write error: " + SG_LOG( SG_IO, SG_ALERT, "Serial I/O write error: " << (const char*) lpMsgBuf ); LocalFree( lpMsgBuf ); return int(lpNumberOfBytesWritten); @@ -434,7 +431,7 @@ int FGSerialPort::write_port(const char* buf, int len) { // ok ... in our context we don't really care if we can't // write a string, we'll just get it the next time around } else { - FG_LOG( FG_IO, FG_ALERT, + SG_LOG( SG_IO, SG_ALERT, "Serial I/O on write, error number = " << errno ); } }