4 XCSoar Glide Computer - http://www.xcsoar.org/
5 Copyright (C) 2000-2013 The XCSoar Project
6 A detailed list of copyright holders can be found in the file "AUTHORS".
8 This program is free software; you can redistribute it and/or
9 modify it under the terms of the GNU General Public License
10 as published by the Free Software Foundation; either version 2
11 of the License, or (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
24 #ifndef XCSOAR_DEVICE_PARSER_HPP
25 #define XCSOAR_DEVICE_PARSER_HPP
27 #include "Math/fixed.hpp"
30 struct BrokenDateTime
;
47 NMEAParser(bool ignore_checksum
= false);
50 * Resets the NMEAParser
54 void SetReal(bool _real
) {
58 void SetIgnoreChecksum(bool _ignore_checksum
) {
59 ignore_checksum
= _ignore_checksum
;
67 * Parses a provided NMEA String into a NMEA_INFO struct
68 * @param line NMEA string
69 * @param info NMEA_INFO output struct
70 * @return Parsing success
72 bool ParseLine(const char *line
, NMEAInfo
&info
);
76 * Calculates the checksum of the provided NMEA string and
77 * compares it to the provided checksum
78 * @param String NMEA string
79 * @return True if checksum correct
81 static bool NMEAChecksum(const char *string
);
84 * Checks whether time has advanced since last call and
85 * updates the last_time reference if necessary
86 * @return True if time has advanced since last call
88 static bool TimeHasAdvanced(fixed this_time
, fixed
&last_time
, NMEAInfo
&info
);
91 * Calculates a seconds-based FixTime and corrects it
92 * in case over passing the UTC midnight mark
93 * @param FixTime NMEA format fix time (HHMMSS)
94 * @param info NMEA_INFO struct to parse into
95 * @return Seconds-based FixTime
97 static fixed
TimeModify(fixed fix_time
, BrokenDateTime
&date_time
,
100 static bool ReadGeoPoint(NMEAInputLine
&line
, GeoPoint
&value_r
);
102 static bool ReadDate(NMEAInputLine
&line
, BrokenDate
&date
);
107 * Verifies the given fix time. If it is smaller than LastTime, but
108 * within a certain tolerance, the LastTime is returned, otherwise
109 * the specified time is returned without modification.
111 * This is used to reduce quirks when the time stamps in GPGGA and
112 * GPRMC are off by a second. Without this workaround, XCSoar loses
113 * the GPS fix every now and then, because GPRMC is ignored most of
117 fixed
TimeAdvanceTolerance(fixed time
) const;
120 * Checks whether time has advanced since last call and
121 * updates the GPS_info if necessary
122 * @param ThisTime Current time
123 * @param info NMEA_INFO struct to update
124 * @return True if time has advanced since last call
126 bool TimeHasAdvanced(fixed this_time
, NMEAInfo
&info
);
129 * Parses a GLL sentence
131 * @param line A NMEAInputLine instance that can be used for parsing
132 * @param info NMEA_INFO struct to parse into
133 * @return Parsing success
135 bool GLL(NMEAInputLine
&line
, NMEAInfo
&info
);
138 * Parses a GGA sentence
140 * @param line A NMEAInputLine instance that can be used for parsing
141 * @param info NMEA_INFO struct to parse into
142 * @return Parsing success
144 bool GGA(NMEAInputLine
&line
, NMEAInfo
&info
);
147 * Parses a GSA sentence
149 * @param line A NMEAInputLine instance that can be used for parsing
150 * @param info NMEA_INFO struct to parse into
151 * @return Parsing success
153 bool GSA(NMEAInputLine
&line
, NMEAInfo
&info
);
156 * Parses a RMC sentence
158 * @param line A NMEAInputLine instance that can be used for parsing
159 * @param info NMEA_INFO struct to parse into
160 * @return Parsing success
162 bool RMC(NMEAInputLine
&line
, NMEAInfo
&info
);
165 * Parses a PGRMZ sentence (Garmin proprietary).
167 * @param line A NMEAInputLine instance that can be used for parsing
168 * @param info NMEA_INFO struct to parse into
169 * @return Parsing success
171 bool RMZ(NMEAInputLine
&line
, NMEAInfo
&info
);
174 * Parses a PTAS1 sentence (Tasman Instruments proprietary).
176 * @param line A NMEAInputLine instance that can be used for parsing
177 * @param info NMEA_INFO struct to parse into
178 * @return Parsing success
180 static bool PTAS1(NMEAInputLine
&line
, NMEAInfo
&info
);