1998-11-16 13:57:42 +00:00
|
|
|
// fg_serial.hxx -- Higher level serial port managment routines
|
|
|
|
//
|
|
|
|
// Written by Curtis Olson, started November 1998.
|
|
|
|
//
|
|
|
|
// 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 program 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.
|
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
// $Id$
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef _FG_SERIAL_HXX
|
|
|
|
#define _FG_SERIAL_HXX
|
|
|
|
|
|
|
|
|
|
|
|
#ifndef __cplusplus
|
|
|
|
# error This library requires C++
|
|
|
|
#endif
|
|
|
|
|
1999-01-21 00:55:01 +00:00
|
|
|
#include "Include/compiler.h"
|
1998-11-16 13:57:42 +00:00
|
|
|
|
1998-11-30 17:43:32 +00:00
|
|
|
#include <string>
|
|
|
|
|
1999-01-21 00:55:01 +00:00
|
|
|
#ifdef FG_HAVE_STD_INCLUDES
|
|
|
|
# include <ctime>
|
|
|
|
#else
|
|
|
|
# include <time.h>
|
|
|
|
#endif
|
|
|
|
|
1998-11-16 13:57:42 +00:00
|
|
|
#include <Serial/serial.hxx>
|
|
|
|
|
|
|
|
|
1998-11-25 01:33:58 +00:00
|
|
|
class fgIOCHANNEL {
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
// Types of serial port protocols
|
|
|
|
enum fgPortKind {
|
|
|
|
FG_SERIAL_DISABLED = 0,
|
|
|
|
FG_SERIAL_NMEA_OUT = 1,
|
|
|
|
FG_SERIAL_NMEA_IN = 2,
|
1998-11-30 17:43:32 +00:00
|
|
|
FG_SERIAL_GARMIN_OUT = 3,
|
|
|
|
FG_SERIAL_GARMIN_IN = 4,
|
1998-11-25 01:33:58 +00:00
|
|
|
FG_SERIAL_FGFS_OUT = 5,
|
1999-04-15 23:59:45 +00:00
|
|
|
FG_SERIAL_FGFS_IN = 6,
|
|
|
|
|
|
|
|
FG_SERIAL_RUL_OUT = 7 // Raul E Horcasitas <rul@compuserve.com>
|
1998-11-25 01:33:58 +00:00
|
|
|
};
|
|
|
|
|
1998-11-30 17:43:32 +00:00
|
|
|
string device;
|
|
|
|
string format;
|
|
|
|
string baud;
|
|
|
|
string direction;
|
|
|
|
|
1998-11-25 01:33:58 +00:00
|
|
|
fgPortKind kind;
|
|
|
|
fgSERIAL port;
|
1999-01-21 00:55:01 +00:00
|
|
|
time_t last_time;
|
1998-11-30 17:43:32 +00:00
|
|
|
bool valid_config;
|
1998-11-25 01:33:58 +00:00
|
|
|
|
|
|
|
fgIOCHANNEL();
|
|
|
|
~fgIOCHANNEL();
|
1998-11-16 13:57:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
// support up to four serial channels. Each channel can be assigned
|
|
|
|
// to an arbitrary port. Bi-directional communication is supported by
|
|
|
|
// the underlying layer.
|
|
|
|
|
|
|
|
// define the four channels
|
1998-11-25 01:33:58 +00:00
|
|
|
// extern fgIOCHANNEL port_a;
|
|
|
|
// extern fgIOCHANNEL port_b;
|
|
|
|
// extern fgIOCHANNEL port_c;
|
|
|
|
// extern fgIOCHANNEL port_d;
|
1998-11-16 13:57:42 +00:00
|
|
|
|
|
|
|
|
|
|
|
// initialize serial ports based on command line options (if any)
|
|
|
|
void fgSerialInit();
|
|
|
|
|
|
|
|
|
|
|
|
// process any serial port work
|
|
|
|
void fgSerialProcess();
|
|
|
|
|
|
|
|
|
|
|
|
#endif // _FG_SERIAL_HXX
|
|
|
|
|
|
|
|
|