android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / test / src / DebugReplayNMEA.cpp
blob2277e348684c2db1a1b41e476f32c30d2be0ba98
1 /*
2 Copyright_License {
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 "DebugReplayNMEA.hpp"
25 #include "IO/FileLineReader.hpp"
26 #include "Device/Driver.hpp"
27 #include "Device/Register.hpp"
28 #include "Device/Port/NullPort.hpp"
29 #include "Device/Parser.hpp"
30 #include "Profile/DeviceConfig.hpp"
32 static DeviceConfig config;
33 static NullPort port;
35 DebugReplayNMEA::DebugReplayNMEA(NLineReader *_reader,
36 const DeviceRegister *driver)
37 :DebugReplay(_reader),
38 device(driver->CreateOnPort != NULL
39 ? driver->CreateOnPort(config, port)
40 : NULL)
44 bool
45 DebugReplayNMEA::Next()
47 last_basic = computed_basic;
49 const char *line;
50 while ((line = reader->ReadLine()) != NULL) {
51 if (raw_basic.time_available)
52 raw_basic.clock = raw_basic.time;
53 if (!device || !device->ParseNMEA(line, raw_basic))
54 parser.ParseLine(line, raw_basic);
56 if (raw_basic.location_available != last_basic.location_available) {
57 Compute();
58 return true;
62 if (computed_basic.time_available)
63 flying_computer.Finish(calculated.flight, computed_basic.time);
65 return false;