nidas v1.2.3
GPS_NMEA_Serial.h
Go to the documentation of this file.
1// -*- mode: C++; indent-tabs-mode: nil; c-basic-offset: 4; tab-width: 4; -*-
2// vim: set shiftwidth=4 softtabstop=4 expandtab:
3/*
4 ********************************************************************
5 ** NIDAS: NCAR In-situ Data Acquistion Software
6 **
7 ** 2005, Copyright University Corporation for Atmospheric Research
8 **
9 ** This program is free software; you can redistribute it and/or modify
10 ** it under the terms of the GNU General Public License as published by
11 ** the Free Software Foundation; either version 2 of the License, or
12 ** (at your option) any later version.
13 **
14 ** This program is distributed in the hope that it will be useful,
15 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
16 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 ** GNU General Public License for more details.
18 **
19 ** The LICENSE.txt file accompanying this software contains
20 ** a copy of the GNU General Public License. If it is not found,
21 ** write to the Free Software Foundation, Inc.,
22 ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23 **
24 ********************************************************************
25*/
26
27#ifndef NIDIS_DYNLD_GPS_NMEA_SERIAL_H
28#define NIDIS_DYNLD_GPS_NMEA_SERIAL_H
29
31
32namespace nidas { namespace dynld {
33
34 using namespace nidas::core;
35
42{
43public:
44
46
50 void validate();
51
59 bool process(const Sample* samp,std::list<const Sample*>& results)
60 throw();
61
66 static bool
67 checksumOK(const char* rec,int len);
68
75 static bool
76 findChecksum(char& checksum, const char* rec, int len);
77
84 static char
85 calcChecksum(const char* rec, int len);
86
92 static void
93 appendChecksum(char* rec, int len, int maxlen);
94
107
108 dsm_time_t parseGGA(const char* input,double *dout,int nvars,dsm_time_t tt)
109 throw();
110
111 dsm_time_t parseRMC(const char* input,double *dout,int nvars,dsm_time_t tt)
112 throw();
113
114 dsm_time_t parseHDT(const char* input,double *dout,int nvars,dsm_time_t tt)
115 throw();
116
117protected:
118
123
128
133
138
143
148
153
157#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
158 static const int GGA_SAMPLE_ID;
159#else
160 static const int GGA_SAMPLE_ID = 1;
161#endif
162
166#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
167 static const int RMC_SAMPLE_ID;
168#else
169 static const int RMC_SAMPLE_ID = 2;
170#endif
171
175#if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
176 static const int HDT_SAMPLE_ID;
177#else
178 static const int HDT_SAMPLE_ID = 3;
179#endif
180
181 unsigned int _badChecksums;
182 unsigned int _badChecksumsCount;
183
189 std::map<int,std::string> _allowedSampleIds;
190};
191
192}} // namespace nidas namespace dynld
193
194#endif
A scanner of sample data.
Definition SampleScanner.h:74
Interface to a data sample.
Definition Sample.h:190
Support for a sensor that is sending packets on a TCP socket, a UDP socket, a Bluetooth RF Comm socke...
Definition SerialSensor.h:65
A class for reading NMEA records from a GPS.
Definition GPS_NMEA_Serial.h:42
dsm_sample_id_t _ggaId
Full sample id of GGA variables.
Definition GPS_NMEA_Serial.h:132
dsm_sample_id_t _hdtId
Full sample id of HDT variables.
Definition GPS_NMEA_Serial.h:152
void validate()
Definition GPS_NMEA_Serial.cc:76
static char calcChecksum(const char *rec, int len)
Given a NMEA message in rec of length len, calculate the checksum of the message and return it.
Definition GPS_NMEA_Serial.cc:575
unsigned int _badChecksumsCount
Definition GPS_NMEA_Serial.h:182
static const int GGA_SAMPLE_ID
Id of sample from GGA NMEA record.
Definition GPS_NMEA_Serial.h:158
std::map< int, std::string > _allowedSampleIds
Derived classes should add their supported sample ids to the map, along with a short descriptive name...
Definition GPS_NMEA_Serial.h:189
static bool findChecksum(char &checksum, const char *rec, int len)
Given a NMEA message in rec of length len, look for the checksum and convert it to a byte value.
Definition GPS_NMEA_Serial.cc:548
static const int HDT_SAMPLE_ID
Id of sample from HDT NMEA record.
Definition GPS_NMEA_Serial.h:176
bool process(const Sample *samp, std::list< const Sample * > &results)
Virtual method that is called to convert a raw sample containing an ASCII NMEA message to a processed...
Definition GPS_NMEA_Serial.cc:606
SampleScanner * buildSampleScanner()
Override SerialSensor::buildSampleScanner() and CharacterSensor::buildSampleScanner(),...
Definition GPS_NMEA_Serial.cc:666
static bool checksumOK(const char *rec, int len)
Calculate the checksum of the NMEA message and return a logical indicating whether it is equal to the...
Definition GPS_NMEA_Serial.cc:601
dsm_time_t parseHDT(const char *input, double *dout, int nvars, dsm_time_t tt)
Parse HDT NMEA message.
Definition GPS_NMEA_Serial.cc:531
dsm_sample_id_t _rmcId
Full sample id of RMC variables.
Definition GPS_NMEA_Serial.h:142
GPS_NMEA_Serial()
Definition GPS_NMEA_Serial.cc:59
dsm_time_t parseGGA(const char *input, double *dout, int nvars, dsm_time_t tt)
Parse GGA NMEA message.
Definition GPS_NMEA_Serial.cc:377
unsigned int _badChecksums
Definition GPS_NMEA_Serial.h:181
static const int RMC_SAMPLE_ID
Id of sample from RMC NMEA record.
Definition GPS_NMEA_Serial.h:167
dsm_time_t _ttgps
Timetag set by parseGGA and parseRMC, used by parseHDT.
Definition GPS_NMEA_Serial.h:122
int _hdtNvars
Number of variables requested from HDT record (sample id == 3)
Definition GPS_NMEA_Serial.h:147
static void appendChecksum(char *rec, int len, int maxlen)
Calculate the checksum for the given message and append it in the form "*%2X", but only if the length...
Definition GPS_NMEA_Serial.cc:594
int _ggaNvars
Number of variables requested from GGA record (sample id == 1)
Definition GPS_NMEA_Serial.h:127
dsm_time_t parseRMC(const char *input, double *dout, int nvars, dsm_time_t tt)
Parse RMC NMEA record.
Definition GPS_NMEA_Serial.cc:193
int _rmcNvars
Number of variables requested from RMC record (sample id == 2)
Definition GPS_NMEA_Serial.h:137
The essential core classes of nidas.
Definition A2DConverter.h:31
long long dsm_time_t
Posix time in microseconds, the number of non-leap microseconds since 1970 Jan 1 00:00 UTC.
Definition Sample.h:62
unsigned int dsm_sample_id_t
Definition Sample.h:64
Root namespace for the NCAR In-Situ Data Acquisition Software.
Definition A2DConverter.h:31
int len
Definition sing.cc:948