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);
37 #define bool(b) ((b) ? "true" : "false")
40 main (int argc, char **argv)
47 while ((c = getopt_long(argc, argv, "", options, NULL)) != -1) {
54 for (i = optind; i < argc; i++) {
55 file = fopen(argv[i], "r");
61 s = strstr(argv[i], "-serial-");
66 while (fgets(line, sizeof (line), file)) {
67 union ao_telemetry_all telem;
68 char call[AO_MAX_CALLSIGN+1];
69 char version[AO_MAX_VERSION+1];
71 if (cc_telemetry_parse(line, &telem)) {
72 int rssi = (int8_t) telem.generic.rssi / 2 - 74;
74 printf ("serial %5d rssi %d status %02x tick %5d type %3d ",
75 telem.generic.serial, rssi, telem.generic.status,
76 telem.generic.tick, telem.generic.type);
77 if ((telem.generic.status & (1 << 7)) == 0) {
78 printf ("CRC error\n");
81 switch (telem.generic.type) {
82 case AO_TELEMETRY_SENSOR_TELEMETRUM:
83 case AO_TELEMETRY_SENSOR_TELEMINI:
84 case AO_TELEMETRY_SENSOR_TELENANO:
85 printf ("state %1d accel %5d pres %5d ",
86 telem.sensor.state, telem.sensor.accel, telem.sensor.pres);
87 printf ("accel %6.2f speed %6.2f height %5d ",
88 telem.sensor.acceleration / 16.0,
89 telem.sensor.speed / 16.0,
91 printf ("ground_pres %5d ground_accel %5d accel_plus %5d accel_minus %5d\n",
92 telem.sensor.ground_pres,
93 telem.sensor.ground_accel,
94 telem.sensor.accel_plus_g,
95 telem.sensor.accel_minus_g);
97 case AO_TELEMETRY_CONFIGURATION:
98 memcpy(call, telem.configuration.callsign, AO_MAX_CALLSIGN);
99 memcpy(version, telem.configuration.version, AO_MAX_VERSION);
100 call[AO_MAX_CALLSIGN] = '\0';
101 version[AO_MAX_CALLSIGN] = '\0';
102 printf ("device %3d flight %5d config %3d.%03d delay %2d main %4d",
103 telem.configuration.device,
104 telem.configuration.flight,
105 telem.configuration.config_major,
106 telem.configuration.config_minor,
107 telem.configuration.apogee_delay,
108 telem.configuration.main_deploy,
109 telem.configuration.flight_log_max);
110 printf (" call %8s version %8s\n", call, version);
112 case AO_TELEMETRY_LOCATION:
113 printf ("sats %d flags %s%s%s%s",
114 telem.location.flags & 0xf,
115 (telem.location.flags & (1 << 4)) ? "valid" : "invalid",
116 (telem.location.flags & (1 << 5)) ? ",running" : "",
117 (telem.location.flags & (1 << 6)) ? ",date" : "",
118 (telem.location.flags & (1 << 7)) ? ",course" : "");
119 printf (" alt %5d lat %12.7f lon %12.7f",
120 telem.location.altitude,
121 telem.location.latitude / 1e7,
122 telem.location.longitude / 1e7);
123 if ((telem.location.flags & (1 << 6)) != 0) {
124 printf (" year %2d month %2d day %2d",
126 telem.location.month,
128 printf (" hour %2d minute %2d second %2d",
130 telem.location.minute,
131 telem.location.second);
133 printf (" pdop %3.1f hdop %3.1f vdop %3.1f mode %d",
134 telem.location.pdop / 5.0,
135 telem.location.hdop / 5.0,
136 telem.location.vdop / 5.0,
137 telem.location.mode);
138 if ((telem.location.flags & (1 << 7)) != 0)
139 printf (" ground_speed %6.2f climb_rate %6.2f course %d",
140 telem.location.ground_speed / 100.0,
141 telem.location.climb_rate / 100.0,
142 telem.location.course * 2);
145 case AO_TELEMETRY_SATELLITE:
146 printf ("sats %d", telem.satellite.channels);
147 for (c = 0; c < 12 && c < telem.satellite.channels; c++) {
148 printf (" sat %d svid %d c_n_1 %d",
150 telem.satellite.sats[c].svid,
151 telem.satellite.sats[c].c_n_1);