FlightGear next
nmea.hxx
Go to the documentation of this file.
1// nmea.hxx -- NMEA protocol class
2//
3// Written by Curtis Olson, started November 1999.
4//
5// Copyright (C) 1999 Curtis L. Olson - http://www.flightgear.org/~curt
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License as
9// published by the Free Software Foundation; either version 2 of the
10// License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful, but
13// WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15// General Public License for more details.
16//
17// You should have received a copy of the GNU General Public License
18// along with this program; if not, write to the Free Software
19// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20//
21// $Id$
22
23#pragma once
24
25#include <simgear/compiler.h>
26
27#include <string>
28
29#include "protocol.hxx"
30
32
33namespace NMEA
34{
35 // supported NMEA messages
36 const unsigned int GPRMC = (1<<0);
37 const unsigned int GPGGA = (1<<1);
38 const unsigned int GPGSA = (1<<2);
39
40 const unsigned int SET = (GPRMC|GPGGA|GPGSA);
41}
42
43class FGNMEA : public FGProtocol {
44
45protected:
47 unsigned int mLength;
48 unsigned int mNmeaMessages;
49 unsigned int mMaxReceiveLines;
52 const char* mLineFeed;
53 std::string mNmeaSentence;
54
55 void add_with_checksum(char *sentence, unsigned int buf_size);
56
57 // process a single NMEA line
58 void parse_line();
59
60 // generate output message(s)
61 virtual bool gen_message();
62
63 // process a single NMEA sentence
64 virtual void parse_message(const std::vector<std::string>& tokens);
65
66public:
67 FGNMEA();
68 ~FGNMEA();
69
70 // open hailing frequencies
71 virtual bool open();
72
73 // process work for this port
74 virtual bool process();
75
76 // close the channel
77 virtual bool close();
78};
char mBuf[16384]
Definition nmea.hxx:46
void parse_line()
Definition nmea.cxx:181
virtual bool gen_message()
Definition nmea.cxx:61
unsigned int mLength
Definition nmea.hxx:47
unsigned int mMaxReceiveLines
Definition nmea.hxx:49
FlightProperties mFdm
Definition nmea.hxx:51
void add_with_checksum(char *sentence, unsigned int buf_size)
Definition nmea.cxx:43
std::string mNmeaSentence
Definition nmea.hxx:53
~FGNMEA()
Definition nmea.cxx:38
bool mBiDirectionalSupport
Definition nmea.hxx:50
FGNMEA()
Definition nmea.cxx:27
virtual bool open()
Definition nmea.cxx:350
const char * mLineFeed
Definition nmea.hxx:52
virtual bool close()
Definition nmea.cxx:415
unsigned int mNmeaMessages
Definition nmea.hxx:48
virtual bool process()
Definition nmea.cxx:380
virtual bool parse_message()
Definition protocol.cxx:105
Encapsulate the FDM properties in some getter/setter helpers.
Definition flarm.hxx:29
const unsigned int SET
Definition nmea.hxx:40
const unsigned int GPGSA
Definition nmea.hxx:38
const unsigned int GPGGA
Definition nmea.hxx:37
const unsigned int GPRMC
Definition nmea.hxx:36
#define FG_MAX_MSG_SIZE
Definition protocol.hxx:33