}
static void
-analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FILE *raw_file, char *plot_name)
+analyse_flight(struct cc_flightraw *f, FILE *summary_file, FILE *detail_file, FILE *raw_file, char *plot_name, FILE *gps_file)
{
double height;
double accel;
time, pres, accel);
}
}
+ if (gps_file) {
+ int j = 0;
+ fprintf(gps_file, "%9s %12s %12s %12s\n",
+ "time", "lat", "lon", "alt");
+ for (i = 0; i < f->gps.num; i++) {
+ int nsat = 0;
+ int k;
+ while (j < f->gps.numsats - 1) {
+ if (f->gps.sats[j].sat[0].time <= f->gps.data[i].time &&
+ f->gps.data[i].time < f->gps.sats[j+1].sat[0].time)
+ break;
+ j++;
+ }
+ fprintf(gps_file, "%12.7f %12.7f %12.7f %12.7f",
+ (f->gps.data[i].time - boost_start) / 100.0,
+ f->gps.data[i].lat,
+ f->gps.data[i].lon,
+ f->gps.data[i].alt);
+ nsat = 0;
+ for (k = 0; k < f->gps.sats[j].nsat; k++) {
+ fprintf (gps_file, " %12.7f", (double) f->gps.sats[j].sat[k].c_n);
+ if (f->gps.sats[j].sat[k].state == 0xbf)
+ nsat++;
+ }
+ fprintf(gps_file, " %d\n", nsat);
+ }
+ }
if (cooked && plot_name) {
struct cc_perioddata *speed;
plsdev("svgcairo");
{ .name = "detail", .has_arg = 1, .val = 'd' },
{ .name = "plot", .has_arg = 1, .val = 'p' },
{ .name = "raw", .has_arg = 1, .val = 'r' },
+ { .name = "gps", .has_arg = 1, .val = 'g' },
{ 0, 0, 0, 0},
};
"\t[--detail=<detail-file] [-d <detail-file>]\n"
"\t[--raw=<raw-file> -r <raw-file]\n"
"\t[--plot=<plot-file> -p <plot-file>]\n"
+ "\t[--gps=<gps-file> -g <gps-file>]\n"
"\t{flight-log} ...\n", program);
exit(1);
}
FILE *summary_file = NULL;
FILE *detail_file = NULL;
FILE *raw_file = NULL;
+ FILE *gps_file = NULL;
int i;
int ret = 0;
struct cc_flightraw *raw;
char *detail_name = NULL;
char *raw_name = NULL;
char *plot_name = NULL;
+ char *gps_name = NULL;
- while ((c = getopt_long(argc, argv, "s:d:p:r:", options, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv, "s:d:p:r:g:", options, NULL)) != -1) {
switch (c) {
case 's':
summary_name = optarg;
case 'r':
raw_name = optarg;
break;
+ case 'g':
+ gps_name = optarg;
+ break;
default:
usage(argv[0]);
break;
exit(1);
}
}
+ if (gps_name) {
+ gps_file = fopen(gps_name, "w");
+ if (!gps_file) {
+ perror(gps_name);
+ exit(1);
+ }
+ }
for (i = optind; i < argc; i++) {
file = fopen(argv[i], "r");
if (!file) {
}
if (!raw->serial)
raw->serial = serial;
- analyse_flight(raw, summary_file, detail_file, raw_file, plot_name);
+ analyse_flight(raw, summary_file, detail_file, raw_file, plot_name, gps_file);
cc_flightraw_free(raw);
}
return ret;