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.mega} ...\n", program);
37 #define bool(b) ((b) ? "true" : "false")
39 static const char *state_names[] = {
53 #define NUM_STATE (sizeof state_names/sizeof state_names[0])
56 main (int argc, char **argv)
64 while ((c = getopt_long(argc, argv, "", options, NULL)) != -1) {
71 for (i = optind; i < argc; i++) {
72 file = fopen(argv[i], "r");
78 s = strstr(argv[i], "-serial-");
83 while (fgets(line, sizeof (line), file)) {
84 struct ao_log_mega log;
86 if (cc_mega_parse(line, &log)) {
88 printf ("kind %d\n", log.u.config_int.kind);
90 printf ("tick %5d ", log.tick);
93 printf ("flight %5u ground_accel %d ground_pres %u\n",
95 log.u.flight.ground_accel,
96 log.u.flight.ground_pres);
99 if (log.u.state.state < NUM_STATE)
100 state = state_names[log.u.state.state];
103 printf ("state %d (%s)\n", log.u.state.state, state);
106 printf ("p %9u t %9u ax %6d ay %6d az %6d gx %6d gy %6d gz %6d mx %6d my %6d mz %6d a %6d\n",
109 log.u.sensor.accel_x,
110 log.u.sensor.accel_y,
111 log.u.sensor.accel_z,
120 case AO_LOG_TEMP_VOLT:
121 printf ("batt %6d pbatt %6d n_sense %d",
125 for (j = 0; j < log.u.volt.n_sense; j++) {
127 j, log.u.volt.sense[j]);
129 printf ("pyro %04x\n", log.u.volt.pyro);
133 printf ("type %c\n", log.type, log.tick);