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/FlymasterF1.hpp"
25 #include "Device/Driver.hpp"
26 #include "Device/Parser.hpp"
27 #include "Device/Internal.hpp"
28 #include "NMEA/Checksum.hpp"
29 #include "NMEA/Info.hpp"
30 #include "NMEA/InputLine.hpp"
31 #include "Atmosphere/Temperature.hpp"
36 class FlymasterF1Device
: public AbstractDevice
{
40 FlymasterF1Device(Port
&_port
):port(_port
) {}
42 virtual bool EnableNMEA(OperationEnvironment
&env
) override
;
43 virtual bool ParseNMEA(const char *line
, struct NMEAInfo
&info
) override
;
47 FlymasterF1Device::EnableNMEA(OperationEnvironment
&env
)
49 /* this command initiates NMEA mode according to the "Flymaster F1
51 return PortWriteNMEA(port
, "$PFMNAV,", env
);
55 VARIO(NMEAInputLine
&line
, NMEAInfo
&info
)
57 // $VARIO,fPressure,fVario,Bat1Volts,Bat2Volts,BatBank,TempSensor1,TempSensor2*CS
59 // fVario = the variometer in decimeters per second
60 // Bat1Volts = the voltage of the battery in bank 1
61 // Bat2Volts = the voltage of the battery in bank 2
62 // BatBank = the battery bank in use.
63 // TempSensor1 = temperature in ºC of external wireless sensor 1
64 // TempSensor2 = temperature in ºC of external wireless sensor 2
67 if (line
.ReadChecked(value
))
68 info
.ProvideStaticPressure(AtmosphericPressure::HectoPascal(value
));
70 if (line
.ReadChecked(value
))
71 info
.ProvideTotalEnergyVario(value
/ 10);
73 unsigned battery_bank
;
75 if (line
.ReadChecked(voltage
[0]) &&
76 line
.ReadChecked(voltage
[1]) &&
77 line
.ReadChecked(battery_bank
) &&
80 info
.voltage
= voltage
[battery_bank
- 1];
81 info
.voltage_available
.Update(info
.clock
);
84 if (line
.ReadChecked(value
)) {
85 info
.temperature
= CelsiusToKelvin(value
);
86 info
.temperature_available
= true;
93 FlymasterF1Device::ParseNMEA(const char *String
, NMEAInfo
&info
)
95 if (!VerifyNMEAChecksum(String
))
98 NMEAInputLine
line(String
);
102 if (StringIsEqual(type
, "$VARIO"))
103 return VARIO(line
, info
);
109 FlymasterF1CreateOnPort(const DeviceConfig
&config
, Port
&port
)
111 return new FlymasterF1Device(port
);
114 const struct DeviceRegister flymaster_f1_driver
= {
118 FlymasterF1CreateOnPort
,