#include <simgear/compiler.h>
+#include STL_IOSTREAM
+
#ifdef SG_HAVE_STD_INCLUDE
# include <cerrno>
#else
#include "serial.hxx"
-
-FGSerialPort::FGSerialPort()
+SGSerialPort::SGSerialPort()
: dev_open(false)
{
// empty
}
-FGSerialPort::FGSerialPort(const string& device, int baud) {
+SGSerialPort::SGSerialPort(const string& device, int baud) {
open_port(device);
if ( dev_open ) {
}
}
-FGSerialPort::~FGSerialPort() {
+SGSerialPort::~SGSerialPort() {
// closing the port here screws us up because if we would even so
- // much as make a copy of an FGSerialPort object and then delete it,
+ // much as make a copy of an SGSerialPort object and then delete it,
// the file descriptor gets closed. Doh!!!
}
-bool FGSerialPort::open_port(const string& device) {
+bool SGSerialPort::open_port(const string& device) {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
struct termios config;
fd = open(device.c_str(), O_RDWR | O_NONBLOCK);
- cout << "Serial fd created = " << fd << endl;
+ SG_LOG( SG_EVENT, SG_DEBUG, "Serial fd created = " << fd);
if ( fd == -1 ) {
SG_LOG( SG_IO, SG_ALERT, "Cannot open " << device
}
-bool FGSerialPort::close_port() {
+bool SGSerialPort::close_port() {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
CloseHandle( fd );
#else
}
-bool FGSerialPort::set_baud(int baud) {
+bool SGSerialPort::set_baud(int baud) {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
}
-string FGSerialPort::read_port() {
+string SGSerialPort::read_port() {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
}
-int FGSerialPort::read_port(char *buf, int len) {
+int SGSerialPort::read_port(char *buf, int len) {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
}
-int FGSerialPort::write_port(const string& value) {
+int SGSerialPort::write_port(const string& value) {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
}
-int FGSerialPort::write_port(const char* buf, int len) {
+int SGSerialPort::write_port(const char* buf, int len) {
#if defined( WIN32 ) && !defined( __CYGWIN__) && !defined( __CYGWIN32__ )
LPCVOID lpBuffer = buf;