2 * Copyright © 2011 Keith Packard <keithp@keithp.com>
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; version 2 of the License.
8 * This program is distributed in the hope that it will be useful, but
9 * WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * General Public License for more details.
13 * You should have received a copy of the GNU General Public License along
14 * with this program; if not, write to the Free Software Foundation, Inc.,
15 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
26 static const struct option options[] = {
30 static void usage(char *program)
32 fprintf(stderr, "usage: %s\n"
33 "\t{flight-log} ...\n", program);
38 main (int argc, char **argv)
45 while ((c = getopt_long(argc, argv, "", options, NULL)) != -1) {
52 for (i = optind; i < argc; i++) {
53 file = fopen(argv[i], "r");
59 s = strstr(argv[i], "-serial-");
64 while (fgets(line, sizeof (line), file)) {
65 union ao_telemetry_all telem;
66 char call[AO_MAX_CALLSIGN+1];
67 char version[AO_MAX_VERSION+1];
69 if (cc_telemetry_parse(line, &telem)) {
70 printf ("serial %5d tick %5d type %3d ",
71 telem.generic.serial, telem.generic.tick, telem.generic.type);
72 switch (telem.generic.type) {
73 case AO_TELEMETRY_SENSOR_TELEMETRUM:
74 case AO_TELEMETRY_SENSOR_TELEMINI:
75 case AO_TELEMETRY_SENSOR_TELENANO:
76 printf ("state %1d accel %5d pres %5d ",
77 telem.sensor.state, telem.sensor.accel, telem.sensor.pres);
78 printf ("accel %5d speed %5d height %5d ",
79 telem.sensor.acceleration,
82 printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d\n",
83 telem.sensor.ground_pres,
84 telem.sensor.ground_accel,
85 telem.sensor.accel_plus_g,
86 telem.sensor.accel_minus_g);
88 case AO_TELEMETRY_CONFIGURATION:
89 memcpy(call, telem.configuration.callsign, AO_MAX_CALLSIGN);
90 memcpy(version, telem.configuration.version, AO_MAX_VERSION);
91 call[AO_MAX_CALLSIGN] = '\0';
92 version[AO_MAX_CALLSIGN] = '\0';
93 printf ("device %3d flight %5d config %3d.%03d delay %2d main %4d",
94 telem.configuration.device,
95 telem.configuration.flight,
96 telem.configuration.config_major,
97 telem.configuration.config_minor,
98 telem.configuration.apogee_delay,
99 telem.configuration.main_deploy,
100 telem.configuration.flight_log_max);
101 printf (" call %8s version %8s\n", call, version);