nidas  v1.2-1520
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 
32 namespace nidas { namespace dynld {
33 
34  using namespace nidas::core;
35 
42 {
43 public:
44 
46 
47  void validate() throw(nidas::util::InvalidParameterException);
48 
56  bool process(const Sample* samp,std::list<const Sample*>& results)
57  throw();
58 
63  static bool
64  checksumOK(const char* rec,int len);
65 
72  static bool
73  findChecksum(char& checksum, const char* rec, int len);
74 
81  static char
82  calcChecksum(const char* rec, int len);
83 
89  static void
90  appendChecksum(char* rec, int len, int maxlen);
91 
101  SampleScanner* buildSampleScanner()
103 
104  dsm_time_t parseGGA(const char* input,double *dout,int nvars,dsm_time_t tt)
105  throw();
106 
107  dsm_time_t parseRMC(const char* input,double *dout,int nvars,dsm_time_t tt)
108  throw();
109 
110  dsm_time_t parseHDT(const char* input,double *dout,int nvars,dsm_time_t tt)
111  throw();
112 
113 protected:
114 
119 
124 
129 
134 
139 
144 
149 
153 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
154  static const int GGA_SAMPLE_ID;
155 #else
156  static const int GGA_SAMPLE_ID = 1;
157 #endif
158 
162 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
163  static const int RMC_SAMPLE_ID;
164 #else
165  static const int RMC_SAMPLE_ID = 2;
166 #endif
167 
171 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 7)
172  static const int HDT_SAMPLE_ID;
173 #else
174  static const int HDT_SAMPLE_ID = 3;
175 #endif
176 
177  unsigned int _badChecksums;
178  unsigned int _badChecksumsCount;
179 
185  std::map<int,std::string> _allowedSampleIds;
186 };
187 
188 }} // namespace nidas namespace dynld
189 
190 #endif
unsigned int _badChecksumsCount
Definition: GPS_NMEA_Serial.h:178
A class for reading NMEA records from a GPS.
Definition: GPS_NMEA_Serial.h:41
unsigned int dsm_sample_id_t
Definition: Sample.h:63
static const int RMC_SAMPLE_ID
Id of sample from RMC NMEA record.
Definition: GPS_NMEA_Serial.h:163
unsigned int _badChecksums
Definition: GPS_NMEA_Serial.h:177
Support for a sensor that is sending packets on a TCP socket, a UDP socket, a Bluetooth RF Comm socke...
Definition: SerialSensor.h:64
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:61
int _ggaNvars
Number of variables requested from GGA record (sample id == 1)
Definition: GPS_NMEA_Serial.h:123
static const int GGA_SAMPLE_ID
Id of sample from GGA NMEA record.
Definition: GPS_NMEA_Serial.h:154
static const int HDT_SAMPLE_ID
Id of sample from HDT NMEA record.
Definition: GPS_NMEA_Serial.h:172
int _rmcNvars
Number of variables requested from RMC record (sample id == 2)
Definition: GPS_NMEA_Serial.h:133
int _hdtNvars
Number of variables requested from HDT record (sample id == 3)
Definition: GPS_NMEA_Serial.h:143
dsm_sample_id_t _ggaId
Full sample id of GGA variables.
Definition: GPS_NMEA_Serial.h:128
dsm_sample_id_t _hdtId
Full sample id of HDT variables.
Definition: GPS_NMEA_Serial.h:148
int len
Definition: sing.cc:934
Interface to a data sample.
Definition: Sample.h:189
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:185
A scanner of sample data.
Definition: SampleScanner.h:73
dsm_time_t _ttgps
Timetag set by parseGGA and parseRMC, used by parseHDT.
Definition: GPS_NMEA_Serial.h:118
dsm_sample_id_t _rmcId
Full sample id of RMC variables.
Definition: GPS_NMEA_Serial.h:138
Definition: InvalidParameterException.h:35