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.
18 package org.altusmetrum.AltosLib;
21 import java.util.concurrent.*;
24 * Extract a bit of information from an eeprom-stored flight log.
27 public class AltosEepromLog {
29 public boolean has_flight;
31 public int start_block;
34 public int year, month, day;
36 public boolean selected;
38 public AltosEepromLog(AltosConfigData config_data,
40 int in_flight, int in_start_block,
42 throws InterruptedException, TimeoutException {
45 boolean has_date = false;
50 start_block = in_start_block;
51 end_block = in_end_block;
52 serial = config_data.serial;
55 * Select all flights for download
60 * Look in TeleMetrum log data for date
62 if (config_data.log_format == AltosLib.AO_LOG_FORMAT_UNKNOWN ||
63 config_data.log_format == AltosLib.AO_LOG_FORMAT_FULL)
66 * Only look in the first two blocks so that this
67 * process doesn't take a long time
69 if (in_end_block > in_start_block + 2)
70 in_end_block = in_start_block + 2;
72 for (block = in_start_block; block < in_end_block; block++) {
73 AltosEepromChunk eechunk = new AltosEepromChunk(link, block, block == in_start_block);
75 for (int i = 0; i < AltosEepromChunk.chunk_size; i += AltosEepromRecord.record_length) {
77 AltosEepromRecord r = new AltosEepromRecord(eechunk, i);
79 if (r.cmd == AltosLib.AO_LOG_FLIGHT) {
83 if (r.cmd == AltosLib.AO_LOG_GPS_DATE) {
84 year = 2000 + (r.a & 0xff);
85 month = (r.a >> 8) & 0xff;
89 } catch (ParseException pe) {
92 if (has_date && has_flight)