android/GlueIOIOPort: fix spurious errors after IOIO baud rate change
[xcsoar.git] / test / src / RunFlightList.cpp
blob90e959a6299974c53cb9baf54c5deb4629868ea2
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 "DebugPort.hpp"
25 #include "Device/Port/Port.hpp"
26 #include "Device/Port/ConfiguredPort.hpp"
27 #include "Device/Driver.hpp"
28 #include "Device/Driver/FLARM/Device.hpp"
29 #include "Device/Register.hpp"
30 #include "Device/Parser.hpp"
31 #include "Device/device.hpp"
32 #include "Engine/Waypoint/Waypoints.hpp"
33 #include "OS/Args.hpp"
34 #include "Operation/ConsoleOperationEnvironment.hpp"
35 #include "Profile/DeviceConfig.hpp"
36 #include "IO/Async/GlobalIOThread.hpp"
37 #include "Util/ConvertString.hpp"
39 #include <stdio.h>
41 bool
42 NMEAParser::ReadGeoPoint(NMEAInputLine &line, GeoPoint &value_r)
44 return false;
47 bool
48 NMEAParser::ReadDate(NMEAInputLine &line, BrokenDate &date)
50 return false;
53 bool
54 NMEAParser::TimeHasAdvanced(fixed this_time, fixed &last_time, NMEAInfo &info)
56 return false;
59 fixed
60 NMEAParser::TimeModify(fixed fix_time, BrokenDateTime &date_time,
61 bool date_available)
63 return fixed(0);
67 * The actual code.
70 int main(int argc, char **argv)
72 NarrowString<1024> usage;
73 usage = "DRIVER PORT BAUD\n\n"
74 "Where DRIVER is one of:";
76 const DeviceRegister *driver;
77 for (unsigned i = 0; (driver = GetDriverByIndex(i)) != NULL; ++i) {
78 if (driver->IsLogger()) {
79 WideToUTF8Converter driver_name(driver->name);
80 usage.AppendFormat("\n\t%s", (const char *)driver_name);
85 Args args(argc, argv, usage);
86 tstring driver_name = args.ExpectNextT();
87 const DeviceConfig config = ParsePortArgs(args);
88 args.ExpectEnd();
90 ConsoleOperationEnvironment env;
91 RecordedFlightList flight_list;
92 const struct DeviceRegister *driver = FindDriverByName(driver_name.c_str());
93 if (driver == NULL) {
94 fprintf(stderr, "No such driver: %s\n", argv[1]);
95 return EXIT_FAILURE;
98 if (!driver->IsLogger()) {
99 fprintf(stderr, "Not a logger driver: %s\n", argv[1]);
100 return EXIT_FAILURE;
103 assert(driver->CreateOnPort != NULL);
105 InitialiseIOThread();
107 Port *port = OpenPort(config, *(DataHandler *)NULL);
108 if (port == NULL) {
109 fprintf(stderr, "Failed to open COM port\n");
110 return EXIT_FAILURE;
113 Device *device = driver->CreateOnPort(config, *port);
114 assert(device != NULL);
116 if (!device->ReadFlightList(flight_list, env)) {
117 delete device;
118 fprintf(stderr, "Failed to download flight list\n");
119 return EXIT_FAILURE;
122 delete device;
123 delete port;
124 DeinitialiseIOThread();
126 for (auto i = flight_list.begin(); i != flight_list.end(); ++i) {
127 const RecordedFlightInfo &flight = *i;
128 printf("%04u/%02u/%02u %02u:%02u-%02u:%02u\n",
129 flight.date.year, flight.date.month, flight.date.day,
130 flight.start_time.hour, flight.start_time.minute,
131 flight.end_time.hour, flight.end_time.minute);