// $Id$
-#ifdef HAVE_CONFIG_H
-# include <config.h>
-#endif
-
#include <simgear/compiler.h>
-#ifdef FG_HAVE_STD_INCLUDE
+#include STL_IOSTREAM
+
+#ifdef SG_HAVE_STD_INCLUDE
# include <cerrno>
#else
# include <errno.h>
#include "serial.hxx"
+#if !defined(SG_HAVE_NATIVE_SGI_COMPILERS)
+SG_USING_STD(cout);
+SG_USING_STD(endl);
+#endif
+
FGSerialPort::FGSerialPort()
: dev_open(false)
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;
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 {
// 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;
}
// 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;
}
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;
}
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;
}
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 );
}
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 );
}
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);
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 ) {
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 );
}
}
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);
// 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 );
}
}