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"
42 NMEAParser::ReadGeoPoint(NMEAInputLine
&line
, GeoPoint
&value_r
)
48 NMEAParser::ReadDate(NMEAInputLine
&line
, BrokenDate
&date
)
54 NMEAParser::TimeHasAdvanced(fixed this_time
, fixed
&last_time
, NMEAInfo
&info
)
60 NMEAParser::TimeModify(fixed fix_time
, BrokenDateTime
&date_time
,
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
);
90 ConsoleOperationEnvironment env
;
91 RecordedFlightList flight_list
;
92 const struct DeviceRegister
*driver
= FindDriverByName(driver_name
.c_str());
94 fprintf(stderr
, "No such driver: %s\n", argv
[1]);
98 if (!driver
->IsLogger()) {
99 fprintf(stderr
, "Not a logger driver: %s\n", argv
[1]);
103 assert(driver
->CreateOnPort
!= NULL
);
105 InitialiseIOThread();
107 Port
*port
= OpenPort(config
, *(DataHandler
*)NULL
);
109 fprintf(stderr
, "Failed to open COM port\n");
113 Device
*device
= driver
->CreateOnPort(config
, *port
);
114 assert(device
!= NULL
);
116 if (!device
->ReadFlightList(flight_list
, env
)) {
118 fprintf(stderr
, "Failed to download flight list\n");
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
);