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 #include "Device/Driver/ILEC.hpp"
25 #include "Device/Parser.hpp"
26 #include "Device/Driver.hpp"
27 #include "NMEA/Checksum.hpp"
28 #include "NMEA/Info.hpp"
29 #include "NMEA/InputLine.hpp"
30 #include "Units/System.hpp"
35 class ILECDevice
: public AbstractDevice
{
37 virtual bool ParseNMEA(const char *line
, struct NMEAInfo
&info
) override
;
41 ReadSpeedVector(NMEAInputLine
&line
, SpeedVector
&value_r
)
45 bool bearing_valid
= line
.ReadChecked(bearing
);
46 bool norm_valid
= line
.ReadChecked(norm
);
48 if (bearing_valid
&& norm_valid
) {
49 value_r
.norm
= Units::ToSysUnit(norm
, Unit::KILOMETER_PER_HOUR
);
50 value_r
.bearing
= Angle::Degrees(bearing
);
57 * Parse a "$PILC,PDA1" sentence.
59 * Example: "$PILC,PDA1,1489,-3.21,274,15,58*7D"
62 ParsePDA1(NMEAInputLine
&line
, NMEAInfo
&info
)
68 if (line
.ReadChecked(altitude
))
69 info
.ProvideBaroAltitudeTrue(fixed(altitude
));
71 // total energy vario [m/s]
72 if (line
.ReadChecked(value
))
73 info
.ProvideTotalEnergyVario(value
);
75 // wind direction [degrees, kph]
77 if (ReadSpeedVector(line
, wind
))
78 info
.ProvideExternalWind(wind
);
80 // confidence [0..100]
87 ILECDevice::ParseNMEA(const char *_line
, NMEAInfo
&info
)
89 if (!VerifyNMEAChecksum(_line
))
92 NMEAInputLine
line(_line
);
94 line
.Read(type
, sizeof(type
));
96 if (StringIsEqual(type
, "$PILC")) {
97 line
.Read(type
, sizeof(type
));
98 if (StringIsEqual(type
, "PDA1"))
99 return ParsePDA1(line
, info
);
107 ILECCreateOnPort(const DeviceConfig
&config
, Port
&com_port
)
109 return new ILECDevice();
112 const struct DeviceRegister ilec_driver
= {