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.
21 import java.awt.event.*;
23 import javax.swing.filechooser.FileNameExtensionFilter;
24 import javax.swing.table.*;
28 import java.util.prefs.*;
29 import java.util.concurrent.*;
34 * Extract a bit of information from an eeprom-stored flight log.
37 public class AltosEepromLog {
49 public AltosEepromLog(AltosSerial serial_line, int in_serial,
50 int in_flight, int in_start_block,
52 throws InterruptedException, TimeoutException {
55 boolean has_date = false;
57 start_block = in_start_block;
58 end_block = in_end_block;
62 * By default, request that every log be downloaded but not deleted
67 * Only look in the first two blocks so that this
68 * process doesn't take a long time
70 if (in_end_block > in_start_block + 2)
71 in_end_block = in_start_block + 2;
73 for (block = in_start_block; block < in_end_block; block++) {
74 AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block);
76 if (block == in_start_block) {
77 if (eechunk.data16(0) == in_flight) {
83 for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) {
85 AltosEepromRecord r = new AltosEepromRecord(eechunk, i);
87 if (r.cmd == Altos.AO_LOG_FLIGHT) {
91 if (r.cmd == Altos.AO_LOG_GPS_DATE) {
92 year = 2000 + (r.a & 0xff);
93 month = (r.a >> 8) & 0xff;
97 } catch (ParseException pe) {
100 if (has_date && has_flight)