From 3fbefb3eea981d34a09496cf8abf0119de2e35bf Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 24 Nov 2010 14:57:57 -0800 Subject: Move altosui to the top level, placing libaltos inside it. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 285 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 285 insertions(+) create mode 100644 altosui/AltosEepromDownload.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java new file mode 100644 index 00000000..02fc36f2 --- /dev/null +++ b/altosui/AltosEepromDownload.java @@ -0,0 +1,285 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +import libaltosJNI.*; + +public class AltosEepromDownload implements Runnable { + + static final String[] state_names = { + "startup", + "idle", + "pad", + "boost", + "fast", + "coast", + "drogue", + "main", + "landed", + "invalid", + }; + + int[] ParseHex(String line) { + String[] tokens = line.split("\\s+"); + int[] array = new int[tokens.length]; + + for (int i = 0; i < tokens.length; i++) + try { + array[i] = Integer.parseInt(tokens[i], 16); + } catch (NumberFormatException ne) { + return null; + } + return array; + } + + int checksum(int[] line) { + int csum = 0x5a; + for (int i = 1; i < line.length; i++) + csum += line[i]; + return csum & 0xff; + } + + void FlushPending(FileWriter file, LinkedList pending) throws IOException { + while (!pending.isEmpty()) { + file.write(pending.remove()); + } + } + + JFrame frame; + AltosDevice device; + AltosSerial serial_line; + boolean remote; + Thread eeprom_thread; + AltosEepromMonitor monitor; + + void CaptureLog() throws IOException, InterruptedException, TimeoutException { + int serial = 0; + int block, state_block = 0; + int addr; + int flight = 0; + int year = 0, month = 0, day = 0; + int state = 0; + boolean done = false; + boolean want_file = false; + boolean any_valid; + FileWriter eeprom_file = null; + AltosFile eeprom_name; + LinkedList eeprom_pending = new LinkedList(); + + serial_line.printf("\nc s\nv\n"); + + /* Pull the serial number out of the version information */ + + for (;;) { + String line = serial_line.get_reply(5000); + + if (line == null) + throw new TimeoutException(); + if (line.startsWith("serial-number")) { + try { + serial = Integer.parseInt(line.substring(13).trim()); + } catch (NumberFormatException ne) { + serial = 0; + } + } + + eeprom_pending.add(String.format("%s\n", line)); + + /* signals the end of the version info */ + if (line.startsWith("software-version")) + break; + } + if (serial == 0) + throw new IOException("no serial number found"); + + monitor.set_serial(serial); + /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */ + + state = 0; state_block = 0; + for (block = 0; !done && block < 511; block++) { + serial_line.printf("e %x\n", block); + any_valid = false; + monitor.set_value(state_names[state], state, block - state_block); + for (addr = 0; addr < 0x100;) { + String line = serial_line.get_reply(5000); + if (line == null) + throw new TimeoutException(); + int[] values = ParseHex(line); + + if (values == null) { + System.out.printf("invalid line: %s\n", line); + continue; + } else if (values[0] != addr) { + System.out.printf("data address out of sync at 0x%x\n", + block * 256 + values[0]); + } else if (checksum(values) != 0) { + System.out.printf("invalid checksum at 0x%x\n", + block * 256 + values[0]); + } else { + any_valid = true; + int cmd = values[1]; + int tick = values[3] + (values[4] << 8); + int a = values[5] + (values[6] << 8); + int b = values[7] + (values[8] << 8); + + if (cmd == Altos.AO_LOG_FLIGHT) { + flight = b; + monitor.set_flight(flight); + } + + /* Monitor state transitions to update display */ + if (cmd == Altos.AO_LOG_STATE && a <= Altos.ao_flight_landed) { + if (a > Altos.ao_flight_pad) + want_file = true; + if (a > state) + state_block = block; + state = a; + } + + if (cmd == Altos.AO_LOG_GPS_DATE) { + year = 2000 + (a & 0xff); + month = (a >> 8) & 0xff; + day = (b & 0xff); + want_file = true; + } + + if (eeprom_file == null) { + if (serial != 0 && flight != 0 && want_file) { + if (year != 0 && month != 0 && day != 0) + eeprom_name = new AltosFile(year, month, day, serial, flight, "eeprom"); + else + eeprom_name = new AltosFile(serial, flight, "eeprom"); + + monitor.set_file(eeprom_name.getName()); + eeprom_file = new FileWriter(eeprom_name); + if (eeprom_file != null) { + FlushPending(eeprom_file, eeprom_pending); + eeprom_pending = null; + } + } + } + + String log_line = String.format("%c %4x %4x %4x\n", + cmd, tick, a, b); + if (eeprom_file != null) + eeprom_file.write(log_line); + else + eeprom_pending.add(log_line); + + if (cmd == Altos.AO_LOG_STATE && a == Altos.ao_flight_landed) { + done = true; + } + } + addr += 8; + } + if (!any_valid) + done = true; + } + if (eeprom_file == null) { + eeprom_name = new AltosFile(serial,flight,"eeprom"); + eeprom_file = new FileWriter(eeprom_name); + if (eeprom_file != null) { + FlushPending(eeprom_file, eeprom_pending); + } + } + if (eeprom_file != null) { + eeprom_file.flush(); + eeprom_file.close(); + } + } + + public void run () { + if (remote) { + serial_line.set_radio(); + serial_line.printf("p\nE 0\n"); + serial_line.flush_input(); + } + + monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed); + monitor.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + eeprom_thread.interrupt(); + } + }); + try { + CaptureLog(); + } catch (IOException ee) { + JOptionPane.showMessageDialog(frame, + device.toShortString(), + ee.getLocalizedMessage(), + JOptionPane.ERROR_MESSAGE); + } catch (InterruptedException ie) { + } catch (TimeoutException te) { + JOptionPane.showMessageDialog(frame, + String.format("Connection to \"%s\" failed", + device.toShortString()), + "Connection Failed", + JOptionPane.ERROR_MESSAGE); + } + if (remote) + serial_line.printf("~"); + monitor.done(); + serial_line.flush_output(); + serial_line.close(); + } + + public AltosEepromDownload(JFrame given_frame) { + frame = given_frame; + device = AltosDeviceDialog.show(frame, AltosDevice.product_any); + + remote = false; + + if (device != null) { + try { + serial_line = new AltosSerial(device); + if (!device.matchProduct(AltosDevice.product_telemetrum)) + remote = true; + eeprom_thread = new Thread(this); + eeprom_thread.start(); + } catch (FileNotFoundException ee) { + JOptionPane.showMessageDialog(frame, + String.format("Cannot open device \"%s\"", + device.toShortString()), + "Cannot open target device", + JOptionPane.ERROR_MESSAGE); + } catch (AltosSerialInUseException si) { + JOptionPane.showMessageDialog(frame, + String.format("Device \"%s\" already in use", + device.toShortString()), + "Device in use", + JOptionPane.ERROR_MESSAGE); + } catch (IOException ee) { + JOptionPane.showMessageDialog(frame, + device.toShortString(), + ee.getLocalizedMessage(), + JOptionPane.ERROR_MESSAGE); + } + } + } +} -- cgit v1.2.3 From 7f88520089660845009148b69bfcea6c9dff9672 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Thu, 25 Nov 2010 16:23:18 -0800 Subject: altosui: Flight data download GUI operations called only from main thread Swing doesn't like UI functions being called from non-dispatch thread, so fix up the eeprom download code to use SwingUtilities.invokeLater to make sure this works right. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 49 ++++++++++++++++++-------- altosui/AltosEepromMonitor.java | 76 +++++++++++++++++++++++++++++++++++++--- 2 files changed, 105 insertions(+), 20 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 02fc36f2..e5ff766c 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -214,6 +214,27 @@ public class AltosEepromDownload implements Runnable { } } + private void show_error_internal(String message, String title) { + JOptionPane.showMessageDialog(frame, + message, + title, + JOptionPane.ERROR_MESSAGE); + } + + private void show_error(String in_message, String in_title) { + final String message = in_message; + final String title = in_title; + Runnable r = new Runnable() { + public void run() { + try { + show_error_internal(message, title); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + public void run () { if (remote) { serial_line.set_radio(); @@ -221,26 +242,16 @@ public class AltosEepromDownload implements Runnable { serial_line.flush_input(); } - monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed); - monitor.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - eeprom_thread.interrupt(); - } - }); try { CaptureLog(); } catch (IOException ee) { - JOptionPane.showMessageDialog(frame, - device.toShortString(), - ee.getLocalizedMessage(), - JOptionPane.ERROR_MESSAGE); + show_error (device.toShortString(), + ee.getLocalizedMessage()); } catch (InterruptedException ie) { } catch (TimeoutException te) { - JOptionPane.showMessageDialog(frame, - String.format("Connection to \"%s\" failed", - device.toShortString()), - "Connection Failed", - JOptionPane.ERROR_MESSAGE); + show_error (String.format("Connection to \"%s\" failed", + device.toShortString()), + "Connection Failed"); } if (remote) serial_line.printf("~"); @@ -260,6 +271,14 @@ public class AltosEepromDownload implements Runnable { serial_line = new AltosSerial(device); if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; + monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed); + monitor.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (eeprom_thread != null) + eeprom_thread.interrupt(); + } + }); + eeprom_thread = new Thread(this); eeprom_thread.start(); } catch (FileNotFoundException ee) { diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index 7ff00ead..13a49a95 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -141,7 +141,7 @@ public class AltosEepromMonitor extends JDialog { cancel.addActionListener(l); } - public void set_value(String state_name, int in_state, int in_block) { + private void set_value_internal(String state_name, int in_state, int in_block) { int block = in_block; int state = in_state; @@ -157,20 +157,86 @@ public class AltosEepromMonitor extends JDialog { pbar.setValue(pos); } - public void set_serial(int serial) { + public void set_value(String in_state_name, int in_state, int in_block) { + final String state_name = in_state_name; + final int state = in_state; + final int block = in_block; + Runnable r = new Runnable() { + public void run() { + try { + set_value_internal(state_name, state, block); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + private void set_serial_internal(int serial) { serial_value.setText(String.format("%d", serial)); } - public void set_flight(int flight) { + public void set_serial(int in_serial) { + final int serial = in_serial; + Runnable r = new Runnable() { + public void run() { + try { + set_serial_internal(serial); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + private void set_flight_internal(int flight) { flight_value.setText(String.format("%d", flight)); } - public void set_file(String file) { + public void set_flight(int in_flight) { + final int flight = in_flight; + Runnable r = new Runnable() { + public void run() { + try { + set_flight_internal(flight); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + private void set_file_internal(String file) { file_value.setText(String.format("%s", file)); } - public void done() { + public void set_file(String in_file) { + final String file = in_file; + Runnable r = new Runnable() { + public void run() { + try { + set_file_internal(file); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + private void done_internal() { setVisible(false); dispose(); } + + public void done() { + Runnable r = new Runnable() { + public void run() { + try { + done_internal(); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } } -- cgit v1.2.3 From bd2480fd757b67557d9c7de42e402034002c3e37 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 11 Jan 2011 15:39:24 -0800 Subject: altosui: Split eeprom download code apart Create separate 'download config data', 'read single record' and 'read block' functions. This code will be shared with future multi-log reading code for new firmware. Signed-off-by: Keith Packard --- altosui/AltosConfigData.java | 109 +++++++++++++++++++ altosui/AltosEepromBlock.java | 82 ++++++++++++++ altosui/AltosEepromDownload.java | 230 ++++++++++++++------------------------- altosui/AltosEepromRecord.java | 47 +++++++- altosui/Makefile.am | 2 + 5 files changed, 318 insertions(+), 152 deletions(-) create mode 100644 altosui/AltosConfigData.java create mode 100644 altosui/AltosEepromBlock.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosConfigData.java b/altosui/AltosConfigData.java new file mode 100644 index 00000000..8c32ed86 --- /dev/null +++ b/altosui/AltosConfigData.java @@ -0,0 +1,109 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +import libaltosJNI.*; + +public class AltosConfigData implements Iterable { + + /* Version information */ + String manufacturer; + String product; + String version; + int serial; + + /* Strings returned */ + LinkedList lines; + + /* Config information */ + int config_major; + int config_minor; + int main_deploy; + int apogee_delay; + int radio_channel; + String callsign; + int accel_cal_plus, accel_cal_minus; + int radio_calibration; + int flight_log_max; + + + static String get_string(String line, String label) throws ParseException { + if (line.startsWith(label)) { + String quoted = line.substring(label.length()).trim(); + + if (quoted.startsWith("\"")) + quoted = quoted.substring(1); + if (quoted.endsWith("\"")) + quoted = quoted.substring(0,quoted.length()-1); + return quoted; + } + throw new ParseException("mismatch", 0); + } + + static int get_int(String line, String label) throws NumberFormatException, ParseException { + if (line.startsWith(label)) { + String tail = line.substring(label.length()).trim(); + String[] tokens = tail.split("\\s+"); + if (tokens.length > 0) + return Integer.parseInt(tokens[0]); + } + throw new ParseException("mismatch", 0); + } + + public Iterator iterator() { + return lines.iterator(); + } + + public AltosConfigData(AltosSerial serial_line) throws InterruptedException, TimeoutException { + serial_line.printf("c s\nv\n"); + lines = new LinkedList(); + for (;;) { + String line = serial_line.get_reply(5000); + if (line == null) + throw new TimeoutException(); + if (line.contains("Syntax error")) + continue; + lines.add(line); + try { serial = get_int(line, "serial-number"); } catch (Exception e) {} + try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {} + try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {} + try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {} + try { radio_calibration = get_int(line, "Radio cal:"); } catch (Exception e) {} + try { flight_log_max = get_int(line, "Max flight log:"); } catch (Exception e) {} + try { callsign = get_string(line, "Callsign:"); } catch (Exception e) {} + try { version = get_string(line,"software-version"); } catch (Exception e) {} + try { product = get_string(line,"product"); } catch (Exception e) {} + + /* signals the end of the version info */ + if (line.startsWith("software-version")) + break; + } + } + +} \ No newline at end of file diff --git a/altosui/AltosEepromBlock.java b/altosui/AltosEepromBlock.java new file mode 100644 index 00000000..0c1a4a92 --- /dev/null +++ b/altosui/AltosEepromBlock.java @@ -0,0 +1,82 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; +import java.lang.reflect.Array; + +import libaltosJNI.*; + +public class AltosEepromBlock extends ArrayList { + boolean has_flight; + int flight; + boolean has_state; + int state; + boolean has_date; + int year, month, day; + + public AltosEepromBlock (AltosSerial serial_line, int block) throws TimeoutException, InterruptedException { + int addr; + boolean done = false; + + has_flight = false; + has_state = false; + has_date = false; + serial_line.printf("e %x\n", block); + for (addr = 0; !done && addr < 0x100;) { + try { + AltosEepromRecord r = new AltosEepromRecord(serial_line, block * 256 + addr); + + if (r.cmd == Altos.AO_LOG_FLIGHT) { + flight = r.b; + has_flight = true; + } + + /* Monitor state transitions to update display */ + if (r.cmd == Altos.AO_LOG_STATE && r.a <= Altos.ao_flight_landed) { + if (!has_state || r.a > state) { + state = r.a; + has_state = true; + } + } + + if (r.cmd == Altos.AO_LOG_GPS_DATE) { + year = 2000 + (r.a & 0xff); + month = (r.a >> 8) & 0xff; + day = (r.b & 0xff); + has_date = true; + } + + if (r.cmd == Altos.AO_LOG_STATE && r.a == Altos.ao_flight_landed) + done = true; + add(addr / 8, r); + } catch (ParseException pe) { + } + addr += 8; + } + } +} \ No newline at end of file diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index e5ff766c..9a748710 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -32,182 +32,105 @@ import libaltosJNI.*; public class AltosEepromDownload implements Runnable { - static final String[] state_names = { - "startup", - "idle", - "pad", - "boost", - "fast", - "coast", - "drogue", - "main", - "landed", - "invalid", - }; - - int[] ParseHex(String line) { - String[] tokens = line.split("\\s+"); - int[] array = new int[tokens.length]; - - for (int i = 0; i < tokens.length; i++) - try { - array[i] = Integer.parseInt(tokens[i], 16); - } catch (NumberFormatException ne) { - return null; - } - return array; - } - - int checksum(int[] line) { - int csum = 0x5a; - for (int i = 1; i < line.length; i++) - csum += line[i]; - return csum & 0xff; - } - - void FlushPending(FileWriter file, LinkedList pending) throws IOException { - while (!pending.isEmpty()) { - file.write(pending.remove()); - } - } - JFrame frame; AltosDevice device; AltosSerial serial_line; boolean remote; Thread eeprom_thread; AltosEepromMonitor monitor; + int serial = 0; + int flight = 0; + int year = 0, month = 0, day = 0; + boolean want_file = false; + FileWriter eeprom_file = null; + LinkedList eeprom_pending = new LinkedList(); + AltosConfigData config_data; + + private void FlushPending() throws IOException { + for (String s : config_data) { + eeprom_file.write(s); + eeprom_file.write('\n'); + } - void CaptureLog() throws IOException, InterruptedException, TimeoutException { - int serial = 0; - int block, state_block = 0; - int addr; - int flight = 0; - int year = 0, month = 0, day = 0; - int state = 0; - boolean done = false; - boolean want_file = false; - boolean any_valid; - FileWriter eeprom_file = null; - AltosFile eeprom_name; - LinkedList eeprom_pending = new LinkedList(); - - serial_line.printf("\nc s\nv\n"); - - /* Pull the serial number out of the version information */ + for (String s : eeprom_pending) + eeprom_file.write(s); + } - for (;;) { - String line = serial_line.get_reply(5000); + private void CheckFile(boolean force) throws IOException { + if (eeprom_file != null) + return; + if (force || (flight != 0 && want_file)) { + AltosFile eeprom_name; + if (year != 0 && month != 0 && day != 0) + eeprom_name = new AltosFile(year, month, day, serial, flight, "eeprom"); + else + eeprom_name = new AltosFile(serial, flight, "eeprom"); - if (line == null) - throw new TimeoutException(); - if (line.startsWith("serial-number")) { - try { - serial = Integer.parseInt(line.substring(13).trim()); - } catch (NumberFormatException ne) { - serial = 0; - } + eeprom_file = new FileWriter(eeprom_name); + if (eeprom_file != null) { + monitor.set_file(eeprom_name.getName()); + FlushPending(); + eeprom_pending = null; } + } + } - eeprom_pending.add(String.format("%s\n", line)); + void CaptureLog(int start_block, int end_block) throws IOException, InterruptedException, TimeoutException { + int block, state_block = 0; + int state = 0; + boolean done = false; + int record; - /* signals the end of the version info */ - if (line.startsWith("software-version")) - break; - } + config_data = new AltosConfigData(serial_line); + serial = config_data.serial; if (serial == 0) throw new IOException("no serial number found"); monitor.set_serial(serial); /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */ - state = 0; state_block = 0; - for (block = 0; !done && block < 511; block++) { - serial_line.printf("e %x\n", block); - any_valid = false; - monitor.set_value(state_names[state], state, block - state_block); - for (addr = 0; addr < 0x100;) { - String line = serial_line.get_reply(5000); - if (line == null) - throw new TimeoutException(); - int[] values = ParseHex(line); - - if (values == null) { - System.out.printf("invalid line: %s\n", line); - continue; - } else if (values[0] != addr) { - System.out.printf("data address out of sync at 0x%x\n", - block * 256 + values[0]); - } else if (checksum(values) != 0) { - System.out.printf("invalid checksum at 0x%x\n", - block * 256 + values[0]); - } else { - any_valid = true; - int cmd = values[1]; - int tick = values[3] + (values[4] << 8); - int a = values[5] + (values[6] << 8); - int b = values[7] + (values[8] << 8); + state = 0; state_block = start_block; + for (block = start_block; !done && block < end_block; block++) { + monitor.set_value(Altos.state_to_string[state], state, block - state_block); - if (cmd == Altos.AO_LOG_FLIGHT) { - flight = b; - monitor.set_flight(flight); - } - - /* Monitor state transitions to update display */ - if (cmd == Altos.AO_LOG_STATE && a <= Altos.ao_flight_landed) { - if (a > Altos.ao_flight_pad) - want_file = true; - if (a > state) - state_block = block; - state = a; - } + AltosEepromBlock eeblock = new AltosEepromBlock(serial_line, block); + if (eeblock.has_flight) { + flight = eeblock.flight; + monitor.set_flight(flight); + } + if (eeblock.has_date) { + year = eeblock.year; + month = eeblock.month; + day = eeblock.day; + want_file = true; + } - if (cmd == Altos.AO_LOG_GPS_DATE) { - year = 2000 + (a & 0xff); - month = (a >> 8) & 0xff; - day = (b & 0xff); - want_file = true; - } + if (eeblock.size() == 0 || + eeblock.has_state && eeblock.state == Altos.ao_flight_landed) + done = true; - if (eeprom_file == null) { - if (serial != 0 && flight != 0 && want_file) { - if (year != 0 && month != 0 && day != 0) - eeprom_name = new AltosFile(year, month, day, serial, flight, "eeprom"); - else - eeprom_name = new AltosFile(serial, flight, "eeprom"); + /* Monitor state transitions to update display */ + if (eeblock.has_state) { + if (eeblock.state > Altos.ao_flight_pad) + want_file = true; + if (eeblock.state > state) + state = eeblock.state; + } - monitor.set_file(eeprom_name.getName()); - eeprom_file = new FileWriter(eeprom_name); - if (eeprom_file != null) { - FlushPending(eeprom_file, eeprom_pending); - eeprom_pending = null; - } - } - } + CheckFile(true); - String log_line = String.format("%c %4x %4x %4x\n", - cmd, tick, a, b); - if (eeprom_file != null) - eeprom_file.write(log_line); - else - eeprom_pending.add(log_line); + for (record = 0; record < eeblock.size(); record++) { + AltosEepromRecord r = eeblock.get(record); - if (cmd == Altos.AO_LOG_STATE && a == Altos.ao_flight_landed) { - done = true; - } - } - addr += 8; - } - if (!any_valid) - done = true; - } - if (eeprom_file == null) { - eeprom_name = new AltosFile(serial,flight,"eeprom"); - eeprom_file = new FileWriter(eeprom_name); - if (eeprom_file != null) { - FlushPending(eeprom_file, eeprom_pending); + String log_line = String.format("%c %4x %4x %4x\n", + r.cmd, r.tick, r.a, r.b); + if (eeprom_file != null) + eeprom_file.write(log_line); + else + eeprom_pending.add(log_line); } } + CheckFile(true); if (eeprom_file != null) { eeprom_file.flush(); eeprom_file.close(); @@ -235,6 +158,8 @@ public class AltosEepromDownload implements Runnable { SwingUtilities.invokeLater(r); } + int start_block, end_block; + public void run () { if (remote) { serial_line.set_radio(); @@ -243,7 +168,7 @@ public class AltosEepromDownload implements Runnable { } try { - CaptureLog(); + CaptureLog(start_block, end_block); } catch (IOException ee) { show_error (device.toShortString(), ee.getLocalizedMessage()); @@ -271,6 +196,7 @@ public class AltosEepromDownload implements Runnable { serial_line = new AltosSerial(device); if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; + monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed); monitor.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { @@ -280,6 +206,8 @@ public class AltosEepromDownload implements Runnable { }); eeprom_thread = new Thread(this); + start_block = 0; + end_block = 0xfff; eeprom_thread.start(); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(frame, diff --git a/altosui/AltosEepromRecord.java b/altosui/AltosEepromRecord.java index 5a673817..e61a7159 100644 --- a/altosui/AltosEepromRecord.java +++ b/altosui/AltosEepromRecord.java @@ -26,7 +26,9 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.prefs.*; -import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.*; + +import libaltosJNI.*; public class AltosEepromRecord { public int cmd; @@ -36,6 +38,49 @@ public class AltosEepromRecord { public String data; public boolean tick_valid; + int[] ParseHex(String line) { + String[] tokens = line.split("\\s+"); + int[] array = new int[tokens.length]; + + for (int i = 0; i < tokens.length; i++) + try { + array[i] = Integer.parseInt(tokens[i], 16); + } catch (NumberFormatException ne) { + return null; + } + return array; + } + + int checksum(int[] line) { + int csum = 0x5a; + for (int i = 1; i < line.length; i++) + csum += line[i]; + return csum & 0xff; + } + + public AltosEepromRecord (AltosSerial serial_line, int addr) + throws TimeoutException, ParseException, InterruptedException { + String line = serial_line.get_reply(5000); + if (line == null) + throw new TimeoutException(); + int[] values = ParseHex(line); + + if (values == null) + throw new ParseException(String.format("invalid line %s", line), 0); + if (values[0] != (addr & 0xff)) + throw new ParseException(String.format("data address out of sync at 0x%x", + addr), 0); + if (checksum(values) != 0) + throw new ParseException(String.format("invalid checksum at 0x%x", addr), 0); + + cmd = values[1]; + tick = values[3] + (values[4] << 8); + a = values[5] + (values[6] << 8); + b = values[7] + (values[8] << 8); + data = null; + tick_valid = true; + } + public AltosEepromRecord (String line) { tick_valid = false; tick = 0; diff --git a/altosui/Makefile.am b/altosui/Makefile.am index e2ff55af..8cdd64cc 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -15,6 +15,7 @@ altosui_JAVA = \ AltosAscent.java \ AltosChannelMenu.java \ AltosConfig.java \ + AltosConfigData.java \ AltosConfigUI.java \ AltosConfigureUI.java \ AltosConvert.java \ @@ -26,6 +27,7 @@ altosui_JAVA = \ AltosDeviceDialog.java \ AltosDevice.java \ AltosDisplayThread.java \ + AltosEepromBlock.java \ AltosEepromDownload.java \ AltosEepromMonitor.java \ AltosEepromIterable.java \ -- cgit v1.2.3 From 440d52e34364fdeeddc76a2d744cc6d1c934364f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 11 Jan 2011 21:28:07 -0800 Subject: altosui: Add support for parsing list of flights from the 'l' command This adds parsing support to enumerate the available flights, but does not yet provide any UI to use it. Signed-off-by: Keith Packard --- altosui/AltosEepromBlock.java | 24 ++++++++- altosui/AltosEepromDownload.java | 13 ++--- altosui/AltosEepromList.java | 103 +++++++++++++++++++++++++++++++++++++++ altosui/AltosEepromLog.java | 98 +++++++++++++++++++++++++++++++++++++ altosui/AltosEepromRecord.java | 6 ++- altosui/AltosSerial.java | 10 ++++ altosui/Makefile.am | 2 + 7 files changed, 247 insertions(+), 9 deletions(-) create mode 100644 altosui/AltosEepromList.java create mode 100644 altosui/AltosEepromLog.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromBlock.java b/altosui/AltosEepromBlock.java index 0c1a4a92..f223f3fb 100644 --- a/altosui/AltosEepromBlock.java +++ b/altosui/AltosEepromBlock.java @@ -38,6 +38,12 @@ public class AltosEepromBlock extends ArrayList { int state; boolean has_date; int year, month, day; + boolean has_lat; + double lat; + boolean has_lon; + double lon; + boolean has_time; + int hour, minute, second; public AltosEepromBlock (AltosSerial serial_line, int block) throws TimeoutException, InterruptedException { int addr; @@ -46,6 +52,9 @@ public class AltosEepromBlock extends ArrayList { has_flight = false; has_state = false; has_date = false; + has_lat = false; + has_lon = false; + has_time = false; serial_line.printf("e %x\n", block); for (addr = 0; !done && addr < 0x100;) { try { @@ -70,7 +79,20 @@ public class AltosEepromBlock extends ArrayList { day = (r.b & 0xff); has_date = true; } - + if (r.cmd == Altos.AO_LOG_GPS_TIME) { + hour = (r.a & 0xff); + minute = (r.a >> 8); + second = (r.b & 0xff); + has_time = true; + } + if (r.cmd == Altos.AO_LOG_GPS_LAT) { + lat = (double) (r.a | (r.b << 16)) / 1e7; + has_lat = true; + } + if (r.cmd == Altos.AO_LOG_GPS_LON) { + lon = (double) (r.a | (r.b << 16)) / 1e7; + has_lon = true; + } if (r.cmd == Altos.AO_LOG_STATE && r.a == Altos.ao_flight_landed) done = true; add(addr / 8, r); diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 9a748710..ca31fdcf 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -161,11 +161,12 @@ public class AltosEepromDownload implements Runnable { int start_block, end_block; public void run () { - if (remote) { - serial_line.set_radio(); - serial_line.printf("p\nE 0\n"); - serial_line.flush_input(); - } + try { + new AltosEepromList(serial_line, remote); + } catch (Exception ee) { } + + if (remote) + serial_line.start_remote(); try { CaptureLog(start_block, end_block); @@ -179,7 +180,7 @@ public class AltosEepromDownload implements Runnable { "Connection Failed"); } if (remote) - serial_line.printf("~"); + serial_line.stop_remote(); monitor.done(); serial_line.flush_output(); serial_line.close(); diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java new file mode 100644 index 00000000..ac4a29de --- /dev/null +++ b/altosui/AltosEepromList.java @@ -0,0 +1,103 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +import libaltosJNI.*; + +class AltosEepromFlight { + int flight; + int start; + int end; + + public AltosEepromFlight(int in_flight, int in_start, int in_end) { + flight = in_flight; + start = in_start; + end = in_end; + } +} + +public class AltosEepromList extends ArrayList { + AltosConfigData config_data; + + public AltosEepromList (AltosSerial serial_line, boolean remote) throws IOException, InterruptedException, TimeoutException { + try { + if (remote) + serial_line.start_remote(); + config_data = new AltosConfigData (serial_line); + if (config_data.serial == 0) + throw new IOException("no serial number found"); + + ArrayList flights = new ArrayList(); + if (config_data.flight_log_max != 0) { + serial_line.printf("l\n"); + for (;;) { + String line = serial_line.get_reply(5000); + if (line == null) + throw new TimeoutException(); + if (line.contains("done")) + break; + if (line.contains("Syntax")) + continue; + String[] tokens = line.split("\\s+"); + System.out.printf("got line %s (%d tokens)\n", line, tokens.length); + if (tokens.length < 6) + break; + + int flight = -1, start = -1, end = -1; + try { + if (tokens[0].equals("flight")) + flight = AltosParse.parse_int(tokens[1]); + if (tokens[2].equals("start")) + start = AltosParse.parse_hex(tokens[3]); + if (tokens[4].equals("end")) + end = AltosParse.parse_hex(tokens[5]); + System.out.printf("parsed flight %d %x %x\n", flight, start, end); + if (flight > 0 && start >= 0 && end > 0) + flights.add(new AltosEepromFlight(flight, start, end)); + } catch (ParseException pe) { System.out.printf("Parse error %s\n", pe.toString()); } + } + } else { + flights.add(new AltosEepromFlight(0, 0, 0xfff)); + } + for (AltosEepromFlight flight : flights) { + System.out.printf("Scanning flight %d %x %x\n", flight.flight, flight.start, flight.end); + add(new AltosEepromLog(serial_line, config_data.serial, + flight.start, flight.end)); + } + } finally { + if (remote) + serial_line.stop_remote(); + serial_line.flush_output(); + } + for (int i = 0; i < size(); i++) { + AltosEepromLog l = get(i); + System.out.printf("Found flight %d at %x - %x\n", l.flight, l.start_block, l.end_block); + } + } +} \ No newline at end of file diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java new file mode 100644 index 00000000..36289b42 --- /dev/null +++ b/altosui/AltosEepromLog.java @@ -0,0 +1,98 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +import libaltosJNI.*; + +public class AltosEepromLog { + int serial; + boolean has_flight; + int flight; + int start_block; + int end_block; + + boolean has_gps; + int year, month, day; + int hour, minute, second; + double lat, lon; + + public AltosEepromLog(AltosSerial serial_line, int in_serial, + int in_start_block, int in_end_block) + throws InterruptedException, TimeoutException { + + int block; + boolean has_date = false, has_time = false, has_lat = false, has_lon = false; + + start_block = in_start_block; + end_block = in_end_block; + serial = in_serial; + + if (in_end_block > in_start_block + 2) + in_end_block = in_start_block + 2; + + for (block = in_start_block; block < in_end_block; block++) { + AltosEepromBlock eeblock = new AltosEepromBlock(serial_line, block); + if (eeblock.has_flight) { + flight = eeblock.flight; + has_flight = true; + } + if (eeblock.has_date) { + year = eeblock.year; + month = eeblock.month; + day = eeblock.day; + has_date = true; + } + if (eeblock.has_time) { + hour = eeblock.hour; + minute = eeblock.minute; + second = eeblock.second; + has_time = true; + } + if (eeblock.has_lat) { + lat = eeblock.lat; + has_lat = true; + } + if (eeblock.has_lon) { + lon = eeblock.lon; + has_lon = true; + } + if (has_date && has_time && has_lat && has_lon) + has_gps = true; + if (has_gps && has_flight) + break; + } + System.out.printf("Serial %d start block %d end block %d\n", + serial, start_block, end_block); + if (has_flight) + System.out.printf("Flight %d\n", flight); + if (has_gps) + System.out.printf("%d-%d-%d %d:%02d:%02d Lat %f Lon %f\n", + year, month, day, hour, minute, second, lat, lon); + } +} diff --git a/altosui/AltosEepromRecord.java b/altosui/AltosEepromRecord.java index e61a7159..584a04b7 100644 --- a/altosui/AltosEepromRecord.java +++ b/altosui/AltosEepromRecord.java @@ -65,8 +65,10 @@ public class AltosEepromRecord { throw new TimeoutException(); int[] values = ParseHex(line); - if (values == null) - throw new ParseException(String.format("invalid line %s", line), 0); + if (values == null || values.length < 9) { + System.out.printf("invalid line %s", line); + throw new ParseException(String.format("inalid line %s", line), 0); + } if (values[0] != (addr & 0xff)) throw new ParseException(String.format("data address out of sync at 0x%x", addr), 0); diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index b19143e5..6dce6f3d 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -242,6 +242,16 @@ public class AltosSerial implements Runnable { } } + public void start_remote() { + set_radio(); + printf("p\nE 0\n"); + flush_input(); + } + + public void stop_remote() { + printf ("~"); + } + public AltosSerial(AltosDevice in_device) throws FileNotFoundException, AltosSerialInUseException { device = in_device; line = ""; diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 8cdd64cc..58d23787 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -29,6 +29,8 @@ altosui_JAVA = \ AltosDisplayThread.java \ AltosEepromBlock.java \ AltosEepromDownload.java \ + AltosEepromList.java \ + AltosEepromLog.java \ AltosEepromMonitor.java \ AltosEepromIterable.java \ AltosEepromRecord.java \ -- cgit v1.2.3 From 8801b8c1947bd39f7c985b91a2ba8dbc81bcc91a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 12 Jan 2011 12:40:45 -0800 Subject: altosui: Add eeprom 'manage' ui to download and delete multiple flights This shows the list of available flights and provides options to download and/or delete each one. Signed-off-by: Keith Packard --- altosui/AltosEepromDelete.java | 148 ++++++++++++++++++++++++++++++++++++ altosui/AltosEepromDownload.java | 124 +++++++++++++++---------------- altosui/AltosEepromList.java | 31 +++++++- altosui/AltosEepromLog.java | 16 ++++ altosui/AltosEepromManage.java | 157 +++++++++++++++++++++++++++++++++++++++ altosui/AltosEepromMonitor.java | 18 +++++ altosui/AltosEepromSelect.java | 132 ++++++++++++++++++++++++++++++++ altosui/AltosUI.java | 2 +- altosui/Makefile.am | 3 + 9 files changed, 565 insertions(+), 66 deletions(-) create mode 100644 altosui/AltosEepromDelete.java create mode 100644 altosui/AltosEepromManage.java create mode 100644 altosui/AltosEepromSelect.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java new file mode 100644 index 00000000..c95eda15 --- /dev/null +++ b/altosui/AltosEepromDelete.java @@ -0,0 +1,148 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +import libaltosJNI.*; + +public class AltosEepromDelete implements Runnable { + AltosEepromList flights; + Thread eeprom_thread; + AltosSerial serial_line; + boolean remote; + JFrame frame; + ActionListener listener; + boolean success; + + private void DeleteLog (AltosEepromLog log) + throws IOException, InterruptedException, TimeoutException { + + if (flights.config_data.flight_log_max != 0) { + + /* Devices with newer firmware can erase the + * flash blocks containing each flight + */ + serial_line.flush_input(); + serial_line.printf("d %d\n", log.flight); + System.out.printf("Attempt to delete flight %d\n", log.flight); + for (;;) { + /* It can take a while to erase the flash... */ + String line = serial_line.get_reply(20000); + System.out.printf("got back line %s\n", line); + if (line == null) + throw new TimeoutException(); + if (line.equals("Erased")) + break; + if (line.startsWith("No such")) + throw new IOException(line); + } + } + } + + private void show_error_internal(String message, String title) { + JOptionPane.showMessageDialog(frame, + message, + title, + JOptionPane.ERROR_MESSAGE); + } + + private void show_error(String in_message, String in_title) { + final String message = in_message; + final String title = in_title; + Runnable r = new Runnable() { + public void run() { + try { + show_error_internal(message, title); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + + public void run () { + if (remote) + serial_line.start_remote(); + + success = false; + try { + for (AltosEepromLog log : flights) { + if (log.delete) { + DeleteLog(log); + } + } + System.out.printf("All flights successfully deleted\n"); + success = true; + } catch (IOException ee) { + show_error (ee.getLocalizedMessage(), + serial_line.device.toShortString()); + } catch (InterruptedException ie) { + } catch (TimeoutException te) { + show_error (String.format("Connection to \"%s\" failed", + serial_line.device.toShortString()), + "Connection Failed"); + } + if (remote) + serial_line.stop_remote(); + serial_line.flush_output(); + serial_line.close(); + if (listener != null) { + Runnable r = new Runnable() { + public void run() { + try { + listener.actionPerformed(new ActionEvent(this, + success ? 1 : 0, + "delete")); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } + } + + public void start() { + eeprom_thread = new Thread(this); + eeprom_thread.start(); + } + + public void addActionListener(ActionListener l) { + listener = l; + } + + public AltosEepromDelete(JFrame given_frame, + AltosSerial given_serial_line, + boolean given_remote, + AltosEepromList given_flights) { + frame = given_frame; + serial_line = given_serial_line; + remote = given_remote; + flights = given_flights; + success = false; + } +} \ No newline at end of file diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index ca31fdcf..5d19acec 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -33,21 +33,21 @@ import libaltosJNI.*; public class AltosEepromDownload implements Runnable { JFrame frame; - AltosDevice device; AltosSerial serial_line; boolean remote; Thread eeprom_thread; AltosEepromMonitor monitor; - int serial = 0; int flight = 0; int year = 0, month = 0, day = 0; boolean want_file = false; FileWriter eeprom_file = null; LinkedList eeprom_pending = new LinkedList(); - AltosConfigData config_data; + AltosEepromList flights; + ActionListener listener; + boolean success; private void FlushPending() throws IOException { - for (String s : config_data) { + for (String s : flights.config_data) { eeprom_file.write(s); eeprom_file.write('\n'); } @@ -62,9 +62,9 @@ public class AltosEepromDownload implements Runnable { if (force || (flight != 0 && want_file)) { AltosFile eeprom_name; if (year != 0 && month != 0 && day != 0) - eeprom_name = new AltosFile(year, month, day, serial, flight, "eeprom"); + eeprom_name = new AltosFile(year, month, day, flights.config_data.serial, flight, "eeprom"); else - eeprom_name = new AltosFile(serial, flight, "eeprom"); + eeprom_name = new AltosFile(flights.config_data.serial, flight, "eeprom"); eeprom_file = new FileWriter(eeprom_name); if (eeprom_file != null) { @@ -75,25 +75,24 @@ public class AltosEepromDownload implements Runnable { } } - void CaptureLog(int start_block, int end_block) throws IOException, InterruptedException, TimeoutException { + void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException { int block, state_block = 0; int state = 0; boolean done = false; int record; - config_data = new AltosConfigData(serial_line); - serial = config_data.serial; - if (serial == 0) + if (flights.config_data.serial == 0) throw new IOException("no serial number found"); - monitor.set_serial(serial); + monitor.set_serial(flights.config_data.serial); /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */ - state = 0; state_block = start_block; - for (block = start_block; !done && block < end_block; block++) { + state = 0; state_block = log.start_block; + for (block = log.start_block; !done && block < log.end_block; block++) { monitor.set_value(Altos.state_to_string[state], state, block - state_block); AltosEepromBlock eeblock = new AltosEepromBlock(serial_line, block); + if (eeblock.has_flight) { flight = eeblock.flight; monitor.set_flight(flight); @@ -117,7 +116,7 @@ public class AltosEepromDownload implements Runnable { state = eeblock.state; } - CheckFile(true); + CheckFile(false); for (record = 0; record < eeblock.size(); record++) { AltosEepromRecord r = eeblock.get(record); @@ -158,76 +157,73 @@ public class AltosEepromDownload implements Runnable { SwingUtilities.invokeLater(r); } - int start_block, end_block; - public void run () { - try { - new AltosEepromList(serial_line, remote); - } catch (Exception ee) { } - if (remote) serial_line.start_remote(); try { - CaptureLog(start_block, end_block); + for (AltosEepromLog log : flights) { + if (log.download) { + monitor.reset(); + CaptureLog(log); + } + } + System.out.printf("All flights successfully downloaded\n"); + success = true; } catch (IOException ee) { - show_error (device.toShortString(), + show_error (serial_line.device.toShortString(), ee.getLocalizedMessage()); } catch (InterruptedException ie) { } catch (TimeoutException te) { show_error (String.format("Connection to \"%s\" failed", - device.toShortString()), + serial_line.device.toShortString()), "Connection Failed"); } if (remote) serial_line.stop_remote(); monitor.done(); serial_line.flush_output(); - serial_line.close(); + if (listener != null) { + Runnable r = new Runnable() { + public void run() { + try { + listener.actionPerformed(new ActionEvent(this, + success ? 1 : 0, + "download")); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } } - public AltosEepromDownload(JFrame given_frame) { - frame = given_frame; - device = AltosDeviceDialog.show(frame, AltosDevice.product_any); + public void start() { + eeprom_thread = new Thread(this); + eeprom_thread.start(); + } - remote = false; + public void addActionListener(ActionListener l) { + listener = l; + } - if (device != null) { - try { - serial_line = new AltosSerial(device); - if (!device.matchProduct(AltosDevice.product_telemetrum)) - remote = true; + public AltosEepromDownload(JFrame given_frame, + AltosSerial given_serial_line, + boolean given_remote, + AltosEepromList given_flights) { - monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed); - monitor.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (eeprom_thread != null) - eeprom_thread.interrupt(); - } - }); - - eeprom_thread = new Thread(this); - start_block = 0; - end_block = 0xfff; - eeprom_thread.start(); - } catch (FileNotFoundException ee) { - JOptionPane.showMessageDialog(frame, - String.format("Cannot open device \"%s\"", - device.toShortString()), - "Cannot open target device", - JOptionPane.ERROR_MESSAGE); - } catch (AltosSerialInUseException si) { - JOptionPane.showMessageDialog(frame, - String.format("Device \"%s\" already in use", - device.toShortString()), - "Device in use", - JOptionPane.ERROR_MESSAGE); - } catch (IOException ee) { - JOptionPane.showMessageDialog(frame, - device.toShortString(), - ee.getLocalizedMessage(), - JOptionPane.ERROR_MESSAGE); - } - } + frame = given_frame; + serial_line = given_serial_line; + remote = given_remote; + flights = given_flights; + success = false; + + monitor = new AltosEepromMonitor(frame, Altos.ao_flight_boost, Altos.ao_flight_landed); + monitor.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + if (eeprom_thread != null) + eeprom_thread.interrupt(); + } + }); } } diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index ac4a29de..a932dd12 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -30,6 +30,12 @@ import java.util.concurrent.*; import libaltosJNI.*; +/* + * Temporary structure to hold the list of stored flights; + * each of these will be queried in turn to generate more + * complete information + */ + class AltosEepromFlight { int flight; int start; @@ -42,10 +48,16 @@ class AltosEepromFlight { } } +/* + * Construct a list of flights available in a connected device + */ + public class AltosEepromList extends ArrayList { AltosConfigData config_data; - public AltosEepromList (AltosSerial serial_line, boolean remote) throws IOException, InterruptedException, TimeoutException { + public AltosEepromList (AltosSerial serial_line, boolean remote) + throws IOException, InterruptedException, TimeoutException + { try { if (remote) serial_line.start_remote(); @@ -54,7 +66,13 @@ public class AltosEepromList extends ArrayList { throw new IOException("no serial number found"); ArrayList flights = new ArrayList(); + if (config_data.flight_log_max != 0) { + + /* Devices with newer firmware will support the 'l' + * command which will list the region of storage + * occupied by each available flight + */ serial_line.printf("l\n"); for (;;) { String line = serial_line.get_reply(5000); @@ -83,8 +101,19 @@ public class AltosEepromList extends ArrayList { } catch (ParseException pe) { System.out.printf("Parse error %s\n", pe.toString()); } } } else { + + /* Older devices will hold only a single + * flight. This also assumes that any older + * device will have a 1MB flash device + */ flights.add(new AltosEepromFlight(0, 0, 0xfff)); } + + /* With the list of flights collected, collect more complete + * information on them by reading the first block or two of + * data. This will add GPS coordinates and a date. For older + * firmware, this will also extract the flight number. + */ for (AltosEepromFlight flight : flights) { System.out.printf("Scanning flight %d %x %x\n", flight.flight, flight.start, flight.end); add(new AltosEepromLog(serial_line, config_data.serial, diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index 36289b42..f284f103 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -30,6 +30,10 @@ import java.util.concurrent.*; import libaltosJNI.*; +/* + * Extract a bit of information from an eeprom-stored flight log. + */ + public class AltosEepromLog { int serial; boolean has_flight; @@ -42,6 +46,9 @@ public class AltosEepromLog { int hour, minute, second; double lat, lon; + boolean download; + boolean delete; + public AltosEepromLog(AltosSerial serial_line, int in_serial, int in_start_block, int in_end_block) throws InterruptedException, TimeoutException { @@ -53,6 +60,15 @@ public class AltosEepromLog { end_block = in_end_block; serial = in_serial; + /* + * By default, request that every log be downloaded but not deleted + */ + download = true; + delete = false; + /* + * Only look in the first two blocks so that this + * process doesn't take a long time + */ if (in_end_block > in_start_block + 2) in_end_block = in_start_block + 2; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java new file mode 100644 index 00000000..b64ee525 --- /dev/null +++ b/altosui/AltosEepromManage.java @@ -0,0 +1,157 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +import libaltosJNI.*; + +public class AltosEepromManage implements ActionListener { + + JFrame frame; + boolean remote; + AltosDevice device; + AltosSerial serial_line; + AltosEepromList flights; + AltosEepromDownload download; + AltosEepromDelete delete; + boolean any_download; + boolean any_delete; + + public void finish() { + if (serial_line != null) { + serial_line.flush_output(); + serial_line.close(); + serial_line = null; + } + } + + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + boolean success = e.getID() != 0; + + System.out.printf("Eeprom manager action %s %d\n", cmd, e.getID()); + if (cmd.equals("download")) { + if (success) { + System.out.printf("Download succeeded\n"); + if (any_delete) + delete.start(); + else + finish(); + } + } else if (cmd.equals("delete")) { + if (success) + System.out.printf("Delete succeeded\n"); + finish(); + } + } + + public AltosEepromManage(JFrame given_frame) { + + frame = given_frame; + device = AltosDeviceDialog.show(frame, AltosDevice.product_any); + + remote = false; + any_download = false; + any_delete = false; + + if (device != null) { + try { + serial_line = new AltosSerial(device); + if (!device.matchProduct(AltosDevice.product_telemetrum)) + remote = true; + + flights = new AltosEepromList(serial_line, remote); + + if (flights.size() == 0) { + } else { + AltosEepromSelect select = new AltosEepromSelect(frame, flights); + + if (select.run()) { + for (AltosEepromLog flight : flights) { + any_download = any_download || flight.download; + any_delete = any_delete || flight.delete; + } + if (any_download) { + download = new AltosEepromDownload(frame, + serial_line, + remote, + flights); + download.addActionListener(this); + } + + if (any_delete) { + delete = new AltosEepromDelete(frame, + serial_line, + remote, + flights); + delete.addActionListener(this); + } + + /* + * Start flight log download + */ + + if (any_download) + download.start(); + else if (any_delete) + delete.start(); + else + finish(); + } + } + } catch (FileNotFoundException ee) { + JOptionPane.showMessageDialog(frame, + String.format("Cannot open device \"%s\"", + device.toShortString()), + "Cannot open target device", + JOptionPane.ERROR_MESSAGE); + } catch (AltosSerialInUseException si) { + JOptionPane.showMessageDialog(frame, + String.format("Device \"%s\" already in use", + device.toShortString()), + "Device in use", + JOptionPane.ERROR_MESSAGE); + } catch (IOException ee) { + JOptionPane.showMessageDialog(frame, + device.toShortString(), + ee.getLocalizedMessage(), + JOptionPane.ERROR_MESSAGE); + finish(); + } catch (TimeoutException te) { + JOptionPane.showMessageDialog(frame, + String.format("Communications failed with \"%s\"", + device.toShortString()), + "Cannot open target device", + JOptionPane.ERROR_MESSAGE); + finish(); + } catch (InterruptedException ie) { + finish(); + } + } + } +} diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index 13a49a95..b9d913fa 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -239,4 +239,22 @@ public class AltosEepromMonitor extends JDialog { }; SwingUtilities.invokeLater(r); } + + private void reset_internal() { + set_value_internal("startup",min_state,0); + set_flight_internal(0); + set_file_internal(""); + } + + public void reset() { + Runnable r = new Runnable() { + public void run() { + try { + reset_internal(); + } catch (Exception ex) { + } + } + }; + SwingUtilities.invokeLater(r); + } } diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java new file mode 100644 index 00000000..104d3180 --- /dev/null +++ b/altosui/AltosEepromSelect.java @@ -0,0 +1,132 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.lang.*; +import java.util.*; +import javax.swing.*; +import javax.swing.border.*; +import java.awt.*; +import java.awt.event.*; +import libaltosJNI.libaltos; +import libaltosJNI.altos_device; +import libaltosJNI.SWIGTYPE_p_altos_file; +import libaltosJNI.SWIGTYPE_p_altos_list; + +class AltosEepromItem extends JPanel implements ActionListener { + AltosEepromLog log; + JCheckBox download; + JCheckBox delete; + JLabel label; + + public void actionPerformed(ActionEvent e) { + System.out.printf("eeprom item action %s %d\n", e.getActionCommand(), e.getID()); + if (e.getSource() == download) { + log.download = download.isSelected(); + System.out.printf("download set to %b\n", log.download); + } else if (e.getSource() == delete) { + log.delete = delete.isSelected(); + System.out.printf("delete set to %b\n", log.delete); + } + } + + public AltosEepromItem(AltosEepromLog in_log) { + log = in_log; + + download = new JCheckBox("Download", log.download); + download.addActionListener(this); + add(download); + delete = new JCheckBox("Delete", log.delete); + delete.addActionListener(this); + add(delete); + label = new JLabel(String.format("Flight %d %4d-%02d-%02d", + log.flight, log.year, log.month, log.day)); + add(label); + } +} + +public class AltosEepromSelect extends JDialog implements ActionListener { + private JList list; + private JFrame frame; + JButton ok; + JButton cancel; + boolean success; + + /* Listen for events from our buttons */ + public void actionPerformed(ActionEvent e) { + String cmd = e.getActionCommand(); + + if (cmd.equals("ok")) + success = true; + setVisible(false); + } + + public boolean run() { + success = false; + setLocationRelativeTo(frame); + setVisible(true); + return success; + } + + public AltosEepromSelect (JFrame in_frame, + AltosEepromList flights) { + + super(in_frame, String.format("Flight list for serial %d", flights.config_data.serial), true); + frame = in_frame; + + JLabel selectLabel = new JLabel("Select flights to download and/or delete", SwingConstants.CENTER); + + JPanel labelPane = new JPanel(); + labelPane.setLayout(new BoxLayout(labelPane, BoxLayout.X_AXIS)); + labelPane.setBorder(BorderFactory.createEmptyBorder(10, 0, 10, 0)); + labelPane.add(Box.createHorizontalGlue()); + labelPane.add(selectLabel); + labelPane.add(Box.createHorizontalGlue()); + + JPanel flightPane = new JPanel(); + flightPane.setLayout(new BoxLayout(flightPane, BoxLayout.Y_AXIS)); + flightPane.setBorder(BorderFactory.createBevelBorder(BevelBorder.LOWERED)); + for (AltosEepromLog flight : flights) { + flightPane.add(new AltosEepromItem(flight)); + } + + ok = new JButton("OK"); + ok.addActionListener(this); + ok.setActionCommand("ok"); + + cancel = new JButton("Cancel"); + cancel.addActionListener(this); + cancel.setActionCommand("cancel"); + + JPanel buttonPane = new JPanel(); + buttonPane.setLayout(new BoxLayout(buttonPane, BoxLayout.X_AXIS)); + buttonPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); + buttonPane.add(Box.createHorizontalGlue()); + buttonPane.add(cancel); + buttonPane.add(Box.createRigidArea(new Dimension(10, 0))); + buttonPane.add(ok); + + Container contentPane = getContentPane(); + + contentPane.add(labelPane, BorderLayout.PAGE_START); + contentPane.add(flightPane, BorderLayout.CENTER); + contentPane.add(buttonPane, BorderLayout.PAGE_END); + + pack(); + } +} diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 94c4dd2a..90e3d7f0 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -245,7 +245,7 @@ public class AltosUI extends JFrame { * a TeleDongle over the packet link */ private void SaveFlightData() { - new AltosEepromDownload(AltosUI.this); + new AltosEepromManage(AltosUI.this); } /* Load a flight log file and write out a CSV file containing diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 58d23787..196d7032 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -28,12 +28,15 @@ altosui_JAVA = \ AltosDevice.java \ AltosDisplayThread.java \ AltosEepromBlock.java \ + AltosEepromDelete.java \ AltosEepromDownload.java \ AltosEepromList.java \ AltosEepromLog.java \ + AltosEepromManage.java \ AltosEepromMonitor.java \ AltosEepromIterable.java \ AltosEepromRecord.java \ + AltosEepromSelect.java \ AltosFile.java \ AltosFlash.java \ AltosFlashUI.java \ -- cgit v1.2.3 From deb3c7b9206be0c9c46f75d35c8f766c26d9838f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 15 Jan 2011 22:43:37 -0800 Subject: altosui: Reset eeprom download instance variables before reading flight To deal with downloading multiple flights in a single invocation, make sure all relevant instance variables are set back to start of flight download values each time a log is read. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 5d19acec..af70b15c 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -37,11 +37,13 @@ public class AltosEepromDownload implements Runnable { boolean remote; Thread eeprom_thread; AltosEepromMonitor monitor; - int flight = 0; - int year = 0, month = 0, day = 0; - boolean want_file = false; - FileWriter eeprom_file = null; - LinkedList eeprom_pending = new LinkedList(); + + int flight; + int year, month, day; + boolean want_file; + FileWriter eeprom_file; + LinkedList eeprom_pending; + AltosEepromList flights; ActionListener listener; boolean success; @@ -84,6 +86,16 @@ public class AltosEepromDownload implements Runnable { if (flights.config_data.serial == 0) throw new IOException("no serial number found"); + /* Reset per-capture variables */ + flight = 0; + year = 0; + month = 0; + day = 0; + want_file = false; + eeprom_file = null; + eeprom_pending = new LinkedList(); + + /* Set serial number in the monitor dialog window */ monitor.set_serial(flights.config_data.serial); /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */ -- cgit v1.2.3 From 987039b8f0b1d889aca9109d4c6a83f034ff64a7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 16 Jan 2011 14:29:57 -0800 Subject: altosui: Remove debug message when eeprom downloads are complete. This message isn't useful now that this code appears to work. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 1 - 1 file changed, 1 deletion(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index af70b15c..f1abd50c 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -180,7 +180,6 @@ public class AltosEepromDownload implements Runnable { CaptureLog(log); } } - System.out.printf("All flights successfully downloaded\n"); success = true; } catch (IOException ee) { show_error (serial_line.device.toShortString(), -- cgit v1.2.3 From 249cd3b63d97581b068fff988e0cd7fcd5bf493e Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 19 Feb 2011 01:06:01 -0800 Subject: altosui: Display eeprom parsing errors to user When reading the eeprom, any parsing errors (most likely bad checksums) indicate some kind of problem with either the hardware or the flight software. Display these to the user and do not erase the flight. Signed-off-by: Keith Packard --- altosui/AltosEepromBlock.java | 3 +++ altosui/AltosEepromDownload.java | 51 +++++++++++++++++++++++++++------------- 2 files changed, 38 insertions(+), 16 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromBlock.java b/altosui/AltosEepromBlock.java index 11438df8..d59fd39e 100644 --- a/altosui/AltosEepromBlock.java +++ b/altosui/AltosEepromBlock.java @@ -44,6 +44,7 @@ public class AltosEepromBlock extends ArrayList { double lon; boolean has_time; int hour, minute, second; + ParseException parse_exception = null; public AltosEepromBlock (AltosSerial serial_line, int block) throws TimeoutException, InterruptedException { int addr; @@ -100,6 +101,8 @@ public class AltosEepromBlock extends ArrayList { } catch (ParseException pe) { AltosEepromRecord r = new AltosEepromRecord(Altos.AO_LOG_INVALID, 0, 0, 0); + if (parse_exception == null) + parse_exception = pe; if (!done) add(addr/8, r); } diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index f1abd50c..1da94a67 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -47,6 +47,7 @@ public class AltosEepromDownload implements Runnable { AltosEepromList flights; ActionListener listener; boolean success; + ParseException parse_exception; private void FlushPending() throws IOException { for (String s : flights.config_data) { @@ -128,17 +129,22 @@ public class AltosEepromDownload implements Runnable { state = eeblock.state; } + if (parse_exception == null && eeblock.parse_exception != null) + parse_exception = eeblock.parse_exception; + CheckFile(false); for (record = 0; record < eeblock.size(); record++) { AltosEepromRecord r = eeblock.get(record); - String log_line = String.format("%c %4x %4x %4x\n", - r.cmd, r.tick, r.a, r.b); - if (eeprom_file != null) - eeprom_file.write(log_line); - else - eeprom_pending.add(log_line); + if (r.cmd != Altos.AO_LOG_INVALID) { + String log_line = String.format("%c %4x %4x %4x\n", + r.cmd, r.tick, r.a, r.b); + if (eeprom_file != null) + eeprom_file.write(log_line); + else + eeprom_pending.add(log_line); + } } } CheckFile(true); @@ -148,20 +154,21 @@ public class AltosEepromDownload implements Runnable { } } - private void show_error_internal(String message, String title) { + private void show_message_internal(String message, String title, int message_type) { JOptionPane.showMessageDialog(frame, message, title, - JOptionPane.ERROR_MESSAGE); + message_type); } - private void show_error(String in_message, String in_title) { + private void show_message(String in_message, String in_title, int in_message_type) { final String message = in_message; final String title = in_title; + final int message_type = in_message_type; Runnable r = new Runnable() { public void run() { try { - show_error_internal(message, title); + show_message_internal(message, title, message_type); } catch (Exception ex) { } } @@ -174,21 +181,33 @@ public class AltosEepromDownload implements Runnable { serial_line.start_remote(); try { + boolean failed = false; for (AltosEepromLog log : flights) { + parse_exception = null; if (log.download) { monitor.reset(); CaptureLog(log); } + if (parse_exception != null) { + failed = true; + show_message(String.format("Flight %d download error\n%s\nValid log data saved", + log.flight, + parse_exception.getMessage()), + serial_line.device.toShortString(), + JOptionPane.WARNING_MESSAGE); + } } - success = true; + success = !failed; } catch (IOException ee) { - show_error (serial_line.device.toShortString(), - ee.getLocalizedMessage()); + show_message(ee.getLocalizedMessage(), + serial_line.device.toShortString(), + JOptionPane.ERROR_MESSAGE); } catch (InterruptedException ie) { } catch (TimeoutException te) { - show_error (String.format("Connection to \"%s\" failed", - serial_line.device.toShortString()), - "Connection Failed"); + show_message(String.format("Connection to \"%s\" failed", + serial_line.device.toShortString()), + "Connection Failed", + JOptionPane.ERROR_MESSAGE); } if (remote) serial_line.stop_remote(); -- cgit v1.2.3 From 011615d40b3cb1d1c0ab9fa41e139e263a6a51e7 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 25 Mar 2011 21:34:31 -0700 Subject: altosui: Add support for downloading TeleMini/TeleNano flight logs Splits the eeprom downloading code into eeprom block downloading and separate eeprom data parsing so that the new data logging format can share the data downloading code. Signed-off-by: Keith Packard --- altosui/Altos.java | 1 + altosui/AltosEepromBlock.java | 7 +- altosui/AltosEepromChunk.java | 88 ++++++++++++++++++++++ altosui/AltosEepromDownload.java | 153 +++++++++++++++++++++++++++++---------- altosui/AltosEepromIterable.java | 5 +- altosui/AltosEepromLog.java | 11 ++- altosui/AltosEepromRecord.java | 45 +++++------- altosui/Makefile.am | 1 + 8 files changed, 239 insertions(+), 72 deletions(-) create mode 100644 altosui/AltosEepromChunk.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/Altos.java b/altosui/Altos.java index 9d5b2e02..3ef4d799 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -34,6 +34,7 @@ public class Altos { static final int AO_LOG_GPS_ALT = 'H'; static final int AO_LOG_GPS_SAT = 'V'; static final int AO_LOG_GPS_DATE = 'Y'; + static final int AO_LOG_HEIGHT = 'h'; /* Added for header fields in eeprom files */ static final int AO_LOG_CONFIG_VERSION = 1000; diff --git a/altosui/AltosEepromBlock.java b/altosui/AltosEepromBlock.java index d59fd39e..650920d1 100644 --- a/altosui/AltosEepromBlock.java +++ b/altosui/AltosEepromBlock.java @@ -46,7 +46,7 @@ public class AltosEepromBlock extends ArrayList { int hour, minute, second; ParseException parse_exception = null; - public AltosEepromBlock (AltosSerial serial_line, int block) throws TimeoutException, InterruptedException { + public AltosEepromBlock (AltosEepromChunk chunk) { int addr; boolean done = false; @@ -56,10 +56,9 @@ public class AltosEepromBlock extends ArrayList { has_lat = false; has_lon = false; has_time = false; - serial_line.printf("e %x\n", block); - for (addr = 0; addr < 0x100;) { + for (addr = 0; addr < chunk.chunk_size;) { try { - AltosEepromRecord r = new AltosEepromRecord(serial_line, block * 256 + addr); + AltosEepromRecord r = new AltosEepromRecord(chunk, addr); if (r.cmd == Altos.AO_LOG_FLIGHT) { flight = r.b; diff --git a/altosui/AltosEepromChunk.java b/altosui/AltosEepromChunk.java new file mode 100644 index 00000000..8eec407d --- /dev/null +++ b/altosui/AltosEepromChunk.java @@ -0,0 +1,88 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.concurrent.*; + +public class AltosEepromChunk { + + static final int chunk_size = 256; + static final int per_line = 8; + + public int data[]; + public int address; + public ParseException parse_exception = null; + + int[] ParseHex(String line) { + String[] tokens = line.split("\\s+"); + int[] array = new int[tokens.length]; + + for (int i = 0; i < tokens.length; i++) + try { + array[i] = Integer.parseInt(tokens[i], 16); + } catch (NumberFormatException ne) { + return null; + } + return array; + } + + int data(int offset) { + return data[offset]; + } + + int data16(int offset) { + return data[offset] | (data[offset + 1] << 8); + } + + public AltosEepromChunk(AltosSerial serial_line, int block) + throws TimeoutException, InterruptedException { + + int offset; + + data = new int[chunk_size]; + address = block * chunk_size; + serial_line.printf("e %x\n", block); + + for (offset = 0; offset < chunk_size; offset += per_line) { + try { + String line = serial_line.get_reply(5000); + + if (line == null) + throw new TimeoutException(); + + int[] values = ParseHex(line); + + if (values == null || values.length != per_line + 1) + throw new ParseException(String.format("invalid line %s", line), 0); + if (values[0] != offset) + throw new ParseException(String.format("data address out of sync at 0x%x", + address + offset), 0); + for (int i = 0; i < per_line; i++) + data[offset + i] = values[1 + i]; + } catch (ParseException pe) { + for (int i = 0; i < per_line; i++) + data[offset + i] = 0xff; + if (parse_exception == null) + parse_exception = pe; + } + } + } +} \ No newline at end of file diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 1da94a67..f96a3dc9 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -78,11 +78,105 @@ public class AltosEepromDownload implements Runnable { } } + void Log(AltosEepromRecord r) throws IOException { + if (r.cmd != Altos.AO_LOG_INVALID) { + String log_line = String.format("%c %4x %4x %4x\n", + r.cmd, r.tick, r.a, r.b); + if (eeprom_file != null) + eeprom_file.write(log_line); + else + eeprom_pending.add(log_line); + } + } + + static final int log_full = 1; + static final int log_tiny = 2; + + boolean done; + int state; + + void CaptureFull(AltosEepromChunk eechunk) throws IOException { + AltosEepromBlock eeblock = new AltosEepromBlock(eechunk); + + if (eeblock.has_flight) { + flight = eeblock.flight; + monitor.set_flight(flight); + } + if (eeblock.has_date) { + year = eeblock.year; + month = eeblock.month; + day = eeblock.day; + want_file = true; + } + + if (eeblock.size() == 0 || + eeblock.has_state && eeblock.state == Altos.ao_flight_landed) + done = true; + + /* Monitor state transitions to update display */ + if (eeblock.has_state) { + if (eeblock.state > Altos.ao_flight_pad) + want_file = true; + if (eeblock.state > state) + state = eeblock.state; + } + + if (parse_exception == null && eeblock.parse_exception != null) + parse_exception = eeblock.parse_exception; + + CheckFile(false); + + for (int record = 0; record < eeblock.size(); record++) + Log(eeblock.get(record)); + } + + boolean start; + int tiny_tick; + + void CaptureTiny (AltosEepromChunk eechunk) throws IOException { + boolean some_reasonable_data = false; + + for (int i = 0; i < eechunk.data.length; i += 2) { + int v = eechunk.data16(i); + + if (i == 0 && start) { + tiny_tick = 0; + start = false; + flight = v; + Log(new AltosEepromRecord(Altos.AO_LOG_FLIGHT, tiny_tick, 0, v)); + some_reasonable_data = true; + } else { + int s = v ^ 0x8000; + if (Altos.ao_flight_startup <= s && s <= Altos.ao_flight_invalid) { + Log(new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, s, 0)); + if (s == Altos.ao_flight_landed) { + done = true; + break; + } + some_reasonable_data = true; + } else { + if (v != 0xffff) + some_reasonable_data = true; + Log(new AltosEepromRecord(Altos.AO_LOG_HEIGHT, tiny_tick, v, 0)); + if (state < Altos.ao_flight_drogue) + tiny_tick += 10; + else + tiny_tick += 100; + } + } + } + CheckFile(false); + if (!some_reasonable_data) + done = true; + } + void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException { int block, state_block = 0; - int state = 0; - boolean done = false; - int record; + int log_style = 0; + + state = 0; + done = false; + start = true; if (flights.config_data.serial == 0) throw new IOException("no serial number found"); @@ -104,47 +198,26 @@ public class AltosEepromDownload implements Runnable { for (block = log.start_block; !done && block < log.end_block; block++) { monitor.set_value(Altos.state_to_string[state], state, block - state_block); - AltosEepromBlock eeblock = new AltosEepromBlock(serial_line, block); + AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block); - if (eeblock.has_flight) { - flight = eeblock.flight; - monitor.set_flight(flight); - } - if (eeblock.has_date) { - year = eeblock.year; - month = eeblock.month; - day = eeblock.day; - want_file = true; - } + /* + * Figure out what kind of data is there + */ - if (eeblock.size() == 0 || - eeblock.has_state && eeblock.state == Altos.ao_flight_landed) - done = true; - - /* Monitor state transitions to update display */ - if (eeblock.has_state) { - if (eeblock.state > Altos.ao_flight_pad) - want_file = true; - if (eeblock.state > state) - state = eeblock.state; + if (block == log.start_block) { + if (eechunk.data(0) == Altos.AO_LOG_FLIGHT) + log_style = log_full; + else + log_style = log_tiny; } - if (parse_exception == null && eeblock.parse_exception != null) - parse_exception = eeblock.parse_exception; - - CheckFile(false); - - for (record = 0; record < eeblock.size(); record++) { - AltosEepromRecord r = eeblock.get(record); - - if (r.cmd != Altos.AO_LOG_INVALID) { - String log_line = String.format("%c %4x %4x %4x\n", - r.cmd, r.tick, r.a, r.b); - if (eeprom_file != null) - eeprom_file.write(log_line); - else - eeprom_pending.add(log_line); - } + switch (log_style) { + case log_full: + CaptureFull(eechunk); + break; + case log_tiny: + CaptureTiny(eechunk); + break; } } CheckFile(true); diff --git a/altosui/AltosEepromIterable.java b/altosui/AltosEepromIterable.java index f8e6d7e5..bb7c7bef 100644 --- a/altosui/AltosEepromIterable.java +++ b/altosui/AltosEepromIterable.java @@ -124,6 +124,10 @@ public class AltosEepromIterable extends AltosRecordIterable { } eeprom.seen |= seen_sensor; break; + case Altos.AO_LOG_HEIGHT: + state.height = record.a; + eeprom.seen |= seen_sensor; + break; case Altos.AO_LOG_TEMP_VOLT: state.temp = record.a; state.batt = record.b; @@ -155,7 +159,6 @@ public class AltosEepromIterable extends AltosRecordIterable { int flags = (record.b >> 8); state.gps.connected = (flags & Altos.AO_GPS_RUNNING) != 0; state.gps.locked = (flags & Altos.AO_GPS_VALID) != 0; - state.gps.date_valid = (flags & Altos.AO_GPS_DATE_VALID) != 0; state.gps.nsat = (flags & Altos.AO_GPS_NUM_SAT_MASK) >> Altos.AO_GPS_NUM_SAT_SHIFT; break; diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index 10befad4..4c6deaa0 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -73,7 +73,16 @@ public class AltosEepromLog { in_end_block = in_start_block + 2; for (block = in_start_block; block < in_end_block; block++) { - AltosEepromBlock eeblock = new AltosEepromBlock(serial_line, block); + AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block); + + if (block == in_start_block) { + if (eechunk.data(0) != Altos.AO_LOG_FLIGHT) { + flight = eechunk.data16(0); + has_flight = true; + break; + } + } + AltosEepromBlock eeblock = new AltosEepromBlock(eechunk); if (eeblock.has_flight) { flight = eeblock.flight; has_flight = true; diff --git a/altosui/AltosEepromRecord.java b/altosui/AltosEepromRecord.java index e5196c50..5787af86 100644 --- a/altosui/AltosEepromRecord.java +++ b/altosui/AltosEepromRecord.java @@ -38,6 +38,8 @@ public class AltosEepromRecord { public String data; public boolean tick_valid; + static final int record_length = 8; + int[] ParseHex(String line) { String[] tokens = line.split("\\s+"); int[] array = new int[tokens.length]; @@ -51,44 +53,35 @@ public class AltosEepromRecord { return array; } - int checksum(int[] line) { + int checksum(int[] data, int start) { int csum = 0x5a; - for (int i = 1; i < line.length; i++) - csum += line[i]; + for (int i = 0; i < record_length; i++) + csum += data[i + start]; return csum & 0xff; } - public AltosEepromRecord (AltosSerial serial_line, int addr) - throws TimeoutException, ParseException, InterruptedException { - String line = serial_line.get_reply(5000); - if (line == null) - throw new TimeoutException(); - int[] values = ParseHex(line); + public AltosEepromRecord (AltosEepromChunk chunk, int start) throws ParseException { + + cmd = chunk.data(start); + tick_valid = true; - if (values == null || values.length < 9) { - System.out.printf("invalid line %s", line); - throw new ParseException(String.format("inalid line %s", line), 0); - } - if (values[0] != (addr & 0xff)) - throw new ParseException(String.format("data address out of sync at 0x%x", - addr), 0); int i; - for (i = 1; i < values.length; i++) - if (values[i] != 0xff) + for (i = 0; i < record_length; i++) + if (chunk.data[start + i] != 0xff) break; - cmd = values[1]; - tick_valid = true; - if (i != values.length) { - if (checksum(values) != 0) - throw new ParseException(String.format("invalid checksum at 0x%x in line %s", addr, line), 0); + if (i != 8) { + if (checksum(chunk.data, start) != 0) + throw new ParseException(String.format("invalid checksum at 0x%x", + chunk.address + start), 0); } else { cmd = Altos.AO_LOG_INVALID; tick_valid = false; } - tick = values[3] + (values[4] << 8); - a = values[5] + (values[6] << 8); - b = values[7] + (values[8] << 8); + tick = chunk.data16(start + 2); + a = chunk.data16(start + 4); + b = chunk.data16(start + 6); + data = null; } diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 49f34ce3..9a9d0d36 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -28,6 +28,7 @@ altosui_JAVA = \ AltosDevice.java \ AltosDisplayThread.java \ AltosEepromBlock.java \ + AltosEepromChunk.java \ AltosEepromDelete.java \ AltosEepromDownload.java \ AltosEepromList.java \ -- cgit v1.2.3 From b155647472ddfacb07c5ffa832e4d1f4a13ad342 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 25 Mar 2011 22:01:18 -0700 Subject: altosui: Remove extra AltosEepromBlock layer This was interposed between the download layer and the eeprom layer to hold a eeprom block full of flight log records. The addition of the tiny log format required reworking the code to hold chunks full of eeprom data without regard to their content, so this content-specific layer didn't seem useful anymore. Signed-off-by: Keith Packard --- altosui/AltosEepromBlock.java | 111 --------------------------------------- altosui/AltosEepromDownload.java | 89 +++++++++++++++++-------------- altosui/AltosEepromLog.java | 49 +++++++---------- altosui/Makefile.am | 3 +- 4 files changed, 69 insertions(+), 183 deletions(-) delete mode 100644 altosui/AltosEepromBlock.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromBlock.java b/altosui/AltosEepromBlock.java deleted file mode 100644 index 650920d1..00000000 --- a/altosui/AltosEepromBlock.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright © 2011 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; - -import java.awt.*; -import java.awt.event.*; -import javax.swing.*; -import javax.swing.filechooser.FileNameExtensionFilter; -import javax.swing.table.*; -import java.io.*; -import java.util.*; -import java.text.*; -import java.util.prefs.*; -import java.util.concurrent.*; -import java.lang.reflect.Array; - -import libaltosJNI.*; - -public class AltosEepromBlock extends ArrayList { - boolean has_flight; - int flight; - boolean has_state; - int state; - boolean has_date; - int year, month, day; - boolean has_lat; - double lat; - boolean has_lon; - double lon; - boolean has_time; - int hour, minute, second; - ParseException parse_exception = null; - - public AltosEepromBlock (AltosEepromChunk chunk) { - int addr; - boolean done = false; - - has_flight = false; - has_state = false; - has_date = false; - has_lat = false; - has_lon = false; - has_time = false; - for (addr = 0; addr < chunk.chunk_size;) { - try { - AltosEepromRecord r = new AltosEepromRecord(chunk, addr); - - if (r.cmd == Altos.AO_LOG_FLIGHT) { - flight = r.b; - has_flight = true; - } - - /* Monitor state transitions to update display */ - if (r.cmd == Altos.AO_LOG_STATE && r.a <= Altos.ao_flight_landed) { - if (!has_state || r.a > state) { - state = r.a; - has_state = true; - } - } - - if (r.cmd == Altos.AO_LOG_GPS_DATE) { - year = 2000 + (r.a & 0xff); - month = (r.a >> 8) & 0xff; - day = (r.b & 0xff); - has_date = true; - } - if (r.cmd == Altos.AO_LOG_GPS_TIME) { - hour = (r.a & 0xff); - minute = (r.a >> 8); - second = (r.b & 0xff); - has_time = true; - } - if (r.cmd == Altos.AO_LOG_GPS_LAT) { - lat = (double) (r.a | (r.b << 16)) / 1e7; - has_lat = true; - } - if (r.cmd == Altos.AO_LOG_GPS_LON) { - lon = (double) (r.a | (r.b << 16)) / 1e7; - has_lon = true; - } - if (!done) - add(addr / 8, r); - if (r.cmd == Altos.AO_LOG_STATE && r.a == Altos.ao_flight_landed) - done = true; - } catch (ParseException pe) { - AltosEepromRecord r = new AltosEepromRecord(Altos.AO_LOG_INVALID, - 0, 0, 0); - if (parse_exception == null) - parse_exception = pe; - if (!done) - add(addr/8, r); - } - addr += 8; - } - } -} \ No newline at end of file diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index f96a3dc9..a03d2b43 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -96,77 +96,88 @@ public class AltosEepromDownload implements Runnable { int state; void CaptureFull(AltosEepromChunk eechunk) throws IOException { - AltosEepromBlock eeblock = new AltosEepromBlock(eechunk); - - if (eeblock.has_flight) { - flight = eeblock.flight; - monitor.set_flight(flight); - } - if (eeblock.has_date) { - year = eeblock.year; - month = eeblock.month; - day = eeblock.day; - want_file = true; - } + boolean any_valid = false; + for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromRecord.record_length) { + try { + AltosEepromRecord r = new AltosEepromRecord(eechunk, i); + if (r.cmd == Altos.AO_LOG_FLIGHT) { + flight = r.b; + monitor.set_flight(flight); + } - if (eeblock.size() == 0 || - eeblock.has_state && eeblock.state == Altos.ao_flight_landed) - done = true; + /* Monitor state transitions to update display */ + if (r.cmd == Altos.AO_LOG_STATE && r.a <= Altos.ao_flight_landed) { + state = r.a; + if (state > Altos.ao_flight_pad) + want_file = true; + } - /* Monitor state transitions to update display */ - if (eeblock.has_state) { - if (eeblock.state > Altos.ao_flight_pad) - want_file = true; - if (eeblock.state > state) - state = eeblock.state; + if (r.cmd == Altos.AO_LOG_GPS_DATE) { + year = 2000 + (r.a & 0xff); + month = (r.a >> 8) & 0xff; + day = (r.b & 0xff); + want_file = true; + } + if (r.cmd == Altos.AO_LOG_STATE && r.a == Altos.ao_flight_landed) + done = true; + any_valid = true; + Log(r); + } catch (ParseException pe) { + if (parse_exception == null) + parse_exception = pe; + } } - if (parse_exception == null && eeblock.parse_exception != null) - parse_exception = eeblock.parse_exception; + if (!any_valid) + done = true; CheckFile(false); - - for (int record = 0; record < eeblock.size(); record++) - Log(eeblock.get(record)); } boolean start; int tiny_tick; void CaptureTiny (AltosEepromChunk eechunk) throws IOException { - boolean some_reasonable_data = false; + boolean any_valid = false; - for (int i = 0; i < eechunk.data.length; i += 2) { - int v = eechunk.data16(i); + for (int i = 0; i < eechunk.data.length && !done; i += 2) { + int v = eechunk.data16(i); + AltosEepromRecord r; if (i == 0 && start) { tiny_tick = 0; start = false; flight = v; - Log(new AltosEepromRecord(Altos.AO_LOG_FLIGHT, tiny_tick, 0, v)); - some_reasonable_data = true; + monitor.set_flight(flight); + r = new AltosEepromRecord(Altos.AO_LOG_FLIGHT, tiny_tick, 0, v); + any_valid = true; } else { int s = v ^ 0x8000; + if (Altos.ao_flight_startup <= s && s <= Altos.ao_flight_invalid) { - Log(new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, s, 0)); - if (s == Altos.ao_flight_landed) { + r = new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, s, 0); + if (s == Altos.ao_flight_landed) done = true; - break; - } - some_reasonable_data = true; + any_valid = true; } else { if (v != 0xffff) - some_reasonable_data = true; - Log(new AltosEepromRecord(Altos.AO_LOG_HEIGHT, tiny_tick, v, 0)); + any_valid = true; + r = new AltosEepromRecord(Altos.AO_LOG_HEIGHT, tiny_tick, v, 0); + + /* + * The flight software records ascent data every 100ms, and descent + * data every 1s. + */ if (state < Altos.ao_flight_drogue) tiny_tick += 10; else tiny_tick += 100; } } + Log(r); } CheckFile(false); - if (!some_reasonable_data) + if (!any_valid) done = true; } diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index 4c6deaa0..f7fb39e1 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -41,10 +41,7 @@ public class AltosEepromLog { int start_block; int end_block; - boolean has_gps; int year, month, day; - int hour, minute, second; - double lat, lon; boolean download; boolean delete; @@ -54,7 +51,7 @@ public class AltosEepromLog { throws InterruptedException, TimeoutException { int block; - boolean has_date = false, has_time = false, has_lat = false, has_lon = false; + boolean has_date = false; start_block = in_start_block; end_block = in_end_block; @@ -82,34 +79,24 @@ public class AltosEepromLog { break; } } - AltosEepromBlock eeblock = new AltosEepromBlock(eechunk); - if (eeblock.has_flight) { - flight = eeblock.flight; - has_flight = true; - } - if (eeblock.has_date) { - year = eeblock.year; - month = eeblock.month; - day = eeblock.day; - has_date = true; - } - if (eeblock.has_time) { - hour = eeblock.hour; - minute = eeblock.minute; - second = eeblock.second; - has_time = true; - } - if (eeblock.has_lat) { - lat = eeblock.lat; - has_lat = true; - } - if (eeblock.has_lon) { - lon = eeblock.lon; - has_lon = true; + for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) { + try { + AltosEepromRecord r = new AltosEepromRecord(eechunk, i); + + if (r.cmd == Altos.AO_LOG_FLIGHT) { + flight = r.b; + has_flight = true; + } + if (r.cmd == Altos.AO_LOG_GPS_DATE) { + year = 2000 + (r.a & 0xff); + month = (r.a >> 8) & 0xff; + day = (r.b & 0xff); + has_date = true; + } + } catch (ParseException pe) { + } } - if (has_date && has_time && has_lat && has_lon) - has_gps = true; - if (has_gps && has_flight) + if (has_date && has_flight) break; } } diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 9a9d0d36..01fe50c8 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -1,6 +1,6 @@ SUBDIRS=libaltos JAVAROOT=classes -AM_JAVACFLAGS=-encoding UTF-8 +AM_JAVACFLAGS=-encoding UTF-8 -Xlint:deprecation man_MANS=altosui.1 @@ -27,7 +27,6 @@ altosui_JAVA = \ AltosDeviceDialog.java \ AltosDevice.java \ AltosDisplayThread.java \ - AltosEepromBlock.java \ AltosEepromChunk.java \ AltosEepromDelete.java \ AltosEepromDownload.java \ -- cgit v1.2.3 From f23d0f3cbf1fb0c8eab497e266625f6410b69ba3 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 27 Mar 2011 00:46:19 -0700 Subject: altosui: Tell serial device which frame to use for timeout dialogs For the timeout dialog to appear, a frame must be configured for it to appear near. This patch sends the frame from the eeprom download functions to the serial code. That path doesn't yet work as the eeprom download is still trying to talk to the serial device from the swing event thread, which prevents the cancel dialog from working. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 1 + altosui/AltosEepromManage.java | 2 ++ 2 files changed, 3 insertions(+) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index a03d2b43..fad16460 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -328,6 +328,7 @@ public class AltosEepromDownload implements Runnable { frame = given_frame; serial_line = given_serial_line; + serial_line.set_frame(frame); remote = given_remote; flights = given_flights; success = false; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index b12d95fa..fe1db9c7 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -106,6 +106,8 @@ public class AltosEepromManage implements ActionListener { if (!device.matchProduct(AltosDevice.product_telemetrum)) remote = true; + serial_line.set_frame(frame); + flights = new AltosEepromList(serial_line, remote); if (flights.size() == 0) { -- cgit v1.2.3 From 8dd455204cf8712fa8c142b0c0517cec1bf5fd0f Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 8 Apr 2011 10:13:55 -0700 Subject: altosui: Add low-level Bluetooth APIs Adds the JNI functions to query and connect to arbitrary bluetooth devices. Adds Java wrappers to construct a list of proximate bluetooth devices. Signed-off-by: Keith Packard --- altosui/AltosBTDevice.java | 142 ++++++++++ altosui/AltosEepromDownload.java | 1 + altosui/Makefile.am | 1 + altosui/libaltos/Makefile.am | 2 +- altosui/libaltos/cjnitest.c | 26 ++ altosui/libaltos/libaltos.c | 574 ++++++++++++++++++++++++--------------- altosui/libaltos/libaltos.h | 21 ++ 7 files changed, 543 insertions(+), 224 deletions(-) create mode 100644 altosui/AltosBTDevice.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java new file mode 100644 index 00000000..8eb18bb9 --- /dev/null +++ b/altosui/AltosBTDevice.java @@ -0,0 +1,142 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; +import java.lang.*; +import java.util.*; +import libaltosJNI.*; + +public class AltosBTDevice extends altos_bt_device { + + static public boolean initialized = false; + static public boolean loaded_library = false; + + public static boolean load_library() { + if (!initialized) { + try { + System.loadLibrary("altos"); + libaltos.altos_init(); + loaded_library = true; + } catch (UnsatisfiedLinkError e) { + loaded_library = false; + } + initialized = true; + } + return loaded_library; + } + + static String bt_product_telebt() { + if (load_library()) + return libaltosConstants.BLUETOOTH_PRODUCT_TELEBT; + return "TeleBT"; + } + + public final static String bt_product_telebt = bt_product_telebt(); + public final static String bt_product_any = "Any"; + public final static String bt_product_basestation = "Basestation"; + + public String getProduct() { + String name = getName(); + if (name == null) + return "Altus Metrum"; + int dash = name.lastIndexOf("-"); + if (dash < 0) + return name; + return name.substring(0,dash); + } + + public int getSerial() { + String name = getName(); + if (name == null) + return 0; + int dash = name.lastIndexOf("-"); + if (dash < 0 || dash >= name.length()) + return 0; + String sn = name.substring(dash + 1, name.length()); + try { + return Integer.parseInt(sn); + } catch (NumberFormatException ne) { + return 0; + } + } + + public String toString() { + String name = getName(); + if (name == null) + name = "Altus Metrum"; + return String.format("%-20.20s %4d %s", + getProduct(), getSerial(), getAddr()); + } + + public String toShortString() { + String name = getName(); + if (name == null) + name = "Altus Metrum"; + return String.format("%s %d %s", + getProduct(), getSerial(), getAddr()); + + } + + public boolean isAltusMetrum() { + if (getName().startsWith(bt_product_telebt)) + return true; + return false; + } + + public boolean matchProduct(String want_product) { + + if (!isAltusMetrum()) + return false; + + if (want_product.equals(bt_product_any)) + return true; + + if (want_product.equals(bt_product_basestation)) + return matchProduct(bt_product_telebt); + + if (want_product.equals(getProduct())) + return true; + + return false; + } + + static AltosBTDevice[] list(String product) { + if (!load_library()) + return null; + + SWIGTYPE_p_altos_bt_list list = libaltos.altos_bt_list_start(); + + ArrayList device_list = new ArrayList(); + if (list != null) { + SWIGTYPE_p_altos_file file; + + for (;;) { + AltosBTDevice device = new AltosBTDevice(); + if (libaltos.altos_bt_list_next(list, device) == 0) + break; + if (device.matchProduct(product)) + device_list.add(device); + } + libaltos.altos_bt_list_finish(list); + } + + AltosBTDevice[] devices = new AltosBTDevice[device_list.size()]; + for (int i = 0; i < device_list.size(); i++) + devices[i] = device_list.get(i); + return devices; + } +} \ No newline at end of file diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index fad16460..5c704968 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -158,6 +158,7 @@ public class AltosEepromDownload implements Runnable { r = new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, s, 0); if (s == Altos.ao_flight_landed) done = true; + state = s; any_valid = true; } else { if (v != 0xffff) diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 01fe50c8..5b11d1b0 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -26,6 +26,7 @@ altosui_JAVA = \ AltosDescent.java \ AltosDeviceDialog.java \ AltosDevice.java \ + AltosBTDevice.java \ AltosDisplayThread.java \ AltosEepromChunk.java \ AltosEepromDelete.java \ diff --git a/altosui/libaltos/Makefile.am b/altosui/libaltos/Makefile.am index 388d2104..3f5f3ee2 100644 --- a/altosui/libaltos/Makefile.am +++ b/altosui/libaltos/Makefile.am @@ -16,7 +16,7 @@ noinst_PROGRAMS=cjnitest cjnitest_LDADD=libaltos.la -LIBS= +LIBS=-lbluetooth HFILES=libaltos.h diff --git a/altosui/libaltos/cjnitest.c b/altosui/libaltos/cjnitest.c index c6d6e069..79561643 100644 --- a/altosui/libaltos/cjnitest.c +++ b/altosui/libaltos/cjnitest.c @@ -14,6 +14,8 @@ main () { struct altos_device device; struct altos_list *list; + struct altos_bt_device bt_device; + struct altos_bt_list *bt_list; altos_init(); list = altos_list_start(); @@ -39,5 +41,29 @@ main () altos_close(file); } altos_list_finish(list); + bt_list = altos_bt_list_start(); + while (altos_bt_list_next(bt_list, &bt_device)) { + printf ("%s %s\n", bt_device.name, bt_device.addr); + if (strncmp(bt_device.name, "TeleBT", 6) == 0) { + struct altos_file *file; + + int c; + file = altos_bt_open(&bt_device); + if (!file) { + printf("altos_bt_open failed\n"); + continue; + } + altos_puts(file,"v\nc s\n"); + altos_flush(file); + while ((c = altos_getchar(file, 100)) >= 0) { + putchar(c); + } + if (c != LIBALTOS_TIMEOUT) + printf("getchar returns %d\n", c); + altos_close(file); + } + } + altos_bt_list_finish(bt_list); altos_fini(); + return 0; } diff --git a/altosui/libaltos/libaltos.c b/altosui/libaltos/libaltos.c index 465f0ac8..13635a0d 100644 --- a/altosui/libaltos/libaltos.c +++ b/altosui/libaltos/libaltos.c @@ -56,6 +56,230 @@ altos_strndup (const char *s, size_t n) #define altos_strndup strndup #endif +#ifdef POSIX_TTY + +#include +#include +#include +#include +#include + +#define USB_BUF_SIZE 64 + +struct altos_file { + int fd; +#ifdef USE_POLL + int pipe[2]; +#else + int out_fd; +#endif + unsigned char out_data[USB_BUF_SIZE]; + int out_used; + unsigned char in_data[USB_BUF_SIZE]; + int in_used; + int in_read; +}; + +PUBLIC struct altos_file * +altos_open(struct altos_device *device) +{ + struct altos_file *file = calloc (sizeof (struct altos_file), 1); + int ret; + struct termios term; + + if (!file) + return NULL; + + file->fd = open(device->path, O_RDWR | O_NOCTTY); + if (file->fd < 0) { + perror(device->path); + free(file); + return NULL; + } +#ifdef USE_POLL + pipe(file->pipe); +#else + file->out_fd = open(device->path, O_RDWR | O_NOCTTY); + if (file->out_fd < 0) { + perror(device->path); + close(file->fd); + free(file); + return NULL; + } +#endif + ret = tcgetattr(file->fd, &term); + if (ret < 0) { + perror("tcgetattr"); + close(file->fd); +#ifndef USE_POLL + close(file->out_fd); +#endif + free(file); + return NULL; + } + cfmakeraw(&term); +#ifdef USE_POLL + term.c_cc[VMIN] = 1; + term.c_cc[VTIME] = 0; +#else + term.c_cc[VMIN] = 0; + term.c_cc[VTIME] = 1; +#endif + ret = tcsetattr(file->fd, TCSAFLUSH, &term); + if (ret < 0) { + perror("tcsetattr"); + close(file->fd); +#ifndef USE_POLL + close(file->out_fd); +#endif + free(file); + return NULL; + } + return file; +} + +PUBLIC void +altos_close(struct altos_file *file) +{ + if (file->fd != -1) { + int fd = file->fd; + file->fd = -1; +#ifdef USE_POLL + write(file->pipe[1], "\r", 1); +#else + close(file->out_fd); + file->out_fd = -1; +#endif + close(fd); + } +} + +PUBLIC void +altos_free(struct altos_file *file) +{ + altos_close(file); + free(file); +} + +PUBLIC int +altos_flush(struct altos_file *file) +{ + if (file->out_used && 0) { + printf ("flush \""); + fwrite(file->out_data, 1, file->out_used, stdout); + printf ("\"\n"); + } + while (file->out_used) { + int ret; + + if (file->fd < 0) + return -EBADF; +#ifdef USE_POLL + ret = write (file->fd, file->out_data, file->out_used); +#else + ret = write (file->out_fd, file->out_data, file->out_used); +#endif + if (ret < 0) + return -errno; + if (ret) { + memmove(file->out_data, file->out_data + ret, + file->out_used - ret); + file->out_used -= ret; + } + } + return 0; +} + +PUBLIC int +altos_putchar(struct altos_file *file, char c) +{ + int ret; + + if (file->out_used == USB_BUF_SIZE) { + ret = altos_flush(file); + if (ret) { + return ret; + } + } + file->out_data[file->out_used++] = c; + ret = 0; + if (file->out_used == USB_BUF_SIZE) + ret = altos_flush(file); + return 0; +} + +#ifdef USE_POLL +#include +#endif + +static int +altos_fill(struct altos_file *file, int timeout) +{ + int ret; +#ifdef USE_POLL + struct pollfd fd[2]; +#endif + + if (timeout == 0) + timeout = -1; + while (file->in_read == file->in_used) { + if (file->fd < 0) + return LIBALTOS_ERROR; +#ifdef USE_POLL + fd[0].fd = file->fd; + fd[0].events = POLLIN|POLLERR|POLLHUP|POLLNVAL; + fd[1].fd = file->pipe[0]; + fd[1].events = POLLIN; + ret = poll(fd, 2, timeout); + if (ret < 0) { + perror("altos_getchar"); + return LIBALTOS_ERROR; + } + if (ret == 0) + return LIBALTOS_TIMEOUT; + + if (fd[0].revents & (POLLHUP|POLLERR|POLLNVAL)) + return LIBALTOS_ERROR; + if (fd[0].revents & POLLIN) +#endif + { + ret = read(file->fd, file->in_data, USB_BUF_SIZE); + if (ret < 0) { + perror("altos_getchar"); + return LIBALTOS_ERROR; + } + file->in_read = 0; + file->in_used = ret; +#ifndef USE_POLL + if (ret == 0 && timeout > 0) + return LIBALTOS_TIMEOUT; +#endif + } + } + if (file->in_used && 0) { + printf ("fill \""); + fwrite(file->in_data, 1, file->in_used, stdout); + printf ("\"\n"); + } + return 0; +} + +PUBLIC int +altos_getchar(struct altos_file *file, int timeout) +{ + int ret; + while (file->in_read == file->in_used) { + if (file->fd < 0) + return LIBALTOS_ERROR; + ret = altos_fill(file, timeout); + if (ret) + return ret; + } + return file->in_data[file->in_read++]; +} + +#endif /* POSIX_TTY */ + /* * Scan for Altus Metrum devices by looking through /sys */ @@ -68,6 +292,10 @@ altos_strndup (const char *s, size_t n) #include #include #include +#include +#include +#include +#include static char * cc_fullname (char *dir, char *file) @@ -354,6 +582,129 @@ altos_list_finish(struct altos_list *usbdevs) free(usbdevs); } +struct altos_bt_list { + inquiry_info *ii; + int sock; + int dev_id; + int rsp; + int num_rsp; +}; + +#define INQUIRY_MAX_RSP 255 +#define INQUIRY_LEN 8 + +struct altos_bt_list * +altos_bt_list_start(void) +{ + struct altos_bt_list *bt_list; + + bt_list = calloc(1, sizeof (struct altos_bt_list)); + if (!bt_list) + goto no_bt_list; + + bt_list->ii = calloc(INQUIRY_MAX_RSP, sizeof (inquiry_info)); + if (!bt_list->ii) + goto no_ii; + bt_list->dev_id = hci_get_route(NULL); + if (bt_list->dev_id < 0) + goto no_dev_id; + + bt_list->sock = hci_open_dev(bt_list->dev_id); + if (bt_list->sock < 0) + goto no_sock; + + bt_list->num_rsp = hci_inquiry(bt_list->dev_id, + INQUIRY_LEN, + INQUIRY_MAX_RSP, + NULL, + &bt_list->ii, + IREQ_CACHE_FLUSH); + if (bt_list->num_rsp < 0) + goto no_rsp; + + bt_list->rsp = 0; + return bt_list; + +no_rsp: + close(bt_list->sock); +no_sock: +no_dev_id: + free(bt_list->ii); +no_ii: + free(bt_list); +no_bt_list: + return NULL; +} + +int +altos_bt_list_next(struct altos_bt_list *bt_list, + struct altos_bt_device *device) +{ + inquiry_info *ii; + + if (bt_list->rsp >= bt_list->num_rsp) + return 0; + + ii = &bt_list->ii[bt_list->rsp]; + ba2str(&ii->bdaddr, device->addr); + memset(&device->name, '\0', sizeof (device->name)); + if (hci_read_remote_name(bt_list->sock, &ii->bdaddr, + sizeof (device->name), + device->name, 0) < 0) { + strcpy(device->name, "[unknown]"); + } + bt_list->rsp++; + return 1; +} + +void +altos_bt_list_finish(struct altos_bt_list *bt_list) +{ + close(bt_list->sock); + free(bt_list->ii); + free(bt_list); +} + +struct altos_file * +altos_bt_open(struct altos_bt_device *device) +{ + struct sockaddr_rc addr = { 0 }; + int s, status; + struct altos_file *file; + + file = calloc(1, sizeof (struct altos_file)); + if (!file) + goto no_file; + file->fd = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); + if (file->fd < 0) + goto no_sock; + + addr.rc_family = AF_BLUETOOTH; + addr.rc_channel = 1; + str2ba(device->addr, &addr.rc_bdaddr); + + status = connect(file->fd, + (struct sockaddr *)&addr, + sizeof(addr)); + if (status < 0) { + perror("connect"); + goto no_link; + } + +#ifdef USE_POLL + pipe(file->pipe); +#else + file->out_fd = dup(file->fd); +#endif + return file; +no_link: + close(s); +no_sock: + free(file); +no_file: + return NULL; +} + #endif #ifdef DARWIN @@ -468,229 +819,6 @@ altos_list_finish(struct altos_list *list) #endif -#ifdef POSIX_TTY - -#include -#include -#include -#include -#include - -#define USB_BUF_SIZE 64 - -struct altos_file { - int fd; -#ifdef USE_POLL - int pipe[2]; -#else - int out_fd; -#endif - unsigned char out_data[USB_BUF_SIZE]; - int out_used; - unsigned char in_data[USB_BUF_SIZE]; - int in_used; - int in_read; -}; - -PUBLIC struct altos_file * -altos_open(struct altos_device *device) -{ - struct altos_file *file = calloc (sizeof (struct altos_file), 1); - int ret; - struct termios term; - - if (!file) - return NULL; - - file->fd = open(device->path, O_RDWR | O_NOCTTY); - if (file->fd < 0) { - perror(device->path); - free(file); - return NULL; - } -#ifdef USE_POLL - pipe(file->pipe); -#else - file->out_fd = open(device->path, O_RDWR | O_NOCTTY); - if (file->out_fd < 0) { - perror(device->path); - close(file->fd); - free(file); - return NULL; - } -#endif - ret = tcgetattr(file->fd, &term); - if (ret < 0) { - perror("tcgetattr"); - close(file->fd); -#ifndef USE_POLL - close(file->out_fd); -#endif - free(file); - return NULL; - } - cfmakeraw(&term); -#ifdef USE_POLL - term.c_cc[VMIN] = 1; - term.c_cc[VTIME] = 0; -#else - term.c_cc[VMIN] = 0; - term.c_cc[VTIME] = 1; -#endif - ret = tcsetattr(file->fd, TCSAFLUSH, &term); - if (ret < 0) { - perror("tcsetattr"); - close(file->fd); -#ifndef USE_POLL - close(file->out_fd); -#endif - free(file); - return NULL; - } - return file; -} - -PUBLIC void -altos_close(struct altos_file *file) -{ - if (file->fd != -1) { - int fd = file->fd; - file->fd = -1; -#ifdef USE_POLL - write(file->pipe[1], "\r", 1); -#else - close(file->out_fd); - file->out_fd = -1; -#endif - close(fd); - } -} - -PUBLIC void -altos_free(struct altos_file *file) -{ - altos_close(file); - free(file); -} - -PUBLIC int -altos_flush(struct altos_file *file) -{ - if (file->out_used && 0) { - printf ("flush \""); - fwrite(file->out_data, 1, file->out_used, stdout); - printf ("\"\n"); - } - while (file->out_used) { - int ret; - - if (file->fd < 0) - return -EBADF; -#ifdef USE_POLL - ret = write (file->fd, file->out_data, file->out_used); -#else - ret = write (file->out_fd, file->out_data, file->out_used); -#endif - if (ret < 0) - return -errno; - if (ret) { - memmove(file->out_data, file->out_data + ret, - file->out_used - ret); - file->out_used -= ret; - } - } - return 0; -} - -PUBLIC int -altos_putchar(struct altos_file *file, char c) -{ - int ret; - - if (file->out_used == USB_BUF_SIZE) { - ret = altos_flush(file); - if (ret) { - return ret; - } - } - file->out_data[file->out_used++] = c; - ret = 0; - if (file->out_used == USB_BUF_SIZE) - ret = altos_flush(file); - return 0; -} - -#ifdef USE_POLL -#include -#endif - -static int -altos_fill(struct altos_file *file, int timeout) -{ - int ret; -#ifdef USE_POLL - struct pollfd fd[2]; -#endif - - if (timeout == 0) - timeout = -1; - while (file->in_read == file->in_used) { - if (file->fd < 0) - return LIBALTOS_ERROR; -#ifdef USE_POLL - fd[0].fd = file->fd; - fd[0].events = POLLIN|POLLERR|POLLHUP|POLLNVAL; - fd[1].fd = file->pipe[0]; - fd[1].events = POLLIN; - ret = poll(fd, 2, timeout); - if (ret < 0) { - perror("altos_getchar"); - return LIBALTOS_ERROR; - } - if (ret == 0) - return LIBALTOS_TIMEOUT; - - if (fd[0].revents & (POLLHUP|POLLERR|POLLNVAL)) - return LIBALTOS_ERROR; - if (fd[0].revents & POLLIN) -#endif - { - ret = read(file->fd, file->in_data, USB_BUF_SIZE); - if (ret < 0) { - perror("altos_getchar"); - return LIBALTOS_ERROR; - } - file->in_read = 0; - file->in_used = ret; -#ifndef USE_POLL - if (ret == 0 && timeout > 0) - return LIBALTOS_TIMEOUT; -#endif - } - } - if (file->in_used && 0) { - printf ("fill \""); - fwrite(file->in_data, 1, file->in_used, stdout); - printf ("\"\n"); - } - return 0; -} - -PUBLIC int -altos_getchar(struct altos_file *file, int timeout) -{ - int ret; - while (file->in_read == file->in_used) { - if (file->fd < 0) - return LIBALTOS_ERROR; - ret = altos_fill(file, timeout); - if (ret) - return ret; - } - return file->in_data[file->in_read++]; -} - -#endif /* POSIX_TTY */ #ifdef WINDOWS diff --git a/altosui/libaltos/libaltos.h b/altosui/libaltos/libaltos.h index 0e5691cb..9c3f9655 100644 --- a/altosui/libaltos/libaltos.h +++ b/altosui/libaltos/libaltos.h @@ -58,6 +58,15 @@ struct altos_device { //%mutable; }; +#define BLUETOOTH_PRODUCT_TELEBT "TeleBT" + +struct altos_bt_device { + //%immutable; + char name[256]; + char addr[20]; + //%mutable; +}; + #define LIBALTOS_SUCCESS 0 #define LIBALTOS_ERROR -1 #define LIBALTOS_TIMEOUT -2 @@ -100,4 +109,16 @@ altos_flush(struct altos_file *file); PUBLIC int altos_getchar(struct altos_file *file, int timeout); +PUBLIC struct altos_bt_list * +altos_bt_list_start(void); + +PUBLIC int +altos_bt_list_next(struct altos_bt_list *list, struct altos_bt_device *device); + +PUBLIC void +altos_bt_list_finish(struct altos_bt_list *list); + +PUBLIC struct altos_file * +altos_bt_open(struct altos_bt_device *device); + #endif /* _LIBALTOS_H_ */ -- cgit v1.2.3 From 7f49d694e776819e03b2c708e1c4ee23ba311430 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 9 Apr 2011 22:53:12 -0700 Subject: altos/altosui: Log averaged baro sensor data in Tm/Tn Instead of logging the best height guess from the kalman filter, log barometer data. The logged data consists of the average value betwen log points to reduce noise. Signed-off-by: Keith Packard --- altosui/Altos.java | 2 +- altosui/AltosDataPoint.java | 1 + altosui/AltosDataPointReader.java | 1 + altosui/AltosEepromDownload.java | 3 ++- altosui/AltosEepromIterable.java | 9 +++++++-- altosui/AltosGraphUI.java | 2 +- src/ao_log_tiny.c | 35 +++++++++++++++++++++++++---------- 7 files changed, 38 insertions(+), 15 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/Altos.java b/altosui/Altos.java index 1f791da5..54aced32 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -34,7 +34,7 @@ public class Altos { static final int AO_LOG_GPS_ALT = 'H'; static final int AO_LOG_GPS_SAT = 'V'; static final int AO_LOG_GPS_DATE = 'Y'; - static final int AO_LOG_HEIGHT = 'h'; + static final int AO_LOG_PRESSURE = 'P'; /* Added for header fields in eeprom files */ static final int AO_LOG_CONFIG_VERSION = 1000; diff --git a/altosui/AltosDataPoint.java b/altosui/AltosDataPoint.java index 66313e03..5e077320 100644 --- a/altosui/AltosDataPoint.java +++ b/altosui/AltosDataPoint.java @@ -25,5 +25,6 @@ interface AltosDataPoint { double battery_voltage(); double drogue_voltage(); double main_voltage(); + boolean has_accel(); } diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index 4335421c..fa48013f 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -59,6 +59,7 @@ class AltosDataPointReader implements Iterable { public double battery_voltage() { return record.battery_voltage(); } public double drogue_voltage() { return record.drogue_voltage(); } public double main_voltage() { return record.main_voltage(); } + public boolean has_accel() { return has_accel; } }; } diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index fad16460..a42f401c 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -162,7 +162,8 @@ public class AltosEepromDownload implements Runnable { } else { if (v != 0xffff) any_valid = true; - r = new AltosEepromRecord(Altos.AO_LOG_HEIGHT, tiny_tick, v, 0); + + r = new AltosEepromRecord(Altos.AO_LOG_PRESSURE, tiny_tick, 0, v); /* * The flight software records ascent data every 100ms, and descent diff --git a/altosui/AltosEepromIterable.java b/altosui/AltosEepromIterable.java index 624e1dd3..16349b88 100644 --- a/altosui/AltosEepromIterable.java +++ b/altosui/AltosEepromIterable.java @@ -134,8 +134,13 @@ public class AltosEepromIterable extends AltosRecordIterable { eeprom.seen |= seen_sensor; has_accel = true; break; - case Altos.AO_LOG_HEIGHT: - state.height = (short) record.a; + case Altos.AO_LOG_PRESSURE: + state.pres = record.b; + state.flight_pres = state.pres; + if (eeprom.n_pad_samples == 0) { + eeprom.n_pad_samples++; + state.ground_pres = state.pres; + } eeprom.seen |= seen_sensor; break; case Altos.AO_LOG_TEMP_VOLT: diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index e98c302b..4b994b47 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -35,7 +35,7 @@ public class AltosGraphUI extends JFrame AltosGraphTime.Element speed = new AltosGraphTime.TimeSeries("Speed (m/s)", "Vertical Speed", green) { public void gotTimeData(double time, AltosDataPoint d) { - if (d.state() < Altos.ao_flight_drogue) { + if (d.state() < Altos.ao_flight_drogue && d.has_accel()) { series.add(time, d.accel_speed()); } else { series.add(time, d.baro_speed()); diff --git a/src/ao_log_tiny.c b/src/ao_log_tiny.c index f0c0662a..6c2468fc 100644 --- a/src/ao_log_tiny.c +++ b/src/ao_log_tiny.c @@ -44,9 +44,12 @@ static void ao_log_tiny_data(uint16_t d) void ao_log(void) { - uint16_t time; - int16_t delay; + uint16_t last_time; + uint16_t now; enum ao_flight_state ao_log_tiny_state; + int32_t sum; + int16_t count; + uint8_t ao_log_adc; ao_storage_setup(); @@ -57,9 +60,19 @@ ao_log(void) while (!ao_log_running) ao_sleep(&ao_log_running); - time = ao_time(); ao_log_tiny_data(ao_flight_number); + ao_log_tiny_data(ao_ground_pres); + sum = 0; + count = 0; + ao_log_adc = ao_sample_adc; + last_time = ao_time(); for (;;) { + ao_sleep(DATA_TO_XDATA(&ao_sample_adc)); + while (ao_log_adc != ao_sample_adc) { + sum += ao_adc_ring[ao_log_adc].pres; + count++; + ao_log_adc = ao_adc_ring_next(ao_log_adc); + } if (ao_flight_state != ao_log_tiny_state) { ao_log_tiny_data(ao_flight_state | 0x8000); ao_log_tiny_state = ao_flight_state; @@ -69,14 +82,16 @@ ao_log(void) if (ao_log_tiny_state == ao_flight_landed) ao_log_stop(); } - ao_log_tiny_data(ao_height); - time += ao_log_tiny_interval; - delay = time - ao_time(); - if (delay > 0) - ao_delay(delay); /* Stop logging when told to */ - while (!ao_log_running) - ao_sleep(&ao_log_running); + if (!ao_log_running) + ao_exit(); + now = ao_time(); + if ((int16_t) (now - (last_time + ao_log_tiny_interval)) >= 0 && count) { + ao_log_tiny_data(sum / count); + sum = 0; + count = 0; + last_time = now; + } } } -- cgit v1.2.3 From a0fb471ce10642fc4a4bd40e4a81f8d6fe7a7c21 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 13 Apr 2011 20:27:38 -0700 Subject: altosui: oops - lost state changes when downloading eeprom data. This would cause the reader to just keep reading past the end of the flight. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index a42f401c..3dd5b12f 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -155,8 +155,9 @@ public class AltosEepromDownload implements Runnable { int s = v ^ 0x8000; if (Altos.ao_flight_startup <= s && s <= Altos.ao_flight_invalid) { - r = new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, s, 0); - if (s == Altos.ao_flight_landed) + state = s; + r = new AltosEepromRecord(Altos.AO_LOG_STATE, tiny_tick, state, 0); + if (state == Altos.ao_flight_landed) done = true; any_valid = true; } else { -- cgit v1.2.3 From 0e3e4f9c1e6a6bf972514f12c9d622258aa2aec2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 8 Aug 2011 01:47:29 -0700 Subject: altosui: Convert from channels to frequencies Major areas: * Preferences are stored as frequencies instead of channels * Serial configuration is done using frequencies * UI is presented with frequency lists Signed-off-by: Keith Packard --- altosui/AltosConfig.java | 54 +++++++++++++--- altosui/AltosConfigData.java | 4 +- altosui/AltosConfigFreqUI.java | 4 +- altosui/AltosConfigUI.java | 58 ++++++++++++------ altosui/AltosConvert.java | 33 ++++++++++ altosui/AltosEepromDelete.java | 15 ++--- altosui/AltosEepromDownload.java | 13 ++-- altosui/AltosFlightReader.java | 7 ++- altosui/AltosFlightUI.java | 26 +++++--- altosui/AltosFreqList.java | 87 ++++++++++++++++++++++++++ altosui/AltosFrequency.java | 6 ++ altosui/AltosIdleMonitorUI.java | 35 ++++++----- altosui/AltosIgnite.java | 37 ++++++----- altosui/AltosPreferences.java | 47 ++++++++++---- altosui/AltosScanUI.java | 125 ++++++++++++++++++++++++-------------- altosui/AltosSerial.java | 72 +++++++++++++++------- altosui/AltosTelemetryReader.java | 27 ++++++-- altosui/AltosUI.java | 12 +++- altosui/Makefile.am | 1 + 19 files changed, 486 insertions(+), 177 deletions(-) create mode 100644 altosui/AltosFreqList.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 04d75528..694ef4db 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -64,6 +64,8 @@ public class AltosConfig implements ActionListener { AltosDevice device; AltosSerial serial_line; boolean remote; + AltosConfigData remote_config_data; + double remote_frequency; int_ref serial; int_ref main_deploy; int_ref apogee_delay; @@ -72,6 +74,7 @@ public class AltosConfig implements ActionListener { int_ref flight_log_max; int_ref ignite_mode; int_ref pad_orientation; + int_ref radio_setting; string_ref version; string_ref product; string_ref callsign; @@ -109,7 +112,7 @@ public class AltosConfig implements ActionListener { } } - void start_serial() throws InterruptedException { + void start_serial() throws InterruptedException, TimeoutException { serial_started = true; if (remote) serial_line.start_remote(); @@ -129,12 +132,13 @@ public class AltosConfig implements ActionListener { config_ui.set_version(version.get()); config_ui.set_main_deploy(main_deploy.get()); config_ui.set_apogee_delay(apogee_delay.get()); - config_ui.set_radio_channel(radio_channel.get()); + config_ui.set_radio_frequency(frequency()); config_ui.set_radio_calibration(radio_calibration.get()); config_ui.set_flight_log_max(flight_log_max.get()); config_ui.set_ignite_mode(ignite_mode.get()); config_ui.set_pad_orientation(pad_orientation.get()); config_ui.set_callsign(callsign.get()); + config_ui.set_radio_setting(radio_setting.get()); config_ui.set_clean(); config_ui.make_visible(); } @@ -157,6 +161,7 @@ public class AltosConfig implements ActionListener { get_int(line, "Max flight log:", flight_log_max); get_int(line, "Ignite mode:", ignite_mode); get_int(line, "Pad orientation:", pad_orientation); + get_int(line, "Radio setting:", radio_setting); get_string(line, "Callsign:", callsign); get_string(line,"software-version", version); get_string(line,"product", product); @@ -200,6 +205,7 @@ public class AltosConfig implements ActionListener { } } } catch (InterruptedException ie) { + } catch (TimeoutException te) { } finally { try { stop_serial(); @@ -211,16 +217,20 @@ public class AltosConfig implements ActionListener { void save_data() { try { - int channel; + double frequency = frequency(); + boolean has_setting = radio_setting.get() != 0; start_serial(); serial_line.printf("c m %d\n", main_deploy.get()); serial_line.printf("c d %d\n", apogee_delay.get()); - channel = radio_channel.get(); - serial_line.printf("c r %d\n", channel); + serial_line.set_radio_frequency(frequency, + has_setting, + radio_calibration.get()); if (remote) { serial_line.stop_remote(); - serial_line.set_channel(channel); - AltosPreferences.set_channel(device.getSerial(), channel); + serial_line.set_radio_frequency(frequency, + has_setting, + radio_calibration.get()); + AltosPreferences.set_frequency(device.getSerial(), frequency); serial_line.start_remote(); } if (!remote) @@ -234,6 +244,7 @@ public class AltosConfig implements ActionListener { serial_line.printf("c o %d\n", pad_orientation.get()); serial_line.printf("c w\n"); } catch (InterruptedException ie) { + } catch (TimeoutException te) { } finally { try { stop_serial(); @@ -248,6 +259,7 @@ public class AltosConfig implements ActionListener { serial_line.printf("r eboot\n"); serial_line.flush_output(); } catch (InterruptedException ie) { + } catch (TimeoutException te) { } finally { try { stop_serial(); @@ -308,11 +320,32 @@ public class AltosConfig implements ActionListener { update_ui(); } + double frequency() { + int setting = radio_setting.get(); + + if (setting != 0) + return AltosConvert.radio_setting_to_frequency(setting, radio_calibration.get()); + else + return AltosConvert.radio_channel_to_frequency(radio_channel.get()); + } + + void set_frequency(double freq) { + int setting = radio_setting.get(); + + if (setting != 0) { + radio_setting.set(AltosConvert.radio_frequency_to_setting(freq, + radio_calibration.get())); + radio_channel.set(0); + } else { + radio_channel.set(AltosConvert.radio_frequency_to_channel(freq)); + } + } + void save_data() { main_deploy.set(config_ui.main_deploy()); apogee_delay.set(config_ui.apogee_delay()); - radio_channel.set(config_ui.radio_channel()); radio_calibration.set(config_ui.radio_calibration()); + set_frequency(config_ui.radio_frequency()); flight_log_max.set(config_ui.flight_log_max()); ignite_mode.set(config_ui.ignite_mode()); pad_orientation.set(config_ui.pad_orientation()); @@ -348,6 +381,7 @@ public class AltosConfig implements ActionListener { main_deploy = new int_ref(250); apogee_delay = new int_ref(0); radio_channel = new int_ref(0); + radio_setting = new int_ref(0); radio_calibration = new int_ref(1186611); flight_log_max = new int_ref(0); ignite_mode = new int_ref(-1); @@ -360,9 +394,9 @@ public class AltosConfig implements ActionListener { if (device != null) { try { serial_line = new AltosSerial(device); - if (!device.matchProduct(Altos.product_telemetrum)) - remote = true; try { + if (!device.matchProduct(Altos.product_telemetrum)) + remote = true; init_ui(); } catch (InterruptedException ie) { abort(); diff --git a/altosui/AltosConfigData.java b/altosui/AltosConfigData.java index 1d50ade9..aa7a90de 100644 --- a/altosui/AltosConfigData.java +++ b/altosui/AltosConfigData.java @@ -47,6 +47,7 @@ public class AltosConfigData implements Iterable { int main_deploy; int apogee_delay; int radio_channel; + int radio_setting; String callsign; int accel_cal_plus, accel_cal_minus; int radio_calibration; @@ -85,7 +86,7 @@ public class AltosConfigData implements Iterable { serial_line.printf("c s\nv\n"); lines = new LinkedList(); for (;;) { - String line = serial_line.get_reply_no_dialog(5000); + String line = serial_line.get_reply(); if (line == null) throw new TimeoutException(); if (line.contains("Syntax error")) @@ -95,6 +96,7 @@ public class AltosConfigData implements Iterable { try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {} try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {} try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {} + try { radio_setting = get_int(line, "Radio setting:"); } catch (Exception e) {} try { if (line.startsWith("Accel cal")) { String[] bits = line.split("\\s+"); diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index d68151ec..063d21b4 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -177,9 +177,9 @@ public class AltosConfigFreqUI extends JDialog implements ActionListener { int i; for (i = 0; i < list_model.size(); i++) { AltosFrequency f = (AltosFrequency) list_model.get(i); - if (f.frequency == frequency.frequency) + if (frequency.frequency == f.frequency) return; - if (f.frequency > frequency.frequency) + if (frequency.frequency < f.frequency) break; } list_model.insertElementAt(frequency, i); diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 1a48c1d3..c109924e 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -43,8 +43,9 @@ public class AltosConfigUI JLabel serial_label; JLabel main_deploy_label; JLabel apogee_delay_label; - JLabel radio_channel_label; + JLabel frequency_label; JLabel radio_calibration_label; + JLabel radio_frequency_label; JLabel flight_log_max_label; JLabel ignite_mode_label; JLabel pad_orientation_label; @@ -58,7 +59,7 @@ public class AltosConfigUI JLabel serial_value; JComboBox main_deploy_value; JComboBox apogee_delay_value; - JComboBox radio_channel_value; + AltosFreqList radio_frequency_value; JTextField radio_calibration_value; JComboBox flight_log_max_value; JComboBox ignite_mode_value; @@ -98,13 +99,6 @@ public class AltosConfigUI "Antenna Down", }; - static String[] radio_channel_values = new String[10]; - { - for (int i = 0; i <= 9; i++) - radio_channel_values[i] = String.format("Channel %1d (%7.3fMHz)", - i, 434.550 + i * 0.1); - } - /* A window listener to catch closing events and tell the config code */ class ConfigListener extends WindowAdapter { AltosConfigUI ui; @@ -245,7 +239,7 @@ public class AltosConfigUI apogee_delay_value.addItemListener(this); pane.add(apogee_delay_value, c); - /* Radio channel */ + /* Frequency */ c = new GridBagConstraints(); c.gridx = 0; c.gridy = 5; c.gridwidth = 4; @@ -253,8 +247,8 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = il; c.ipady = 5; - radio_channel_label = new JLabel("Radio Channel:"); - pane.add(radio_channel_label, c); + radio_frequency_label = new JLabel("Frequency:"); + pane.add(radio_frequency_label, c); c = new GridBagConstraints(); c.gridx = 4; c.gridy = 5; @@ -264,10 +258,9 @@ public class AltosConfigUI c.anchor = GridBagConstraints.LINE_START; c.insets = ir; c.ipady = 5; - radio_channel_value = new JComboBox(radio_channel_values); - radio_channel_value.setEditable(false); - radio_channel_value.addItemListener(this); - pane.add(radio_channel_value, c); + radio_frequency_value = new AltosFreqList(); + radio_frequency_value.addItemListener(this); + pane.add(radio_frequency_value, c); /* Radio Calibration */ c = new GridBagConstraints(); @@ -501,6 +494,7 @@ public class AltosConfigUI /* set and get all of the dialog values */ public void set_product(String product) { + radio_frequency_value.set_product(product); product_value.setText(product); } @@ -509,6 +503,7 @@ public class AltosConfigUI } public void set_serial(int serial) { + radio_frequency_value.set_serial(serial); serial_value.setText(String.format("%d", serial)); } @@ -528,12 +523,32 @@ public class AltosConfigUI return Integer.parseInt(apogee_delay_value.getSelectedItem().toString()); } - public void set_radio_channel(int new_radio_channel) { - radio_channel_value.setSelectedIndex(new_radio_channel); + public void set_radio_frequency(double new_radio_frequency) { + int i; + for (i = 0; i < radio_frequency_value.getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); + + if (f.close(new_radio_frequency)) { + radio_frequency_value.setSelectedIndex(i); + return; + } + } + for (i = 0; i < radio_frequency_value.getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) radio_frequency_value.getItemAt(i); + + if (new_radio_frequency < f.frequency) + break; + } + String description = String.format("%s serial %s", + product_value.getText(), + serial_value.getText()); + AltosFrequency new_frequency = new AltosFrequency(new_radio_frequency, description); + AltosPreferences.add_common_frequency(new_frequency); + radio_frequency_value.insertItemAt(new_frequency, i); } - public int radio_channel() { - return radio_channel_value.getSelectedIndex(); + public double radio_frequency() { + return radio_frequency_value.frequency(); } public void set_radio_calibration(int new_radio_calibration) { @@ -548,6 +563,9 @@ public class AltosConfigUI callsign_value.setText(new_callsign); } + public void set_radio_setting(int new_radio_setting) { + } + public String callsign() { return callsign_value.getText(); } diff --git a/altosui/AltosConvert.java b/altosui/AltosConvert.java index 8cc1df27..6a9b699c 100644 --- a/altosui/AltosConvert.java +++ b/altosui/AltosConvert.java @@ -189,4 +189,37 @@ public class AltosConvert { { return ignite / 32767 * 15.0; } + + static double + radio_setting_to_frequency(int setting, int cal) { + double f; + + f = 434.550 * setting / cal; + /* Round to nearest 50KHz */ + f = Math.floor (20.0 * f + 0.5) / 20.0; + return f; + } + + static int + radio_frequency_to_setting(double frequency, int cal) { + double set = frequency / 434.550 * cal; + + return (int) Math.floor (set + 0.5); + } + + static double + radio_channel_to_frequency(int channel) { + return 434.550 + channel * 0.100; + } + + static int + radio_frequency_to_channel(double frequency) { + int channel = (int) Math.floor ((frequency - 434.550) / 0.100 + 0.5); + + if (channel < 0) + channel = 0; + if (channel > 9) + channel = 9; + return channel; + } } diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index ecd82c18..94951ced 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -84,11 +84,11 @@ public class AltosEepromDelete implements Runnable { } public void run () { - if (remote) - serial_line.start_remote(); - success = false; try { + if (remote) + serial_line.start_remote(); + for (AltosEepromLog log : flights) { if (log.delete) { DeleteLog(log); @@ -103,11 +103,12 @@ public class AltosEepromDelete implements Runnable { show_error (String.format("Connection to \"%s\" failed", serial_line.device.toShortString()), "Connection Failed"); + } finally { + if (remote) + serial_line.stop_remote(); + serial_line.flush_output(); + serial_line.close(); } - if (remote) - serial_line.stop_remote(); - serial_line.flush_output(); - serial_line.close(); if (listener != null) { Runnable r = new Runnable() { public void run() { diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 82f01ef5..64dcdff7 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -264,11 +264,11 @@ public class AltosEepromDownload implements Runnable { } public void run () { - if (remote) - serial_line.start_remote(); - try { boolean failed = false; + if (remote) + serial_line.start_remote(); + for (AltosEepromLog log : flights) { parse_exception = null; if (log.download) { @@ -295,11 +295,12 @@ public class AltosEepromDownload implements Runnable { serial_line.device.toShortString()), "Connection Failed", JOptionPane.ERROR_MESSAGE); + } finally { + if (remote) + serial_line.stop_remote(); + serial_line.flush_output(); } - if (remote) - serial_line.stop_remote(); monitor.done(); - serial_line.flush_output(); if (listener != null) { Runnable r = new Runnable() { public void run() { diff --git a/altosui/AltosFlightReader.java b/altosui/AltosFlightReader.java index f665bda8..3a171444 100644 --- a/altosui/AltosFlightReader.java +++ b/altosui/AltosFlightReader.java @@ -20,6 +20,7 @@ package altosui; import java.lang.*; import java.text.*; import java.io.*; +import java.util.concurrent.*; public class AltosFlightReader { String name; @@ -32,9 +33,13 @@ public class AltosFlightReader { void close(boolean interrupted) { } - void set_channel(int channel) { } + void set_frequency(double frequency) throws InterruptedException, TimeoutException { } + + void save_frequency() { } void set_telemetry(int telemetry) { } + void save_telemetry() { } + void update(AltosState state) throws InterruptedException { } } diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 04bfc90d..8c3f821e 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -26,7 +26,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.prefs.*; -import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.*; public class AltosFlightUI extends JFrame implements AltosFlightDisplay { AltosVoice voice; @@ -118,7 +118,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { } Container bag; - JComboBox channels; + AltosFreqList frequencies; JComboBox telemetries; public AltosFlightUI(AltosVoice in_voice, AltosFlightReader in_reader, final int serial) { @@ -141,18 +141,25 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { /* Stick channel selector at top of table for telemetry monitoring */ if (serial >= 0) { // Channel menu - channels = new AltosChannelMenu(AltosPreferences.channel(serial)); - channels.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - int channel = channels.getSelectedIndex(); - reader.set_channel(channel); - } + frequencies = new AltosFreqList(AltosPreferences.frequency(serial)); + frequencies.set_product("Monitor"); + frequencies.set_serial(serial); + frequencies.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + double frequency = frequencies.frequency(); + reader.save_frequency(); + try { + reader.set_frequency(frequency); + } catch (TimeoutException te) { + } catch (InterruptedException ie) { + } + } }); c.gridx = 0; c.gridy = 0; c.insets = new Insets(3, 3, 3, 3); c.anchor = GridBagConstraints.WEST; - bag.add (channels, c); + bag.add (frequencies, c); // Telemetry format menu telemetries = new JComboBox(); @@ -168,6 +175,7 @@ public class AltosFlightUI extends JFrame implements AltosFlightDisplay { public void actionPerformed(ActionEvent e) { int telemetry = telemetries.getSelectedIndex() + 1; reader.set_telemetry(telemetry); + reader.save_telemetry(); } }); c.gridx = 1; diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java new file mode 100644 index 00000000..59b0e127 --- /dev/null +++ b/altosui/AltosFreqList.java @@ -0,0 +1,87 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; + +public class AltosFreqList extends JComboBox { + + String product; + int serial; + int calibrate; + + public void set_frequency(double new_frequency) { + int i; + for (i = 0; i < getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) getItemAt(i); + + if (f.close(new_frequency)) { + setSelectedIndex(i); + return; + } + } + for (i = 0; i < getItemCount(); i++) { + AltosFrequency f = (AltosFrequency) getItemAt(i); + + if (new_frequency < f.frequency) + break; + } + String description = String.format("%s serial %d", product, serial); + AltosFrequency frequency = new AltosFrequency(new_frequency, description); + AltosPreferences.add_common_frequency(frequency); + insertItemAt(frequency, i); + setMaximumRowCount(getItemCount()); + } + + public void set_product(String new_product) { + product = new_product; + } + + public void set_serial(int new_serial) { + serial = new_serial; + } + + public double frequency() { + AltosFrequency f = (AltosFrequency) getSelectedItem(); + if (f != null) + return f.frequency; + return 434.550; + } + + public AltosFreqList () { + super(AltosPreferences.common_frequencies()); + setMaximumRowCount(getItemCount()); + setEditable(false); + product = "Unknown"; + serial = 0; + } + + public AltosFreqList(double in_frequency) { + this(); + set_frequency(in_frequency); + } +} diff --git a/altosui/AltosFrequency.java b/altosui/AltosFrequency.java index 8265eafc..0617ce74 100644 --- a/altosui/AltosFrequency.java +++ b/altosui/AltosFrequency.java @@ -44,6 +44,12 @@ public class AltosFrequency { frequency, description); } + public boolean close(double f) { + double diff = Math.abs(frequency - f); + + return diff < 0.010; + } + public AltosFrequency(double f, String d) { frequency = f; description = d; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index a4262cae..0370efa9 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -167,7 +167,7 @@ class AltosIdleMonitor extends Thread { AltosIdleMonitorUI ui; AltosState state; boolean remote; - int channel; + double frequency; AltosState previous_state; AltosConfigData config_data; AltosADC adc; @@ -178,7 +178,7 @@ class AltosIdleMonitor extends Thread { try { if (remote) { - set_channel(channel); + serial.set_radio_frequency(frequency); serial.start_remote(); } else serial.flush_input(); @@ -217,8 +217,8 @@ class AltosIdleMonitor extends Thread { state = new AltosState (record, state); } - void set_channel(int in_channel) { - channel = in_channel; + void set_frequency(double in_frequency) { + frequency = in_frequency; } public void post_state() { @@ -246,7 +246,7 @@ class AltosIdleMonitor extends Thread { } public AltosIdleMonitor(AltosIdleMonitorUI in_ui, AltosDevice in_device, boolean in_remote) - throws FileNotFoundException, AltosSerialInUseException { + throws FileNotFoundException, AltosSerialInUseException, InterruptedException, TimeoutException { device = in_device; ui = in_ui; serial = new AltosSerial(device); @@ -299,9 +299,10 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay { } Container bag; - JComboBox channels; + AltosFreqList frequencies; - public AltosIdleMonitorUI(JFrame in_owner) throws FileNotFoundException, AltosSerialInUseException { + public AltosIdleMonitorUI(JFrame in_owner) + throws FileNotFoundException, AltosSerialInUseException, TimeoutException, InterruptedException { device = AltosDeviceDialog.show(in_owner, Altos.product_any); remote = false; @@ -320,21 +321,23 @@ public class AltosIdleMonitorUI extends JFrame implements AltosFlightDisplay { setTitle(String.format("AltOS %s", device.toShortString())); - /* Stick channel selector at top of table for telemetry monitoring */ + /* Stick frequency selector at top of table for telemetry monitoring */ if (remote && serial >= 0) { - // Channel menu - channels = new AltosChannelMenu(AltosPreferences.channel(serial)); - channels.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent e) { - int channel = channels.getSelectedIndex(); - thread.set_channel(channel); - } + // Frequency menu + frequencies = new AltosFreqList(AltosPreferences.frequency(serial)); + frequencies.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent e) { + double frequency = frequencies.frequency(); + thread.set_frequency(frequency); + AltosPreferences.set_frequency(device.getSerial(), + frequency); + } }); c.gridx = 0; c.gridy = 0; c.insets = new Insets(3, 3, 3, 3); c.anchor = GridBagConstraints.WEST; - bag.add (channels, c); + bag.add (frequencies, c); } diff --git a/altosui/AltosIgnite.java b/altosui/AltosIgnite.java index 7a06c63d..3e52ea36 100644 --- a/altosui/AltosIgnite.java +++ b/altosui/AltosIgnite.java @@ -40,7 +40,7 @@ public class AltosIgnite { final static int Active = 2; final static int Open = 3; - private void start_serial() throws InterruptedException { + private void start_serial() throws InterruptedException, TimeoutException { serial_started = true; if (remote) serial.start_remote(); @@ -102,22 +102,25 @@ public class AltosIgnite { if (serial == null) return status; string_ref status_name = new string_ref(); - start_serial(); - serial.printf("t\n"); - for (;;) { - String line = serial.get_reply(5000); - if (line == null) - throw new TimeoutException(); - if (get_string(line, "Igniter: drogue Status: ", status_name)) - if (igniter == Apogee) - status = status(status_name.get()); - if (get_string(line, "Igniter: main Status: ", status_name)) { - if (igniter == Main) - status = status(status_name.get()); - break; + try { + start_serial(); + serial.printf("t\n"); + for (;;) { + String line = serial.get_reply(5000); + if (line == null) + throw new TimeoutException(); + if (get_string(line, "Igniter: drogue Status: ", status_name)) + if (igniter == Apogee) + status = status(status_name.get()); + if (get_string(line, "Igniter: main Status: ", status_name)) { + if (igniter == Main) + status = status(status_name.get()); + break; + } } + } finally { + stop_serial(); } - stop_serial(); return status; } @@ -145,6 +148,7 @@ public class AltosIgnite { break; } } catch (InterruptedException ie) { + } catch (TimeoutException te) { } finally { try { stop_serial(); @@ -166,7 +170,8 @@ public class AltosIgnite { serial.set_frame(frame); } - public AltosIgnite(AltosDevice in_device) throws FileNotFoundException, AltosSerialInUseException { + public AltosIgnite(AltosDevice in_device) + throws FileNotFoundException, AltosSerialInUseException, TimeoutException, InterruptedException { device = in_device; serial = new AltosSerial(device); diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java index e92b9532..8609f94e 100644 --- a/altosui/AltosPreferences.java +++ b/altosui/AltosPreferences.java @@ -34,6 +34,9 @@ class AltosPreferences { /* channel preference name */ final static String channelPreferenceFormat = "CHANNEL-%d"; + /* frequency preference name */ + final static String frequencyPreferenceFormat = "FREQUENCY-%d"; + /* telemetry format preference name */ final static String telemetryPreferenceFormat = "TELEMETRY-%d"; @@ -61,9 +64,6 @@ class AltosPreferences { /* Map directory -- hangs of logdir */ static File mapdir; - /* Channel (map serial to channel) */ - static Hashtable channels; - /* Frequency (map serial to frequency) */ static Hashtable frequencies; @@ -148,7 +148,7 @@ class AltosPreferences { if (!mapdir.exists()) mapdir.mkdirs(); - channels = new Hashtable(); + frequencies = new Hashtable(); telemetries = new Hashtable(); @@ -242,20 +242,24 @@ class AltosPreferences { return mapdir; } - public static void set_channel(int serial, int new_channel) { - channels.put(serial, new_channel); + public static void set_frequency(int serial, double new_frequency) { + frequencies.put(serial, new_frequency); synchronized (preferences) { - preferences.putInt(String.format(channelPreferenceFormat, serial), new_channel); + preferences.putDouble(String.format(frequencyPreferenceFormat, serial), new_frequency); flush_preferences(); } } - public static int channel(int serial) { - if (channels.containsKey(serial)) - return channels.get(serial); - int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0); - channels.put(serial, channel); - return channel; + public static double frequency(int serial) { + if (frequencies.containsKey(serial)) + return frequencies.get(serial); + double frequency = preferences.getDouble(String.format(frequencyPreferenceFormat, serial), 0); + if (frequency == 0.0) { + int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0); + frequency = AltosConvert.radio_channel_to_frequency(channel); + } + frequencies.put(serial, frequency); + return frequency; } public static void set_telemetry(int serial, int new_telemetry) { @@ -339,4 +343,21 @@ class AltosPreferences { flush_preferences(); } } + + public static void add_common_frequency(AltosFrequency frequency) { + AltosFrequency[] new_frequencies = new AltosFrequency[common_frequencies.length + 1]; + int i; + + for (i = 0; i < common_frequencies.length; i++) { + if (frequency.frequency == common_frequencies[i].frequency) + return; + if (frequency.frequency < common_frequencies[i].frequency) + break; + new_frequencies[i] = common_frequencies[i]; + } + new_frequencies[i] = frequency; + for (; i < common_frequencies.length; i++) + new_frequencies[i+1] = common_frequencies[i]; + set_common_frequencies(new_frequencies); + } } diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 96cab73b..9a483138 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -33,27 +33,27 @@ class AltosScanResult { String callsign; int serial; int flight; - int channel; + double frequency; int telemetry; boolean interrupted = false; public String toString() { - return String.format("%-9.9s serial %-4d flight %-4d (channel %-2d %s)", - callsign, serial, flight, channel, Altos.telemetry_name(telemetry)); + return String.format("%-9.9s serial %-4d flight %-4d (frequency %7.3f %s)", + callsign, serial, flight, frequency, Altos.telemetry_name(telemetry)); } public String toShortString() { - return String.format("%s %d %d %d %d", - callsign, serial, flight, channel, telemetry); + return String.format("%s %d %d %7.3f %d", + callsign, serial, flight, frequency, telemetry); } public AltosScanResult(String in_callsign, int in_serial, - int in_flight, int in_channel, int in_telemetry) { + int in_flight, double in_frequency, int in_telemetry) { callsign = in_callsign; serial = in_serial; flight = in_flight; - channel = in_channel; + frequency = in_frequency; telemetry = in_telemetry; } @@ -61,7 +61,7 @@ class AltosScanResult { return (callsign.equals(other.callsign) && serial == other.serial && flight == other.flight && - channel == other.channel && + frequency == other.frequency && telemetry == other.telemetry); } } @@ -107,20 +107,25 @@ public class AltosScanUI { AltosUI owner; AltosDevice device; + AltosConfigData config_data; AltosTelemetryReader reader; private JList list; private JLabel scanning_label; + private JLabel frequency_label; + private JLabel telemetry_label; private JButton cancel_button; private JButton monitor_button; javax.swing.Timer timer; AltosScanResults results = new AltosScanResults(); int telemetry; - int channel; + double frequency; final static int timeout = 1200; TelemetryHandler handler; Thread thread; + AltosFrequency[] frequencies; + int frequency_index; void scan_exception(Exception e) { if (e instanceof FileNotFoundException) { @@ -167,7 +172,7 @@ public class AltosScanUI final AltosScanResult result = new AltosScanResult(record.callsign, record.serial, record.flight, - channel, + frequency, telemetry); Runnable r = new Runnable() { public void run() { @@ -190,26 +195,30 @@ public class AltosScanUI } void set_label() { - scanning_label.setText(String.format("Scanning: channel %d %s", - channel, - Altos.telemetry_name(telemetry))); + frequency_label.setText(String.format("Frequency: %s", frequencies[frequency_index].toString())); + telemetry_label.setText(String.format("Telemetry: %s", Altos.telemetry_name(telemetry))); } - void next() { + void set_telemetry() { + reader.set_telemetry(telemetry); + } + + void set_frequency() throws InterruptedException, TimeoutException { + reader.set_frequency(frequencies[frequency_index].frequency); + } + + void next() throws InterruptedException, TimeoutException { reader.serial.set_monitor(false); - try { - Thread.sleep(100); - } catch (InterruptedException ie){ - } - ++channel; - if (channel > 9) { - channel = 0; + Thread.sleep(100); + ++frequency_index; + if (frequency_index >= frequencies.length) { + frequency_index = 0; ++telemetry; if (telemetry > Altos.ao_telemetry_max) telemetry = Altos.ao_telemetry_min; - reader.serial.set_telemetry(telemetry); + set_telemetry(); } - reader.serial.set_channel(channel); + set_frequency(); set_label(); reader.serial.set_monitor(true); } @@ -229,31 +238,37 @@ public class AltosScanUI dispose(); } - void tick_timer() { + void tick_timer() throws InterruptedException, TimeoutException { next(); } public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); - if (cmd.equals("cancel")) - close(); - - if (cmd.equals("tick")) - tick_timer(); - - if (cmd.equals("monitor")) { - close(); - AltosScanResult r = (AltosScanResult) (list.getSelectedValue()); - if (r != null) { - if (device != null) { - if (reader != null) { - reader.set_telemetry(r.telemetry); - reader.set_channel(r.channel); - owner.telemetry_window(device); + try { + if (cmd.equals("cancel")) + close(); + + if (cmd.equals("tick")) + tick_timer(); + + if (cmd.equals("monitor")) { + close(); + AltosScanResult r = (AltosScanResult) (list.getSelectedValue()); + if (r != null) { + if (device != null) { + if (reader != null) { + reader.set_telemetry(r.telemetry); + reader.set_frequency(r.frequency); + owner.telemetry_window(device); + } } } } + } catch (TimeoutException te) { + close(); + } catch (InterruptedException ie) { + close(); } } @@ -278,8 +293,8 @@ public class AltosScanUI return false; try { reader = new AltosTelemetryReader(device); - reader.serial.set_channel(channel); - reader.serial.set_telemetry(telemetry); + set_frequency(); + set_telemetry(); try { Thread.sleep(100); } catch (InterruptedException ie) { @@ -306,6 +321,16 @@ public class AltosScanUI device.toShortString(), "Unkonwn I/O error", JOptionPane.ERROR_MESSAGE); + } catch (TimeoutException te) { + JOptionPane.showMessageDialog(owner, + device.toShortString(), + "Timeout error", + JOptionPane.ERROR_MESSAGE); + } catch (InterruptedException ie) { + JOptionPane.showMessageDialog(owner, + device.toShortString(), + "Interrupted exception", + JOptionPane.ERROR_MESSAGE); } if (reader != null) reader.close(false); @@ -316,7 +341,8 @@ public class AltosScanUI owner = in_owner; - channel = 0; + frequencies = AltosPreferences.common_frequencies(); + frequency_index = 0; telemetry = Altos.ao_telemetry_min; if (!open()) @@ -335,11 +361,13 @@ public class AltosScanUI pane.setLayout(new GridBagLayout()); scanning_label = new JLabel("Scanning:"); + frequency_label = new JLabel(""); + telemetry_label = new JLabel(""); set_label(); c.fill = GridBagConstraints.NONE; - c.anchor = GridBagConstraints.CENTER; + c.anchor = GridBagConstraints.WEST; c.insets = i; c.weightx = 1; c.weighty = 1; @@ -347,9 +375,12 @@ public class AltosScanUI c.gridx = 0; c.gridy = 0; c.gridwidth = 2; - c.anchor = GridBagConstraints.CENTER; pane.add(scanning_label, c); + c.gridy = 1; + pane.add(frequency_label, c); + c.gridy = 2; + pane.add(telemetry_label, c); list = new JList(results) { //Subclass JList to workaround bug 4832765, which can cause the @@ -417,7 +448,7 @@ public class AltosScanUI c.weighty = 1; c.gridx = 0; - c.gridy = 1; + c.gridy = 3; c.gridwidth = 2; c.anchor = GridBagConstraints.CENTER; @@ -434,7 +465,7 @@ public class AltosScanUI c.weighty = 1; c.gridx = 0; - c.gridy = 2; + c.gridy = 4; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; @@ -451,7 +482,7 @@ public class AltosScanUI c.weighty = 1; c.gridx = 1; - c.gridy = 2; + c.gridy = 4; c.gridwidth = 1; c.anchor = GridBagConstraints.CENTER; diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index f45aa18b..6c687f5f 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -54,11 +54,12 @@ public class AltosSerial implements Runnable { int line_count; boolean monitor_mode; int telemetry; - int channel; + double frequency; static boolean debug; boolean remote; LinkedList pending_output = new LinkedList(); Frame frame; + AltosConfigData config_data; static void set_debug(boolean new_debug) { debug = new_debug; @@ -154,7 +155,7 @@ public class AltosSerial implements Runnable { Object[] options = { "Cancel" }; JOptionPane pane = new JOptionPane(); - pane.setMessage(String.format("Connecting to %s", device.getPath())); + pane.setMessage(String.format("Connecting to %s, %7.3f MHz", device.toShortString(), frequency)); pane.setOptions(options); pane.setInitialValue(null); @@ -208,20 +209,13 @@ public class AltosSerial implements Runnable { } while (got_some); } - public String get_reply() throws InterruptedException { - if (SwingUtilities.isEventDispatchThread()) - System.out.printf("Uh-oh, reading serial device from swing thread\n"); - flush_output(); - AltosLine line = reply_queue.take(); - return line.line; - } - int in_reply; public String get_reply(int timeout) throws InterruptedException { boolean can_cancel = true; ++in_reply; + System.out.printf("get_reply %d\n", timeout); if (SwingUtilities.isEventDispatchThread()) { can_cancel = false; System.out.printf("Uh-oh, reading serial device from swing thread\n"); @@ -239,7 +233,6 @@ public class AltosSerial implements Runnable { --in_reply; return line.line; } - System.out.printf("no line remote %b can_cancel %b\n", remote, can_cancel); if (!remote || !can_cancel || check_timeout()) { --in_reply; return null; @@ -247,8 +240,13 @@ public class AltosSerial implements Runnable { } } + public String get_reply() throws InterruptedException { + return get_reply(5000); + } + public String get_reply_no_dialog(int timeout) throws InterruptedException, TimeoutException { flush_output(); + System.out.printf("get_reply_no_dialog\n"); AltosLine line = reply_queue.poll(timeout, TimeUnit.MILLISECONDS); if (line != null) return line.line; @@ -267,6 +265,8 @@ public class AltosSerial implements Runnable { } public void close() { + if (remote) + stop_remote(); if (in_reply != 0) System.out.printf("Uh-oh. Closing active serial device\n"); @@ -328,19 +328,11 @@ public class AltosSerial implements Runnable { flush_output(); } - public void set_radio() { - telemetry = AltosPreferences.telemetry(device.getSerial()); - channel = AltosPreferences.channel(device.getSerial()); - set_channel(channel); - set_callsign(AltosPreferences.callsign()); - } - private int telemetry_len() { return Altos.telemetry_len(telemetry); } - public void set_channel(int in_channel) { - channel = in_channel; + private void set_channel(int channel) { if (altos != null) { if (monitor_mode) printf("m 0\nc r %d\nm %x\n", @@ -351,6 +343,33 @@ public class AltosSerial implements Runnable { } } + private void set_radio_setting(int setting) { + if (altos != null) { + if (monitor_mode) + printf("m 0\nc R %d\nc r 0\nm %x\n", + setting, telemetry_len()); + else + printf("c R %d\nc r 0\n", setting); + } + } + + public void set_radio_frequency(double frequency, + boolean has_setting, + int cal) { + if (has_setting) + set_radio_setting(AltosConvert.radio_frequency_to_setting(frequency, cal)); + else + set_channel(AltosConvert.radio_frequency_to_channel(frequency)); + } + + public void set_radio_frequency(double in_frequency) throws InterruptedException, TimeoutException { + frequency = in_frequency; + config_data(); + set_radio_frequency(frequency, + config_data.radio_setting != 0, + config_data.radio_calibration); + } + public void set_telemetry(int in_telemetry) { telemetry = in_telemetry; if (altos != null) { @@ -378,10 +397,19 @@ public class AltosSerial implements Runnable { } } - public void start_remote() { + public AltosConfigData config_data() throws InterruptedException, TimeoutException { + if (config_data == null) + config_data = new AltosConfigData(this); + return config_data; + } + + public void start_remote() throws TimeoutException, InterruptedException { if (debug) System.out.printf("start remote\n"); - set_radio(); + if (frequency == 0.0) + frequency = AltosPreferences.frequency(device.getSerial()); + set_radio_frequency(frequency); + set_callsign(AltosPreferences.callsign()); printf("p\nE 0\n"); flush_input(); remote = true; diff --git a/altosui/AltosTelemetryReader.java b/altosui/AltosTelemetryReader.java index 23524b2c..4512e761 100644 --- a/altosui/AltosTelemetryReader.java +++ b/altosui/AltosTelemetryReader.java @@ -27,6 +27,9 @@ class AltosTelemetryReader extends AltosFlightReader { AltosSerial serial; AltosLog log; AltosRecord previous; + AltosConfigData config_data; + double frequency; + int telemetry; LinkedBlockingQueue telem; @@ -49,18 +52,26 @@ class AltosTelemetryReader extends AltosFlightReader { serial.close(); } - void set_channel(int channel) { - serial.set_channel(channel); - AltosPreferences.set_channel(device.getSerial(), channel); + public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException { + frequency = in_frequency; + serial.set_radio_frequency(frequency); } - void set_telemetry(int telemetry) { + void save_frequency() { + AltosPreferences.set_frequency(device.getSerial(), frequency); + } + + void set_telemetry(int in_telemetry) { + telemetry = in_telemetry; serial.set_telemetry(telemetry); + } + + void save_telemetry() { AltosPreferences.set_telemetry(device.getSerial(), telemetry); } public AltosTelemetryReader (AltosDevice in_device) - throws FileNotFoundException, AltosSerialInUseException, IOException { + throws FileNotFoundException, AltosSerialInUseException, IOException, InterruptedException, TimeoutException { device = in_device; serial = new AltosSerial(device); log = new AltosLog(serial); @@ -68,7 +79,11 @@ class AltosTelemetryReader extends AltosFlightReader { previous = null; telem = new LinkedBlockingQueue(); - serial.set_radio(); + frequency = AltosPreferences.frequency(device.getSerial()); + set_frequency(frequency); + telemetry = AltosPreferences.telemetry(device.getSerial()); + set_telemetry(telemetry); + serial.set_callsign(AltosPreferences.callsign()); serial.add_monitor(telem); } } diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 033f233c..885e60cd 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -26,7 +26,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.prefs.*; -import java.util.concurrent.LinkedBlockingQueue; +import java.util.concurrent.*; import libaltosJNI.*; @@ -67,6 +67,16 @@ public class AltosUI extends JFrame { device.toShortString(), "Unkonwn I/O error", JOptionPane.ERROR_MESSAGE); + } catch (TimeoutException te) { + JOptionPane.showMessageDialog(this, + device.toShortString(), + "Timeout error", + JOptionPane.ERROR_MESSAGE); + } catch (InterruptedException ie) { + JOptionPane.showMessageDialog(this, + device.toShortString(), + "Interrupted exception", + JOptionPane.ERROR_MESSAGE); } } diff --git a/altosui/Makefile.am b/altosui/Makefile.am index d6fd0e6d..4bac6df1 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -52,6 +52,7 @@ altosui_JAVA = \ AltosFlightStatus.java \ AltosFlightUI.java \ AltosFrequency.java \ + AltosFreqList.java \ AltosGPS.java \ AltosGPSSat.java \ AltosGreatCircle.java \ -- cgit v1.2.3 From bf06af154e232d4caa1585a1d6d5279a075292e4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 12 Aug 2011 21:43:56 -0700 Subject: altos/altosui: Report log format in the version command This will make it easier to figure out what the contents of the flash should look like from altosui; the current 'guessing' mechanism will not scale to many more formats. Signed-off-by: Keith Packard --- altosui/Altos.java | 32 ++++++++++++++++++++++++++++++++ altosui/AltosConfig.java | 3 +++ altosui/AltosConfigData.java | 2 ++ altosui/AltosEepromDownload.java | 26 +++++++++++++------------- altosui/AltosEepromRecord.java | 3 +++ src/ao.h | 9 +++++++++ src/ao_cmd.c | 3 +++ src/ao_log.c | 2 ++ src/ao_log_tiny.c | 2 ++ src/ao_telebt.c | 2 ++ 10 files changed, 71 insertions(+), 13 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/Altos.java b/altosui/Altos.java index 73dc7468..416d9328 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -51,6 +51,7 @@ public class Altos { static final int AO_LOG_MANUFACTURER = 2000; static final int AO_LOG_PRODUCT = 2001; static final int AO_LOG_SERIAL_NUMBER = 2002; + static final int AO_LOG_LOG_FORMAT = 2003; static final int AO_LOG_SOFTWARE_VERSION = 9999; /* Added to flag invalid records */ @@ -177,6 +178,13 @@ public class Altos { static final int AO_GPS_NUM_SAT_SHIFT = 0; static final int AO_GPS_NUM_SAT_MASK = 0xf; + static final int AO_LOG_FORMAT_UNKNOWN = 0; + static final int AO_LOG_FORMAT_FULL = 1; + static final int AO_LOG_FORMAT_TINY = 2; + static final int AO_LOG_FORMAT_TELEMETRY = 3; + static final int AO_LOG_FORMAT_TELESCIENCE = 4; + static final int AO_LOG_FORMAT_NONE = 127; + static boolean isspace(int c) { switch (c) { case ' ': @@ -404,12 +412,36 @@ public class Altos { return 0x000e; } + static int usb_product_telelaunch() { + load_library(); + return 0x000f; + } + + static int usb_product_telelco() { + load_library(); + return 0x0010; + } + + static int usb_product_telescience() { + load_library(); + return 0x0011; + } + + static int usb_product_telepyro() { + load_library(); + return 0x0012; + } + public final static int vendor_altusmetrum = usb_vendor_altusmetrum(); public final static int product_altusmetrum = usb_product_altusmetrum(); public final static int product_telemetrum = usb_product_telemetrum(); public final static int product_teledongle = usb_product_teledongle(); public final static int product_teleterra = usb_product_teleterra(); public final static int product_telebt = usb_product_telebt(); + public final static int product_telelaunch = usb_product_telelaunch(); + public final static int product_tele10 = usb_product_telelco(); + public final static int product_telescience = usb_product_telescience(); + public final static int product_telepyro = usb_product_telepyro(); public final static int product_altusmetrum_min = usb_product_altusmetrum_min(); public final static int product_altusmetrum_max = usb_product_altusmetrum_max(); diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 7312ea6c..ffabe209 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -67,6 +67,7 @@ public class AltosConfig implements ActionListener { AltosConfigData remote_config_data; double remote_frequency; int_ref serial; + int_ref log_format; int_ref main_deploy; int_ref apogee_delay; int_ref radio_channel; @@ -153,6 +154,7 @@ public class AltosConfig implements ActionListener { return; } get_int(line, "serial-number", serial); + get_int(line, "log-format", log_format); get_int(line, "Main deploy:", main_deploy); get_int(line, "Apogee delay:", apogee_delay); get_int(line, "Radio channel:", radio_channel); @@ -374,6 +376,7 @@ public class AltosConfig implements ActionListener { owner = given_owner; serial = new int_ref(0); + log_format = new int_ref(Altos.AO_LOG_FORMAT_UNKNOWN); main_deploy = new int_ref(250); apogee_delay = new int_ref(0); radio_channel = new int_ref(0); diff --git a/altosui/AltosConfigData.java b/altosui/AltosConfigData.java index 016033a3..710231d7 100644 --- a/altosui/AltosConfigData.java +++ b/altosui/AltosConfigData.java @@ -36,6 +36,7 @@ public class AltosConfigData implements Iterable { String manufacturer; String product; String version; + int log_format; int serial; /* Strings returned */ @@ -94,6 +95,7 @@ public class AltosConfigData implements Iterable { continue; lines.add(line); try { serial = get_int(line, "serial-number"); } catch (Exception e) {} + try { log_format = get_int(line, "log-format"); } catch (Exception e) {} try { main_deploy = get_int(line, "Main deploy:"); } catch (Exception e) {} try { apogee_delay = get_int(line, "Apogee delay:"); } catch (Exception e) {} try { radio_channel = get_int(line, "Radio channel:"); } catch (Exception e) {} diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 64dcdff7..417aab00 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -89,9 +89,6 @@ public class AltosEepromDownload implements Runnable { } } - static final int log_full = 1; - static final int log_tiny = 2; - boolean done; int state; @@ -186,7 +183,7 @@ public class AltosEepromDownload implements Runnable { void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException { int block, state_block = 0; - int log_style = 0; + int log_format = flights.config_data.log_format; state = 0; done = false; @@ -215,21 +212,24 @@ public class AltosEepromDownload implements Runnable { AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block); /* - * Figure out what kind of data is there + * Guess what kind of data is there if the device + * didn't tell us */ - if (block == log.start_block) { - if (eechunk.data(0) == Altos.AO_LOG_FLIGHT) - log_style = log_full; - else - log_style = log_tiny; + if (log_format == Altos.AO_LOG_FORMAT_UNKNOWN) { + if (block == log.start_block) { + if (eechunk.data(0) == Altos.AO_LOG_FLIGHT) + log_format = Altos.AO_LOG_FORMAT_FULL; + else + log_format = Altos.AO_LOG_FORMAT_TINY; + } } - switch (log_style) { - case log_full: + switch (log_format) { + case Altos.AO_LOG_FORMAT_FULL: CaptureFull(eechunk); break; - case log_tiny: + case Altos.AO_LOG_FORMAT_TINY: CaptureTiny(eechunk); break; } diff --git a/altosui/AltosEepromRecord.java b/altosui/AltosEepromRecord.java index 52acb435..c0f97035 100644 --- a/altosui/AltosEepromRecord.java +++ b/altosui/AltosEepromRecord.java @@ -143,6 +143,9 @@ public class AltosEepromRecord { } else if (tokens[0].equals("serial-number")) { cmd = Altos.AO_LOG_SERIAL_NUMBER; a = Integer.parseInt(tokens[1]); + } else if (tokens[0].equals("log-format")) { + cmd = Altos.AO_LOG_LOG_FORMAT; + a = Integer.parseInt(tokens[1]); } else if (tokens[0].equals("software-version")) { cmd = Altos.AO_LOG_SOFTWARE_VERSION; data = tokens[1]; diff --git a/src/ao.h b/src/ao.h index 0699fc2c..1c8f5bbf 100644 --- a/src/ao.h +++ b/src/ao.h @@ -539,6 +539,15 @@ extern __pdata enum flight_state ao_log_state; /* required functions from the underlying log system */ +#define AO_LOG_FORMAT_UNKNOWN 0 /* unknown; altosui will have to guess */ +#define AO_LOG_FORMAT_FULL 1 /* 8 byte typed log records */ +#define AO_LOG_FORMAT_TINY 2 /* two byte state/baro records */ +#define AO_LOG_FORMAT_TELEMETRY 3 /* 32 byte ao_telemetry records */ +#define AO_LOG_FORMAT_TELESCIENCE 4 /* 32 byte typed telescience records */ +#define AO_LOG_FORMAT_NONE 127 /* No log at all */ + +extern __code uint8_t ao_log_format; + /* Return the flight number from the given log slot, 0 if none */ uint16_t ao_log_flight(uint8_t slot); diff --git a/src/ao_cmd.c b/src/ao_cmd.c index 6d3ae38d..1442ebea 100644 --- a/src/ao_cmd.c +++ b/src/ao_cmd.c @@ -219,6 +219,9 @@ version(void) printf("manufacturer %s\n", ao_manufacturer); printf("product %s\n", ao_product); printf("serial-number %u\n", ao_serial_number); +#if HAS_EEPROM + printf("log-format %u\n", ao_log_format); +#endif printf("software-version %s\n", ao_version); } diff --git a/src/ao_log.c b/src/ao_log.c index 80d7243d..6d3ad535 100644 --- a/src/ao_log.c +++ b/src/ao_log.c @@ -24,6 +24,8 @@ __xdata uint8_t ao_log_running; __pdata enum flight_state ao_log_state; __xdata uint16_t ao_flight_number; +__code uint8_t ao_log_format = AO_LOG_FORMAT_FULL; + void ao_log_flush(void) { diff --git a/src/ao_log_tiny.c b/src/ao_log_tiny.c index d26e0080..d5a3b99f 100644 --- a/src/ao_log_tiny.c +++ b/src/ao_log_tiny.c @@ -28,6 +28,8 @@ static __data uint16_t ao_log_tiny_interval; #define AO_PAD_RING 2 #endif +__code uint8_t ao_log_format = AO_LOG_FORMAT_TINY; + void ao_log_tiny_set_interval(uint16_t ticks) { diff --git a/src/ao_telebt.c b/src/ao_telebt.c index 8e77c4d9..85565172 100644 --- a/src/ao_telebt.c +++ b/src/ao_telebt.c @@ -17,6 +17,8 @@ #include "ao.h" +__code uint8_t ao_log_format = AO_LOG_FORMAT_NONE; /* until we actually log stuff */ + void main(void) { -- cgit v1.2.3 From 03e201e1acc8742399054e4ad36b533120ea1612 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Aug 2011 18:39:35 -0700 Subject: altosui: Add support for TeleScience eeprom download Using the existing eeprom methods, fetch and save TeleScience eeprom data, storing to a filename generated from the serial/flight from the TM connected to the TS board. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 95 +++++++++++++++++++++++++++++++++---- altosui/AltosEepromList.java | 4 +- altosui/AltosEepromLog.java | 65 +++++++++++++------------ altosui/AltosEepromTeleScience.java | 64 +++++++++++++++++++++++++ altosui/Makefile.am | 1 + 5 files changed, 188 insertions(+), 41 deletions(-) create mode 100644 altosui/AltosEepromTeleScience.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 417aab00..6112a3b1 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -39,6 +39,7 @@ public class AltosEepromDownload implements Runnable { AltosEepromMonitor monitor; int flight; + int serial; int year, month, day; boolean want_file; FileWriter eeprom_file; @@ -48,6 +49,7 @@ public class AltosEepromDownload implements Runnable { ActionListener listener; boolean success; ParseException parse_exception; + String extension; private void FlushPending() throws IOException { for (String s : flights.config_data) { @@ -64,10 +66,13 @@ public class AltosEepromDownload implements Runnable { return; if (force || (flight != 0 && want_file)) { AltosFile eeprom_name; + + if (extension == null) + extension = "data"; if (year != 0 && month != 0 && day != 0) - eeprom_name = new AltosFile(year, month, day, flights.config_data.serial, flight, "eeprom"); + eeprom_name = new AltosFile(year, month, day, serial, flight, extension); else - eeprom_name = new AltosFile(flights.config_data.serial, flight, "eeprom"); + eeprom_name = new AltosFile(serial, flight, extension); eeprom_file = new FileWriter(eeprom_name); if (eeprom_file != null) { @@ -89,18 +94,29 @@ public class AltosEepromDownload implements Runnable { } } + void set_serial(int in_serial) { + serial = in_serial; + monitor.set_serial(serial); + } + + void set_flight(int in_flight) { + flight = in_flight; + monitor.set_flight(flight); + } + boolean done; int state; void CaptureFull(AltosEepromChunk eechunk) throws IOException { boolean any_valid = false; + + extension = "eeprom"; + set_serial(flights.config_data.serial); for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromRecord.record_length) { try { AltosEepromRecord r = new AltosEepromRecord(eechunk, i); - if (r.cmd == Altos.AO_LOG_FLIGHT) { - flight = r.b; - monitor.set_flight(flight); - } + if (r.cmd == Altos.AO_LOG_FLIGHT) + set_flight(r.b); /* Monitor state transitions to update display */ if (r.cmd == Altos.AO_LOG_STATE && r.a <= Altos.ao_flight_landed) { @@ -137,6 +153,8 @@ public class AltosEepromDownload implements Runnable { void CaptureTiny (AltosEepromChunk eechunk) throws IOException { boolean any_valid = false; + extension = "eeprom"; + set_serial(flights.config_data.serial); for (int i = 0; i < eechunk.data.length && !done; i += 2) { int v = eechunk.data16(i); AltosEepromRecord r; @@ -144,8 +162,7 @@ public class AltosEepromDownload implements Runnable { if (i == 0 && start) { tiny_tick = 0; start = false; - flight = v; - monitor.set_flight(flight); + set_flight(v); r = new AltosEepromRecord(Altos.AO_LOG_FLIGHT, tiny_tick, 0, v); any_valid = true; } else { @@ -181,6 +198,56 @@ public class AltosEepromDownload implements Runnable { done = true; } + void LogTeleScience(AltosEepromTeleScience r) throws IOException { + if (r.type != Altos.AO_LOG_INVALID) { + String log_line = String.format("%c %4x %4x %d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d %5d\n", + r.type, r.tick, r.tm_tick, r.tm_state, + r.data[0], r.data[1], r.data[2], r.data[3], + r.data[4], r.data[5], r.data[6], r.data[7], + r.data[8], r.data[9], r.data[10], r.data[11]); + if (eeprom_file != null) + eeprom_file.write(log_line); + else + eeprom_pending.add(log_line); + } + } + + boolean telescience_start; + + void CaptureTeleScience (AltosEepromChunk eechunk) throws IOException { + boolean any_valid = false; + + extension = "science"; + for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromTeleScience.record_length) { + try { + AltosEepromTeleScience r = new AltosEepromTeleScience(eechunk, i); + if (r.type == AltosEepromTeleScience.AO_LOG_TELESCIENCE_START) { + if (telescience_start) { + done = true; + break; + } + set_serial(r.data[0]); + set_flight(r.data[1]); + telescience_start = true; + } else { + if (!telescience_start) + break; + } + state = r.tm_state; + want_file =true; + any_valid = true; + LogTeleScience(r); + } catch (ParseException pe) { + if (parse_exception == null) + parse_exception = pe; + } + } + + CheckFile(false); + if (!any_valid) + done = true; + } + void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException { int block, state_block = 0; int log_format = flights.config_data.log_format; @@ -202,7 +269,6 @@ public class AltosEepromDownload implements Runnable { eeprom_pending = new LinkedList(); /* Set serial number in the monitor dialog window */ - monitor.set_serial(flights.config_data.serial); /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */ state = 0; state_block = log.start_block; @@ -227,11 +293,21 @@ public class AltosEepromDownload implements Runnable { switch (log_format) { case Altos.AO_LOG_FORMAT_FULL: + extension = "eeprom"; CaptureFull(eechunk); break; case Altos.AO_LOG_FORMAT_TINY: + extension = "eeprom"; CaptureTiny(eechunk); break; +// case Altos.AO_LOG_FORMAT_TELEMETRY: +// extension = "telem"; +// CaptureTelemetry(eechunk); +// break; + case Altos.AO_LOG_FORMAT_TELESCIENCE: + extension = "science"; + CaptureTeleScience(eechunk); + break; } } CheckFile(true); @@ -290,6 +366,7 @@ public class AltosEepromDownload implements Runnable { serial_line.device.toShortString(), JOptionPane.ERROR_MESSAGE); } catch (InterruptedException ie) { + System.out.printf("download interrupted\n"); } catch (TimeoutException te) { show_message(String.format("Connection to \"%s\" failed", serial_line.device.toShortString()), diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index 185fec91..da4b1166 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -67,7 +67,7 @@ public class AltosEepromList extends ArrayList { ArrayList flights = new ArrayList(); - if (config_data.flight_log_max != 0) { + if (config_data.flight_log_max != 0 || config_data.log_format != 0) { /* Devices with newer firmware will support the 'l' * command which will list the region of storage @@ -113,7 +113,7 @@ public class AltosEepromList extends ArrayList { * firmware, this will also extract the flight number. */ for (AltosEepromFlight flight : flights) { - add(new AltosEepromLog(serial_line, config_data.serial, + add(new AltosEepromLog(config_data, serial_line, flight.flight, flight.start, flight.end)); } } finally { diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index 0cf420d9..be2549cb 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -46,7 +46,8 @@ public class AltosEepromLog { boolean download; boolean delete; - public AltosEepromLog(AltosSerial serial_line, int in_serial, + public AltosEepromLog(AltosConfigData config_data, + AltosSerial serial_line, int in_flight, int in_start_block, int in_end_block) throws InterruptedException, TimeoutException { @@ -54,51 +55,55 @@ public class AltosEepromLog { int block; boolean has_date = false; + flight = in_flight; + if (flight != 0) + has_flight = true; start_block = in_start_block; end_block = in_end_block; - serial = in_serial; + serial = config_data.serial; /* * By default, request that every log be downloaded but not deleted */ download = true; delete = false; + /* - * Only look in the first two blocks so that this - * process doesn't take a long time + * Look in TeleMetrum log data for date */ - if (in_end_block > in_start_block + 2) - in_end_block = in_start_block + 2; + if (config_data.log_format == Altos.AO_LOG_FORMAT_UNKNOWN || + config_data.log_format == Altos.AO_LOG_FORMAT_FULL) + { + /* + * Only look in the first two blocks so that this + * process doesn't take a long time + */ + if (in_end_block > in_start_block + 2) + in_end_block = in_start_block + 2; - for (block = in_start_block; block < in_end_block; block++) { - AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block); + for (block = in_start_block; block < in_end_block; block++) { + AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block); - if (block == in_start_block) { - if (eechunk.data16(0) == in_flight) { - flight = in_flight; - has_flight = true; - break; - } - } - for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) { - try { - AltosEepromRecord r = new AltosEepromRecord(eechunk, i); + for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) { + try { + AltosEepromRecord r = new AltosEepromRecord(eechunk, i); - if (r.cmd == Altos.AO_LOG_FLIGHT) { - flight = r.b; - has_flight = true; - } - if (r.cmd == Altos.AO_LOG_GPS_DATE) { - year = 2000 + (r.a & 0xff); - month = (r.a >> 8) & 0xff; - day = (r.b & 0xff); - has_date = true; + if (r.cmd == Altos.AO_LOG_FLIGHT) { + flight = r.b; + has_flight = true; + } + if (r.cmd == Altos.AO_LOG_GPS_DATE) { + year = 2000 + (r.a & 0xff); + month = (r.a >> 8) & 0xff; + day = (r.b & 0xff); + has_date = true; + } + } catch (ParseException pe) { } - } catch (ParseException pe) { } + if (has_date && has_flight) + break; } - if (has_date && has_flight) - break; } } } diff --git a/altosui/AltosEepromTeleScience.java b/altosui/AltosEepromTeleScience.java new file mode 100644 index 00000000..ee1840b0 --- /dev/null +++ b/altosui/AltosEepromTeleScience.java @@ -0,0 +1,64 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +public class AltosEepromTeleScience { + int type; + int tick; + int tm_state; + int tm_tick; + int[] data; + boolean valid; + + static final int AO_LOG_TELESCIENCE_START = 's'; + static final int AO_LOG_TELESCIENCE_DATA = 'd'; + + static final int max_data = 12; + static final int record_length = 32; + + public AltosEepromTeleScience (AltosEepromChunk chunk, int start) throws ParseException { + type = chunk.data(start); + + valid = !chunk.erased(start, record_length); + if (valid) { + if (AltosConvert.checksum(chunk.data, start, record_length) != 0) + throw new ParseException(String.format("invalid checksum at 0x%x", + chunk.address + start), 0); + } else { + type = Altos.AO_LOG_INVALID; + } + + tick = chunk.data16(start+2); + tm_tick = chunk.data16(start+4); + tm_state = chunk.data(start+6); + data = new int[max_data]; + for (int i = 0; i < max_data; i++) + data[i] = chunk.data16(start + 8 + i * 2); + } +} diff --git a/altosui/Makefile.am b/altosui/Makefile.am index 83510352..e4986ba5 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -45,6 +45,7 @@ altosui_JAVA = \ AltosEepromMonitor.java \ AltosEepromIterable.java \ AltosEepromRecord.java \ + AltosEepromTeleScience.java \ AltosEepromSelect.java \ AltosFile.java \ AltosFlash.java \ -- cgit v1.2.3 From dcd15032eec45f3fdd003050710ebd5b85052662 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Aug 2011 21:09:19 -0700 Subject: altosui: Eliminate inter-chunk flush_input calls Once the serial line is nicely synchronized, we don't need to flush input between chunks. This speeds up eeprom downloading quite a bit. Signed-off-by: Keith Packard --- altosui/AltosEepromChunk.java | 5 +++-- altosui/AltosEepromDownload.java | 2 +- altosui/AltosEepromLog.java | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromChunk.java b/altosui/AltosEepromChunk.java index fb632a3f..59767c2a 100644 --- a/altosui/AltosEepromChunk.java +++ b/altosui/AltosEepromChunk.java @@ -59,14 +59,15 @@ public class AltosEepromChunk { return true; } - public AltosEepromChunk(AltosSerial serial_line, int block) + public AltosEepromChunk(AltosSerial serial_line, int block, boolean flush) throws TimeoutException, InterruptedException { int offset; data = new int[chunk_size]; address = block * chunk_size; - serial_line.flush_input(); + if (flush) + serial_line.flush_input(); serial_line.printf("e %x\n", block); for (offset = 0; offset < chunk_size; offset += per_line) { diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 6112a3b1..b44a1451 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -275,7 +275,7 @@ public class AltosEepromDownload implements Runnable { for (block = log.start_block; !done && block < log.end_block; block++) { monitor.set_value(Altos.state_to_string[state], state, block - state_block); - AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block); + AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block, block == log.start_block); /* * Guess what kind of data is there if the device diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index be2549cb..ee77e5c8 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -82,7 +82,7 @@ public class AltosEepromLog { in_end_block = in_start_block + 2; for (block = in_start_block; block < in_end_block; block++) { - AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block); + AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block, block == in_start_block); for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) { try { -- cgit v1.2.3 From 924d56a4d2d8b16530cd378b18cfc5d6e08420ed Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sat, 13 Aug 2011 21:10:15 -0700 Subject: altos: AltosSerial.flush_input shouldn't discard Interrupted exceptions The eeprom download code wants to interrupt serial communication so that it can stop downloading stuff in the middle of a run. Make flush_input pass the exception along instead of discarding it. Signed-off-by: Keith Packard --- altosui/AltosDebug.java | 5 ++++- altosui/AltosEepromDelete.java | 12 ++++++++---- altosui/AltosEepromDownload.java | 8 ++++++-- altosui/AltosEepromManage.java | 5 ++++- altosui/AltosSerial.java | 17 +++++++++-------- 5 files changed, 31 insertions(+), 16 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosDebug.java b/altosui/AltosDebug.java index 8d435b66..d18de80d 100644 --- a/altosui/AltosDebug.java +++ b/altosui/AltosDebug.java @@ -62,7 +62,10 @@ public class AltosDebug extends AltosSerial { void ensure_debug_mode() { if (!debug_mode) { printf("D\n"); - flush_input(); + try { + flush_input(); + } catch (InterruptedException ie) { + } debug_mode = true; } } diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index cd9abfab..a9d77788 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -104,10 +104,14 @@ public class AltosEepromDelete implements Runnable { serial_line.device.toShortString()), "Connection Failed"); } finally { - if (remote) - serial_line.stop_remote(); - serial_line.flush_output(); - serial_line.close(); + try { + if (remote) + serial_line.stop_remote(); + } catch (InterruptedException ie) { + } finally { + serial_line.flush_output(); + serial_line.close(); + } } if (listener != null) { Runnable r = new Runnable() { diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index b44a1451..358ad337 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -373,8 +373,12 @@ public class AltosEepromDownload implements Runnable { "Connection Failed", JOptionPane.ERROR_MESSAGE); } finally { - if (remote) - serial_line.stop_remote(); + if (remote) { + try { + serial_line.stop_remote(); + } catch (InterruptedException ie) { + } + } serial_line.flush_output(); } monitor.done(); diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index 0652ca04..2e520628 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -44,7 +44,10 @@ public class AltosEepromManage implements ActionListener { public void finish() { if (serial_line != null) { - serial_line.flush_input(); + try { + serial_line.flush_input(); + } catch (InterruptedException ie) { + } serial_line.close(); serial_line = null; } diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index b089c9c4..f0e25fa5 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -187,7 +187,7 @@ public class AltosSerial implements Runnable { return abort; } - public void flush_input() { + public void flush_input() throws InterruptedException { flush_output(); boolean got_some; @@ -195,10 +195,7 @@ public class AltosSerial implements Runnable { if (remote) timeout = 500; do { - try { - Thread.sleep(timeout); - } catch (InterruptedException ie) { - } + Thread.sleep(timeout); got_some = !reply_queue.isEmpty(); synchronized(this) { if (!"VERSION".startsWith(line) && @@ -271,8 +268,12 @@ public class AltosSerial implements Runnable { } public void close() { - if (remote) - stop_remote(); + if (remote) { + try { + stop_remote(); + } catch (InterruptedException ie) { + } + } if (in_reply != 0) System.out.printf("Uh-oh. Closing active serial device\n"); @@ -422,7 +423,7 @@ public class AltosSerial implements Runnable { remote = true; } - public void stop_remote() { + public void stop_remote() throws InterruptedException { if (debug) System.out.printf("stop remote\n"); try { -- cgit v1.2.3 From 31e3255b6cbfaf95c0e97e2d1ec8de72f845994c Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 28 Aug 2011 15:50:30 -0700 Subject: altosui: Report error message back from libaltos This includes changing all of the error dialogs to show the error message rather than just the file name. Signed-off-by: Keith Packard --- altosui/AltosBTDevice.java | 7 +++ altosui/AltosCSVUI.java | 2 +- altosui/AltosConfig.java | 3 +- altosui/AltosDataChooser.java | 2 +- altosui/AltosDevice.java | 1 + altosui/AltosEepromDownload.java | 12 +++-- altosui/AltosEepromManage.java | 3 +- altosui/AltosFlashUI.java | 4 +- altosui/AltosIgniteUI.java | 3 +- altosui/AltosLanded.java | 4 +- altosui/AltosLaunchUI.java | 3 +- altosui/AltosScanUI.java | 6 +-- altosui/AltosSerial.java | 4 +- altosui/AltosUI.java | 9 ++-- altosui/AltosUSBDevice.java | 7 +++ altosui/libaltos/libaltos.c | 97 +++++++++++++++++++++++++++++++++------- altosui/libaltos/libaltos.h | 8 ++++ 17 files changed, 131 insertions(+), 44 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index 7a876c25..55b8f8fc 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -42,6 +42,13 @@ public class AltosBTDevice extends altos_bt_device implements AltosDevice { return getAddr(); } + public String getErrorString() { + altos_error error = new altos_error(); + + libaltos.altos_get_last_error(error); + return String.format("%s (%d)", error.getString(), error.getCode()); + } + public int getSerial() { String name = getName(); if (name == null) diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index e1b6002d..a212409e 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -99,7 +99,7 @@ public class AltosCSVUI writer.close(); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(frame, - file.getName(), + ee.getMessage(), "Cannot open file", JOptionPane.ERROR_MESSAGE); } diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 122ebecc..93def70d 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -480,8 +480,7 @@ public class AltosConfig implements ActionListener { } } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(owner, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ee.getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } catch (AltosSerialInUseException si) { diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index 15de05c2..d81ca6d1 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -61,7 +61,7 @@ public class AltosDataChooser extends JFileChooser { } } catch (FileNotFoundException fe) { JOptionPane.showMessageDialog(frame, - filename, + fe.getMessage(), "Cannot open file", JOptionPane.ERROR_MESSAGE); } diff --git a/altosui/AltosDevice.java b/altosui/AltosDevice.java index 3357c550..1b5c1a91 100644 --- a/altosui/AltosDevice.java +++ b/altosui/AltosDevice.java @@ -26,5 +26,6 @@ public interface AltosDevice { public abstract int getSerial(); public abstract String getPath(); public abstract boolean matchProduct(int product); + public abstract String getErrorString(); public SWIGTYPE_p_altos_file open(); } diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 358ad337..e7e52466 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -248,6 +248,10 @@ public class AltosEepromDownload implements Runnable { done = true; } + void CaptureTelemetry(AltosEepromChunk eechunk) throws IOException { + + } + void CaptureLog(AltosEepromLog log) throws IOException, InterruptedException, TimeoutException { int block, state_block = 0; int log_format = flights.config_data.log_format; @@ -300,10 +304,10 @@ public class AltosEepromDownload implements Runnable { extension = "eeprom"; CaptureTiny(eechunk); break; -// case Altos.AO_LOG_FORMAT_TELEMETRY: -// extension = "telem"; -// CaptureTelemetry(eechunk); -// break; + case Altos.AO_LOG_FORMAT_TELEMETRY: + extension = "telem"; + CaptureTelemetry(eechunk); + break; case Altos.AO_LOG_FORMAT_TELESCIENCE: extension = "science"; CaptureTeleScience(eechunk); diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index 2e520628..083c7372 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -219,8 +219,7 @@ public class AltosEepromManage implements ActionListener { t.start(); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(frame, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ee.getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } catch (AltosSerialInUseException si) { diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 3874b500..3956ff20 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -200,8 +200,8 @@ public class AltosFlashUI void exception (Exception e) { if (e instanceof FileNotFoundException) { JOptionPane.showMessageDialog(frame, - "Cannot open image", - file.toString(), + ((FileNotFoundException) e).getMessage(), + "Cannot open file", JOptionPane.ERROR_MESSAGE); } else if (e instanceof AltosSerialInUseException) { JOptionPane.showMessageDialog(frame, diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index c11a8614..b215c228 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -122,8 +122,7 @@ public class AltosIgniteUI void ignite_exception(Exception e) { if (e instanceof FileNotFoundException) { JOptionPane.showMessageDialog(owner, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ((FileNotFoundException) e).getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } else if (e instanceof AltosSerialInUseException) { diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 50e6b542..4dd9a2dd 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -250,7 +250,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio FileInputStream in = new FileInputStream(file); records = new AltosTelemetryIterable(in); } else { - throw new FileNotFoundException(); + throw new FileNotFoundException(filename); } try { new AltosGraphUI(records, filename); @@ -259,7 +259,7 @@ public class AltosLanded extends JComponent implements AltosFlightDisplay, Actio } } catch (FileNotFoundException fe) { JOptionPane.showMessageDialog(null, - filename, + fe.getMessage(), "Cannot open file", JOptionPane.ERROR_MESSAGE); } diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index 4e630afb..47365e03 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -164,8 +164,7 @@ public class AltosLaunchUI void launch_exception(Exception e) { if (e instanceof FileNotFoundException) { JOptionPane.showMessageDialog(owner, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ((FileNotFoundException) e).getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } else if (e instanceof AltosSerialInUseException) { diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index bce4b32c..df5c51d4 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -130,8 +130,7 @@ public class AltosScanUI void scan_exception(Exception e) { if (e instanceof FileNotFoundException) { JOptionPane.showMessageDialog(owner, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ((FileNotFoundException) e).getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } else if (e instanceof AltosSerialInUseException) { @@ -326,8 +325,7 @@ public class AltosScanUI return true; } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(owner, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ee.getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } catch (AltosSerialInUseException si) { diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index 0a531aa9..4cf306d0 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -323,8 +323,10 @@ public class AltosSerial implements Runnable { } altos = device.open(); if (altos == null) { + final String message = device.getErrorString(); close(); - throw new FileNotFoundException(device.toShortString()); + throw new FileNotFoundException(String.format("%s (%s)", + device.toShortString(), message)); } if (debug) System.out.printf("Open %s\n", device.getPath()); diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 60adfc7c..3e5bcf43 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -52,8 +52,7 @@ public class AltosUI extends JFrame { new AltosFlightUI(voice, reader, device.getSerial()); } catch (FileNotFoundException ee) { JOptionPane.showMessageDialog(AltosUI.this, - String.format("Cannot open device \"%s\"", - device.toShortString()), + ee.getMessage(), "Cannot open target device", JOptionPane.ERROR_MESSAGE); } catch (AltosSerialInUseException si) { @@ -356,7 +355,7 @@ public class AltosUI extends JFrame { else return new AltosTelemetryIterable(in); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -366,7 +365,7 @@ public class AltosUI extends JFrame { try { return new AltosCSV(file); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } @@ -376,7 +375,7 @@ public class AltosUI extends JFrame { try { return new AltosKML(file); } catch (FileNotFoundException fe) { - System.out.printf("Cannot open '%s'\n", filename); + System.out.printf("%s\n", fe.getMessage()); return null; } } diff --git a/altosui/AltosUSBDevice.java b/altosui/AltosUSBDevice.java index dc746a64..b11a3934 100644 --- a/altosui/AltosUSBDevice.java +++ b/altosui/AltosUSBDevice.java @@ -39,6 +39,13 @@ public class AltosUSBDevice extends altos_device implements AltosDevice { } + public String getErrorString() { + altos_error error = new altos_error(); + + libaltos.altos_get_last_error(error); + return String.format("%s (%d)", error.getString(), error.getCode()); + } + public SWIGTYPE_p_altos_file open() { return libaltos.altos_open(this); } diff --git a/altosui/libaltos/libaltos.c b/altosui/libaltos/libaltos.c index a3796ee3..48e00a44 100644 --- a/altosui/libaltos/libaltos.c +++ b/altosui/libaltos/libaltos.c @@ -49,6 +49,22 @@ altos_fini(void) { } +static struct altos_error last_error; + +static void +altos_set_last_error(int code, char *string) +{ + last_error.code = code; + strncpy(last_error.string, string, sizeof (last_error.string) -1); + last_error.string[sizeof(last_error.string)-1] = '\0'; +} + +PUBLIC void +altos_get_last_error(struct altos_error *error) +{ + *error = last_error; +} + #ifdef DARWIN #undef USE_POLL @@ -96,6 +112,12 @@ struct altos_file { int in_read; }; +static void +altos_set_last_posix_error(void) +{ + altos_set_last_error(errno, strerror(errno)); +} + PUBLIC struct altos_file * altos_open(struct altos_device *device) { @@ -103,12 +125,18 @@ altos_open(struct altos_device *device) int ret; struct termios term; - if (!file) + if (!file) { + altos_set_last_posix_error(); return NULL; + } + +// altos_set_last_error(12, "yeah yeah, failed again"); +// free(file); +// return NULL; file->fd = open(device->path, O_RDWR | O_NOCTTY); if (file->fd < 0) { - perror(device->path); + altos_set_last_posix_error(); free(file); return NULL; } @@ -117,7 +145,7 @@ altos_open(struct altos_device *device) #else file->out_fd = open(device->path, O_RDWR | O_NOCTTY); if (file->out_fd < 0) { - perror(device->path); + altos_set_last_posix_error(); close(file->fd); free(file); return NULL; @@ -125,7 +153,7 @@ altos_open(struct altos_device *device) #endif ret = tcgetattr(file->fd, &term); if (ret < 0) { - perror("tcgetattr"); + altos_set_last_posix_error(); close(file->fd); #ifndef USE_POLL close(file->out_fd); @@ -143,7 +171,7 @@ altos_open(struct altos_device *device) #endif ret = tcsetattr(file->fd, TCSAFLUSH, &term); if (ret < 0) { - perror("tcsetattr"); + altos_set_last_posix_error(); close(file->fd); #ifndef USE_POLL close(file->out_fd); @@ -195,8 +223,10 @@ altos_flush(struct altos_file *file) #else ret = write (file->out_fd, file->out_data, file->out_used); #endif - if (ret < 0) + if (ret < 0) { + altos_set_last_posix_error(); return -errno; + } if (ret) { memmove(file->out_data, file->out_data + ret, file->out_used - ret); @@ -248,7 +278,7 @@ altos_fill(struct altos_file *file, int timeout) fd[1].events = POLLIN; ret = poll(fd, 2, timeout); if (ret < 0) { - perror("altos_getchar"); + altos_set_last_posix_error(); return LIBALTOS_ERROR; } if (ret == 0) @@ -261,7 +291,7 @@ altos_fill(struct altos_file *file, int timeout) { ret = read(file->fd, file->in_data, USB_BUF_SIZE); if (ret < 0) { - perror("altos_getchar"); + altos_set_last_posix_error(); return LIBALTOS_ERROR; } file->in_read = 0; @@ -700,8 +730,10 @@ altos_bt_open(struct altos_bt_device *device) if (!file) goto no_file; file->fd = socket(AF_BLUETOOTH, SOCK_STREAM, BTPROTO_RFCOMM); - if (file->fd < 0) + if (file->fd < 0) { + altos_set_last_posix_error(); goto no_sock; + } addr.rc_family = AF_BLUETOOTH; addr.rc_channel = 1; @@ -711,7 +743,7 @@ altos_bt_open(struct altos_bt_device *device) (struct sockaddr *)&addr, sizeof(addr)); if (status < 0) { - perror("connect"); + altos_set_last_posix_error(); goto no_link; } sleep(1); @@ -912,6 +944,21 @@ struct altos_file { OVERLAPPED ov_write; }; +static void +altos_set_last_windows_error(void) +{ + DWORD error = GetLastError(); + TCHAR message[1024]; + FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, + 0, + error, + 0, + message, + sizeof (message) / sizeof (TCHAR), + NULL); + altos_set_last_error(error, message); +} + PUBLIC struct altos_list * altos_list_start(void) { @@ -922,7 +969,7 @@ altos_list_start(void) list->dev_info = SetupDiGetClassDevs(NULL, "USB", NULL, DIGCF_ALLCLASSES|DIGCF_PRESENT); if (list->dev_info == INVALID_HANDLE_VALUE) { - printf("SetupDiGetClassDevs failed %ld\n", GetLastError()); + altos_set_last_windows_error(); free(list); return NULL; } @@ -956,6 +1003,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) DICS_FLAG_GLOBAL, 0, DIREG_DEV, KEY_READ); if (dev_key == INVALID_HANDLE_VALUE) { + altos_set_last_windows_error(); printf("cannot open device registry key\n"); continue; } @@ -966,6 +1014,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) result = RegQueryValueEx(dev_key, "SymbolicName", NULL, NULL, symbolic, &symbolic_len); if (result != 0) { + altos_set_last_windows_error(); printf("cannot find SymbolicName value\n"); RegCloseKey(dev_key); continue; @@ -988,6 +1037,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) port, &port_len); RegCloseKey(dev_key); if (result != 0) { + altos_set_last_windows_error(); printf("failed to get PortName\n"); continue; } @@ -1003,6 +1053,7 @@ altos_list_next(struct altos_list *list, struct altos_device *device) sizeof(friendlyname), &friendlyname_len)) { + altos_set_last_windows_error(); printf("Failed to get friendlyname\n"); continue; } @@ -1015,8 +1066,10 @@ altos_list_next(struct altos_list *list, struct altos_device *device) return 1; } result = GetLastError(); - if (result != ERROR_NO_MORE_ITEMS) + if (result != ERROR_NO_MORE_ITEMS) { + altos_set_last_windows_error(); printf ("SetupDiEnumDeviceInfo failed error %d\n", (int) result); + } return 0; } @@ -1035,8 +1088,10 @@ altos_queue_read(struct altos_file *file) return LIBALTOS_SUCCESS; if (!ReadFile(file->handle, file->in_data, USB_BUF_SIZE, &got, &file->ov_read)) { - if (GetLastError() != ERROR_IO_PENDING) + if (GetLastError() != ERROR_IO_PENDING) { + altos_set_last_windows_error(); return LIBALTOS_ERROR; + } file->pend_read = TRUE; } else { file->pend_read = FALSE; @@ -1061,8 +1116,10 @@ altos_wait_read(struct altos_file *file, int timeout) ret = WaitForSingleObject(file->ov_read.hEvent, timeout); switch (ret) { case WAIT_OBJECT_0: - if (!GetOverlappedResult(file->handle, &file->ov_read, &got, FALSE)) + if (!GetOverlappedResult(file->handle, &file->ov_read, &got, FALSE)) { + altos_set_last_windows_error(); return LIBALTOS_ERROR; + } file->pend_read = FALSE; file->in_read = 0; file->in_used = got; @@ -1106,15 +1163,20 @@ altos_flush(struct altos_file *file) while (used) { if (!WriteFile(file->handle, data, used, &put, &file->ov_write)) { - if (GetLastError() != ERROR_IO_PENDING) + if (GetLastError() != ERROR_IO_PENDING) { + altos_set_last_windows_error(); return LIBALTOS_ERROR; + } ret = WaitForSingleObject(file->ov_write.hEvent, INFINITE); switch (ret) { case WAIT_OBJECT_0: - if (!GetOverlappedResult(file->handle, &file->ov_write, &put, FALSE)) + if (!GetOverlappedResult(file->handle, &file->ov_write, &put, FALSE)) { + altos_set_last_windows_error(); return LIBALTOS_ERROR; + } break; default: + altos_set_last_windows_error(); return LIBALTOS_ERROR; } } @@ -1142,6 +1204,7 @@ altos_open(struct altos_device *device) 0, NULL, OPEN_EXISTING, FILE_FLAG_OVERLAPPED, NULL); if (file->handle == INVALID_HANDLE_VALUE) { + altos_set_last_windows_error(); free(file); return NULL; } @@ -1157,6 +1220,7 @@ altos_open(struct altos_device *device) dcbSerialParams.DCBlength = sizeof(dcbSerialParams); if (!GetCommState(file->handle, &dcbSerialParams)) { + altos_set_last_windows_error(); CloseHandle(file->handle); free(file); return NULL; @@ -1166,6 +1230,7 @@ altos_open(struct altos_device *device) dcbSerialParams.StopBits = ONESTOPBIT; dcbSerialParams.Parity = NOPARITY; if (!SetCommState(file->handle, &dcbSerialParams)) { + altos_set_last_windows_error(); CloseHandle(file->handle); free(file); return NULL; diff --git a/altosui/libaltos/libaltos.h b/altosui/libaltos/libaltos.h index a05bed4c..f90fbb87 100644 --- a/altosui/libaltos/libaltos.h +++ b/altosui/libaltos/libaltos.h @@ -51,6 +51,11 @@ struct altos_bt_device { //%mutable; }; +struct altos_error { + int code; + char string[1024]; +}; + #define LIBALTOS_SUCCESS 0 #define LIBALTOS_ERROR -1 #define LIBALTOS_TIMEOUT -2 @@ -62,6 +67,9 @@ altos_init(void); PUBLIC void altos_fini(void); +PUBLIC void +altos_get_last_error(struct altos_error *error); + PUBLIC struct altos_list * altos_list_start(void); -- cgit v1.2.3 From 0952224c36eba25db34bd147d2d579c66b15bbf8 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 27 Mar 2012 18:24:51 -0700 Subject: altosui: Change flight data saving UI to separate download/delete selections First pop up a dialog to select flights for download. Download them. Then, after that, pop up a *new* dialog to select flights for delete. Offer to delete all of the downloaded flights by default. Then delete the flights. Signed-off-by: Keith Packard --- altosui/AltosEepromDelete.java | 2 +- altosui/AltosEepromDownload.java | 2 +- altosui/AltosEepromLog.java | 8 ++--- altosui/AltosEepromManage.java | 72 +++++++++++++++++++++------------------- altosui/AltosEepromSelect.java | 45 ++++++------------------- 5 files changed, 52 insertions(+), 77 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index a9d77788..fcce8155 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -90,7 +90,7 @@ public class AltosEepromDelete implements Runnable { serial_line.start_remote(); for (AltosEepromLog log : flights) { - if (log.delete) { + if (log.selected) { DeleteLog(log); } } diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index e7e52466..40c98bfd 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -351,7 +351,7 @@ public class AltosEepromDownload implements Runnable { for (AltosEepromLog log : flights) { parse_exception = null; - if (log.download) { + if (log.selected) { monitor.reset(); CaptureLog(log); } diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index ee77e5c8..475d7f12 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -43,8 +43,7 @@ public class AltosEepromLog { int year, month, day; - boolean download; - boolean delete; + boolean selected; public AltosEepromLog(AltosConfigData config_data, AltosSerial serial_line, @@ -63,10 +62,9 @@ public class AltosEepromLog { serial = config_data.serial; /* - * By default, request that every log be downloaded but not deleted + * Select all flights for download */ - download = true; - delete = false; + selected = true; /* * Look in TeleMetrum log data for date diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index 083c7372..1e06f4ca 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -39,8 +39,6 @@ public class AltosEepromManage implements ActionListener { AltosEepromList flights; AltosEepromDownload download; AltosEepromDelete delete; - boolean any_download; - boolean any_delete; public void finish() { if (serial_line != null) { @@ -57,7 +55,7 @@ public class AltosEepromManage implements ActionListener { String result = ""; for (AltosEepromLog flight : flights) { - if (flight.delete) { + if (flight.selected) { if (result.equals("")) result = String.format("%d", flight.flight); else @@ -67,18 +65,38 @@ public class AltosEepromManage implements ActionListener { return result; } + public boolean download_done() { + AltosEepromSelect select = new AltosEepromSelect(frame, flights, "Delete"); + + if (select.run()) { + boolean any_selected = false; + for (AltosEepromLog flight : flights) + any_selected = any_selected || flight.selected; + if (any_selected) { + delete = new AltosEepromDelete(frame, + serial_line, + remote, + flights); + delete.addActionListener(this); + /* + * Start flight log delete + */ + + delete.start(); + return true; + } + } + return false; + } + public void actionPerformed(ActionEvent e) { String cmd = e.getActionCommand(); boolean success = e.getID() != 0; boolean running = false; if (cmd.equals("download")) { - if (success) { - if (any_delete) { - delete.start(); - running = true; - } - } + if (success) + running = download_done(); } else if (cmd.equals("delete")) { if (success) { JOptionPane.showMessageDialog(frame, @@ -104,40 +122,26 @@ public class AltosEepromManage implements ActionListener { serial_line.device.toShortString(), JOptionPane.INFORMATION_MESSAGE); } else { - AltosEepromSelect select = new AltosEepromSelect(frame, flights); + AltosEepromSelect select = new AltosEepromSelect(frame, flights, "Download"); if (select.run()) { - for (AltosEepromLog flight : flights) { - any_download = any_download || flight.download; - any_delete = any_delete || flight.delete; - } - if (any_download) { + boolean any_selected = false; + for (AltosEepromLog flight : flights) + any_selected = any_selected || flight.selected; + if (any_selected) { download = new AltosEepromDownload(frame, serial_line, remote, flights); download.addActionListener(this); - } - - if (any_delete) { - delete = new AltosEepromDelete(frame, - serial_line, - remote, - flights); - delete.addActionListener(this); - } + /* + * Start flight log download + */ - /* - * Start flight log download - */ - - if (any_download) { download.start(); running = true; - } - else if (any_delete) { - delete.start(); - running = true; + } else { + running = download_done(); } } } @@ -203,8 +207,6 @@ public class AltosEepromManage implements ActionListener { device = AltosDeviceDialog.show(frame, Altos.product_any); remote = false; - any_download = false; - any_delete = false; if (device != null) { try { diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index ebafc4c8..e0fbeead 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -31,15 +31,11 @@ import libaltosJNI.SWIGTYPE_p_altos_list; class AltosEepromItem implements ActionListener { AltosEepromLog log; JLabel label; - JCheckBox download; + JCheckBox action; JCheckBox delete; public void actionPerformed(ActionEvent e) { - if (e.getSource() == download) { - log.download = download.isSelected(); - } else if (e.getSource() == delete) { - log.delete = delete.isSelected(); - } + log.selected = action.isSelected(); } public AltosEepromItem(AltosEepromLog in_log) { @@ -54,11 +50,8 @@ class AltosEepromItem implements ActionListener { label = new JLabel(text); - download = new JCheckBox("", log.download); - download.addActionListener(this); - - delete = new JCheckBox("", log.delete); - delete.addActionListener(this); + action = new JCheckBox("", log.selected); + action.addActionListener(this); } } @@ -86,7 +79,8 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener { } public AltosEepromSelect (JFrame in_frame, - AltosEepromList flights) { + AltosEepromList flights, + String action) { super(in_frame, String.format("Flight list for serial %d", flights.config_data.serial), true); frame = in_frame; @@ -95,7 +89,7 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener { Container contentPane = getContentPane(); /* First, we create a pane containing the dialog's header/title */ - JLabel selectLabel = new JLabel("Select flights to download and/or delete", SwingConstants.CENTER); + JLabel selectLabel = new JLabel(String.format ("Select flights to %s", action), SwingConstants.CENTER); JPanel labelPane = new JPanel(); labelPane.setLayout(new BoxLayout(labelPane, BoxLayout.X_AXIS)); @@ -132,19 +126,9 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener { c.weightx = 0.5; c.anchor = GridBagConstraints.CENTER; c.insets = i; - JLabel downloadHeaderLabel = new JLabel("Download"); + JLabel downloadHeaderLabel = new JLabel(action); flightPane.add(downloadHeaderLabel, c); - /* Delete Header */ - c = new GridBagConstraints(); - c.gridx = 2; c.gridy = 0; - c.fill = GridBagConstraints.NONE; - c.weightx = 0.5; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - JLabel deleteHeaderLabel = new JLabel("Delete"); - flightPane.add(deleteHeaderLabel, c); - /* Add the flights to the GridBag */ AltosEepromItem item; int itemNumber = 1; @@ -163,23 +147,14 @@ public class AltosEepromSelect extends AltosDialog implements ActionListener { c.insets = i; flightPane.add(item.label, c); - /* Add a download checkbox for the flight */ + /* Add action checkbox for the flight */ c = new GridBagConstraints(); c.gridx = 1; c.gridy = itemNumber; c.fill = GridBagConstraints.NONE; c.weightx = 0.5; c.anchor = GridBagConstraints.CENTER; c.insets = i; - flightPane.add(item.download, c); - - /* Add a delete checkbox for the flight */ - c = new GridBagConstraints(); - c.gridx = 2; c.gridy = itemNumber; - c.fill = GridBagConstraints.NONE; - c.weightx = 0.5; - c.anchor = GridBagConstraints.CENTER; - c.insets = i; - flightPane.add(item.delete, c); + flightPane.add(item.action, c); itemNumber++; } -- cgit v1.2.3 From 1824761f5b98e92485e2dd347b1c4d043ec207e2 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Fri, 1 Jun 2012 19:51:25 -0700 Subject: altosui: Quick hacks to download megametrum data and convert to CSV Very little useful data crunching is done, but at least we can save and convert files Signed-off-by: Keith Packard --- altosui/Altos.java | 12 + altosui/AltosCSV.java | 42 ++- altosui/AltosConfigData.java | 2 +- altosui/AltosDataChooser.java | 3 + altosui/AltosEepromChunk.java | 5 + altosui/AltosEepromDownload.java | 67 ++++- altosui/AltosEepromIterable.java | 26 +- altosui/AltosEepromList.java | 4 +- altosui/AltosEepromMega.java | 218 +++++++++++++++ altosui/AltosEepromMegaIterable.java | 523 +++++++++++++++++++++++++++++++++++ altosui/AltosIMU.java | 29 ++ altosui/AltosMag.java | 25 ++ altosui/AltosMs5607.java | 76 +++++ altosui/AltosRecord.java | 5 + altosui/AltosState.java | 5 + altosui/AltosUI.java | 2 + altosui/Makefile.am | 5 + 17 files changed, 1039 insertions(+), 10 deletions(-) create mode 100644 altosui/AltosEepromMega.java create mode 100644 altosui/AltosEepromMegaIterable.java create mode 100644 altosui/AltosIMU.java create mode 100644 altosui/AltosMag.java create mode 100644 altosui/AltosMs5607.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/Altos.java b/altosui/Altos.java index aa2fd77a..1d393dbe 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -52,6 +52,17 @@ public class Altos { static final int AO_LOG_PRODUCT = 2001; static final int AO_LOG_SERIAL_NUMBER = 2002; static final int AO_LOG_LOG_FORMAT = 2003; + + /* Added for header fields in megametrum files */ + static final int AO_LOG_BARO_RESERVED = 3000; + static final int AO_LOG_BARO_SENS = 3001; + static final int AO_LOG_BARO_OFF = 3002; + static final int AO_LOG_BARO_TCS = 3004; + static final int AO_LOG_BARO_TCO = 3005; + static final int AO_LOG_BARO_TREF = 3006; + static final int AO_LOG_BARO_TEMPSENS = 3007; + static final int AO_LOG_BARO_CRC = 3008; + static final int AO_LOG_SOFTWARE_VERSION = 9999; /* Added to flag invalid records */ @@ -220,6 +231,7 @@ public class Altos { static final int AO_LOG_FORMAT_TINY = 2; static final int AO_LOG_FORMAT_TELEMETRY = 3; static final int AO_LOG_FORMAT_TELESCIENCE = 4; + static final int AO_LOG_FORMAT_MEGAMETRUM = 5; static final int AO_LOG_FORMAT_NONE = 127; static boolean isspace(int c) { diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index 9ec21bef..b88bedba 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -31,7 +31,7 @@ public class AltosCSV implements AltosWriter { LinkedList pad_records; AltosState state; - static final int ALTOS_CSV_VERSION = 4; + static final int ALTOS_CSV_VERSION = 5; /* Version 4 format: * @@ -61,6 +61,17 @@ public class AltosCSV implements AltosWriter { * drogue (V) * main (V) * + * Advanced sensors (if available) + * accel_x (m/s²) + * accel_y (m/s²) + * accel_z (m/s²) + * gyro_x (d/s) + * gyro_y (d/s) + * gyro_z (d/s) + * mag_x (g) + * mag_y (g) + * mag_z (g) + * * GPS data (if available) * connected (1/0) * locked (1/0) @@ -129,6 +140,24 @@ public class AltosCSV implements AltosWriter { record.main_voltage()); } + void write_advanced_header() { + out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z"); + } + + void write_advanced(AltosRecord record) { + AltosIMU imu = record.imu; + AltosMag mag = record.mag; + + if (imu == null) + imu = new AltosIMU(); + if (mag == null) + mag = new AltosMag(); + out.printf("%d,%d,%d,%d,%d,%d,%d,%d,%d", + imu.accel_x, imu.accel_y, imu.accel_z, + imu.gyro_x, imu.gyro_y, imu.gyro_z, + mag.x, mag.y, mag.z); + } + void write_gps_header() { out.printf("connected,locked,nsat,latitude,longitude,altitude,year,month,day,hour,minute,second,pad_dist,pad_range,pad_az,pad_el,hdop"); } @@ -212,10 +241,12 @@ public class AltosCSV implements AltosWriter { out.printf(",0"); } - void write_header(boolean gps, boolean companion) { + void write_header(boolean advanced, boolean gps, boolean companion) { out.printf("#"); write_general_header(); out.printf(","); write_flight_header(); out.printf(","); write_basic_header(); + if (advanced) + out.printf(","); write_advanced_header(); if (gps) { out.printf(","); write_gps_header(); out.printf(","); write_gps_sat_header(); @@ -230,7 +261,9 @@ public class AltosCSV implements AltosWriter { state = new AltosState(record, state); write_general(record); out.printf(","); write_flight(record); out.printf(","); - write_basic(record); + write_basic(record); out.printf(","); + if (record.imu != null || record.mag != null) + write_advanced(record); if (record.gps != null) { out.printf(","); write_gps(record); out.printf(","); @@ -253,7 +286,8 @@ public class AltosCSV implements AltosWriter { if (record.state == Altos.ao_flight_startup) return; if (!header_written) { - write_header(record.gps != null, record.companion != null); + write_header(record.imu != null || record.mag != null, + record.gps != null, record.companion != null); header_written = true; } if (!seen_boost) { diff --git a/altosui/AltosConfigData.java b/altosui/AltosConfigData.java index 53509dfa..64d9f095 100644 --- a/altosui/AltosConfigData.java +++ b/altosui/AltosConfigData.java @@ -138,7 +138,7 @@ public class AltosConfigData implements Iterable { } public AltosConfigData(AltosSerial serial_line) throws InterruptedException, TimeoutException { - serial_line.printf("c s\nf\nl\nv\n"); + serial_line.printf("c s\np\nf\nl\nv\n"); lines = new LinkedList(); radio_setting = 0; radio_frequency = 0; diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index d81ca6d1..488e1068 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -56,6 +56,9 @@ public class AltosDataChooser extends JFileChooser { } else if (filename.endsWith("telem")) { FileInputStream in = new FileInputStream(file); return new AltosTelemetryIterable(in); + } else if (filename.endsWith("mega")) { + FileInputStream in = new FileInputStream(file); + return new AltosEepromMegaIterable(in); } else { throw new FileNotFoundException(); } diff --git a/altosui/AltosEepromChunk.java b/altosui/AltosEepromChunk.java index 59767c2a..77707f7b 100644 --- a/altosui/AltosEepromChunk.java +++ b/altosui/AltosEepromChunk.java @@ -52,6 +52,11 @@ public class AltosEepromChunk { return data[offset] | (data[offset + 1] << 8); } + int data32(int offset) { + return data[offset] | (data[offset + 1] << 8) | + (data[offset+2] << 16) | (data[offset+3] << 24); + } + boolean erased(int start, int len) { for (int i = 0; i < len; i++) if (data[start+i] != 0xff) diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 40c98bfd..8f7a8544 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -248,6 +248,64 @@ public class AltosEepromDownload implements Runnable { done = true; } + void LogMega(AltosEepromMega r) throws IOException { + if (r.cmd != Altos.AO_LOG_INVALID) { + String log_line = String.format("%c %4x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x %2x\n", + r.cmd, r.tick, + r.data8[0], r.data8[1], r.data8[2], r.data8[3], + r.data8[4], r.data8[5], r.data8[6], r.data8[7], + r.data8[8], r.data8[9], r.data8[10], r.data8[11], + r.data8[12], r.data8[13], r.data8[14], r.data8[15], + r.data8[16], r.data8[17], r.data8[18], r.data8[19], + r.data8[20], r.data8[21], r.data8[22], r.data8[23], + r.data8[24], r.data8[25], r.data8[26], r.data8[27]); + if (eeprom_file != null) + eeprom_file.write(log_line); + else + eeprom_pending.add(log_line); + } + } + + void CaptureMega(AltosEepromChunk eechunk) throws IOException { + boolean any_valid = false; + + extension = "mega"; + set_serial(flights.config_data.serial); + for (int i = 0; i < eechunk.chunk_size && !done; i += AltosEepromMega.record_length) { + try { + AltosEepromMega r = new AltosEepromMega(eechunk, i); + if (r.cmd == Altos.AO_LOG_FLIGHT) + set_flight(r.data16(0)); + + /* Monitor state transitions to update display */ + if (r.cmd == Altos.AO_LOG_STATE && r.data16(0) <= Altos.ao_flight_landed) { + state = r.data16(0); + if (state > Altos.ao_flight_pad) + want_file = true; + } + + if (r.cmd == Altos.AO_LOG_GPS_TIME) { + year = 2000 + r.data8(14); + month = r.data8(15); + day = r.data8(14); + want_file = true; + } + + if (r.cmd == Altos.AO_LOG_STATE && r.data16(0) == Altos.ao_flight_landed) + done = true; + any_valid = true; + LogMega(r); + } catch (ParseException pe) { + if (parse_exception == null) + parse_exception = pe; + } + } + if (!any_valid) + done = true; + + CheckFile(false); + } + void CaptureTelemetry(AltosEepromChunk eechunk) throws IOException { } @@ -260,9 +318,11 @@ public class AltosEepromDownload implements Runnable { done = false; start = true; - if (flights.config_data.serial == 0) - throw new IOException("no serial number found"); +// if (flights.config_data.serial == 0) +// throw new IOException("no serial number found"); + log_format = 5; + System.out.printf ("log format: %d\n", log_format); /* Reset per-capture variables */ flight = 0; year = 0; @@ -312,6 +372,9 @@ public class AltosEepromDownload implements Runnable { extension = "science"; CaptureTeleScience(eechunk); break; + case Altos.AO_LOG_FORMAT_MEGAMETRUM: + extension = "mega"; + CaptureMega(eechunk); } } CheckFile(true); diff --git a/altosui/AltosEepromIterable.java b/altosui/AltosEepromIterable.java index 6fdaf8e0..b8e21ece 100644 --- a/altosui/AltosEepromIterable.java +++ b/altosui/AltosEepromIterable.java @@ -268,7 +268,7 @@ public class AltosEepromIterable extends AltosRecordIterable { AltosRecord r = new AltosRecord(state); r.time = (r.tick - eeprom.boost_tick) / 100.0; list.add(r); - return list; + return list; } public Iterator iterator() { @@ -323,6 +323,30 @@ public class AltosEepromIterable extends AltosRecordIterable { case Altos.AO_LOG_SOFTWARE_VERSION: out.printf ("# Software version: %s\n", record.data); break; + case Altos.AO_LOG_BARO_RESERVED: + out.printf ("# Baro reserved: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_SENS: + out.printf ("# Baro sens: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_OFF: + out.printf ("# Baro off: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TCS: + out.printf ("# Baro tcs: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TCO: + out.printf ("# Baro tco: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TREF: + out.printf ("# Baro tref: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TEMPSENS: + out.printf ("# Baro tempsens: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_CRC: + out.printf ("# Baro crc: %d\n", record.a); + break; } } } diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index da4b1166..945746dd 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -62,8 +62,8 @@ public class AltosEepromList extends ArrayList { if (remote) serial_line.start_remote(); config_data = new AltosConfigData (serial_line); - if (config_data.serial == 0) - throw new IOException("no serial number found"); +// if (config_data.serial == 0) +// throw new IOException("no serial number found"); ArrayList flights = new ArrayList(); diff --git a/altosui/AltosEepromMega.java b/altosui/AltosEepromMega.java new file mode 100644 index 00000000..8ae485cb --- /dev/null +++ b/altosui/AltosEepromMega.java @@ -0,0 +1,218 @@ +/* + * Copyright © 2011 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.*; + +public class AltosEepromMega { + public int cmd; + public int tick; + public boolean valid; + public String data; + int a, b; + + public int data8[]; + + static final int record_length = 32; + static final int header_length = 4; + static final int data_length = record_length - header_length; + + public int data8(int i) { + return data8[i]; + } + + public int data16(int i) { + return ((data8[i] | (data8[i+1] << 8)) << 16) >> 16; + } + + public int data32(int i) { + return data8[i] | (data8[i+1] << 8) | (data8[i+2] << 16) | (data8[i+3] << 24); + } + + /* AO_LOG_FLIGHT elements */ + public int flight() { return data16(0); } + public int ground_accel() { return data16(2); } + public int ground_pres() { return data32(4); } + public int ground_temp() { return data32(8); } + + /* AO_LOG_STATE elements */ + public int state() { return data16(0); } + public int reason() { return data16(2); } + + /* AO_LOG_SENSOR elements */ + public int pres() { return data32(0); } + public int temp() { return data32(4); } + public int accel_x() { return data16(8); } + public int accel_y() { return data16(10); } + public int accel_z() { return data16(12); } + public int gyro_x() { return data16(14); } + public int gyro_y() { return data16(16); } + public int gyro_z() { return data16(18); } + public int mag_x() { return data16(20); } + public int mag_y() { return data16(22); } + public int mag_z() { return data16(24); } + public int accel() { + int a = data16(26); + if (a != 0xffff) + return a; + return accel_y(); + } + + /* AO_LOG_VOLT elements */ + public int v_batt() { return data16(0); } + public int v_pbatt() { return data16(2); } + public int nsense() { return data16(4); } + public int sense(int i) { return data16(6 + i * 2); } + + public AltosEepromMega (AltosEepromChunk chunk, int start) throws ParseException { + cmd = chunk.data(start); + + valid = !chunk.erased(start, record_length); + if (valid) { + if (AltosConvert.checksum(chunk.data, start, record_length) != 0) + throw new ParseException(String.format("invalid checksum at 0x%x", + chunk.address + start), 0); + } else { + cmd = Altos.AO_LOG_INVALID; + } + + tick = chunk.data16(start+2); + + data8 = new int[data_length]; + for (int i = 0; i < data_length; i++) + data8[i] = chunk.data(start + header_length + i); + } + + public AltosEepromMega (String line) { + valid = false; + tick = 0; + + if (line == null) { + cmd = Altos.AO_LOG_INVALID; + line = ""; + } else { + try { + String[] tokens = line.split("\\s+"); + + if (tokens[0].length() == 1) { + if (tokens.length != 2 + data_length) { + cmd = Altos.AO_LOG_INVALID; + data = line; + } else { + cmd = tokens[0].codePointAt(0); + tick = Integer.parseInt(tokens[1],16); + valid = true; + data8 = new int[data_length]; + for (int i = 0; i < data_length; i++) + data8[i] = Integer.parseInt(tokens[2 + i],16); + } + } else if (tokens[0].equals("Config") && tokens[1].equals("version:")) { + cmd = Altos.AO_LOG_CONFIG_VERSION; + data = tokens[2]; + } else if (tokens[0].equals("Main") && tokens[1].equals("deploy:")) { + cmd = Altos.AO_LOG_MAIN_DEPLOY; + a = Integer.parseInt(tokens[2]); + } else if (tokens[0].equals("Apogee") && tokens[1].equals("delay:")) { + cmd = Altos.AO_LOG_APOGEE_DELAY; + a = Integer.parseInt(tokens[2]); + } else if (tokens[0].equals("Radio") && tokens[1].equals("channel:")) { + cmd = Altos.AO_LOG_RADIO_CHANNEL; + a = Integer.parseInt(tokens[2]); + } else if (tokens[0].equals("Callsign:")) { + cmd = Altos.AO_LOG_CALLSIGN; + data = tokens[1].replaceAll("\"",""); + } else if (tokens[0].equals("Accel") && tokens[1].equals("cal")) { + cmd = Altos.AO_LOG_ACCEL_CAL; + a = Integer.parseInt(tokens[3]); + b = Integer.parseInt(tokens[5]); + } else if (tokens[0].equals("Radio") && tokens[1].equals("cal:")) { + cmd = Altos.AO_LOG_RADIO_CAL; + a = Integer.parseInt(tokens[2]); + } else if (tokens[0].equals("Max") && tokens[1].equals("flight") && tokens[2].equals("log:")) { + cmd = Altos.AO_LOG_MAX_FLIGHT_LOG; + a = Integer.parseInt(tokens[3]); + } else if (tokens[0].equals("manufacturer")) { + cmd = Altos.AO_LOG_MANUFACTURER; + data = tokens[1]; + } else if (tokens[0].equals("product")) { + cmd = Altos.AO_LOG_PRODUCT; + data = tokens[1]; + } else if (tokens[0].equals("serial-number")) { + cmd = Altos.AO_LOG_SERIAL_NUMBER; + a = Integer.parseInt(tokens[1]); + } else if (tokens[0].equals("log-format")) { + cmd = Altos.AO_LOG_LOG_FORMAT; + a = Integer.parseInt(tokens[1]); + } else if (tokens[0].equals("software-version")) { + cmd = Altos.AO_LOG_SOFTWARE_VERSION; + data = tokens[1]; + } else if (tokens[0].equals("ms5607")) { + if (tokens[1].equals("reserved:")) { + cmd = Altos.AO_LOG_BARO_RESERVED; + a = Integer.parseInt(tokens[2]); + } else if (tokens[1].equals("sens:")) { + cmd = Altos.AO_LOG_BARO_SENS; + a = Integer.parseInt(tokens[2]); + } else if (tokens[1].equals("off:")) { + cmd = Altos.AO_LOG_BARO_OFF; + a = Integer.parseInt(tokens[2]); + } else if (tokens[1].equals("tcs:")) { + cmd = Altos.AO_LOG_BARO_TCS; + a = Integer.parseInt(tokens[2]); + } else if (tokens[1].equals("tco:")) { + cmd = Altos.AO_LOG_BARO_TCO; + a = Integer.parseInt(tokens[2]); + } else if (tokens[1].equals("tref:")) { + cmd = Altos.AO_LOG_BARO_TREF; + a = Integer.parseInt(tokens[2]); + } else if (tokens[1].equals("tempsens:")) { + cmd = Altos.AO_LOG_BARO_TEMPSENS; + a = Integer.parseInt(tokens[2]); + } else if (tokens[1].equals("crc:")) { + cmd = Altos.AO_LOG_BARO_CRC; + a = Integer.parseInt(tokens[2]); + } else { + cmd = Altos.AO_LOG_INVALID; + data = line; + } + } else { + cmd = Altos.AO_LOG_INVALID; + data = line; + } + } catch (NumberFormatException ne) { + cmd = Altos.AO_LOG_INVALID; + data = line; + } + } + } + + public AltosEepromMega(int in_cmd, int in_tick) { + cmd = in_cmd; + tick = in_tick; + valid = true; + } +} diff --git a/altosui/AltosEepromMegaIterable.java b/altosui/AltosEepromMegaIterable.java new file mode 100644 index 00000000..e2cd2785 --- /dev/null +++ b/altosui/AltosEepromMegaIterable.java @@ -0,0 +1,523 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.awt.*; +import java.awt.event.*; +import javax.swing.*; +import javax.swing.filechooser.FileNameExtensionFilter; +import javax.swing.table.*; +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; + +/* + * AltosRecords with an index field so they can be sorted by tick while preserving + * the original ordering for elements with matching ticks + */ +class AltosOrderedMegaRecord extends AltosEepromMega implements Comparable { + + public int index; + + public AltosOrderedMegaRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid) + throws ParseException { + super(line); + if (prev_tick_valid) { + tick |= (prev_tick & ~0xffff); + if (tick < prev_tick) { + if (prev_tick - tick > 0x8000) + tick += 0x10000; + } else { + if (tick - prev_tick > 0x8000) + tick -= 0x10000; + } + } + index = in_index; + } + + public AltosOrderedMegaRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) { + super(in_cmd, in_tick); + a = in_a; + b = in_b; + index = in_index; + } + + public String toString() { + return String.format("%d.%d %04x %04x %04x", + cmd, index, tick, a, b); + } + + public int compareTo(AltosOrderedMegaRecord o) { + int tick_diff = tick - o.tick; + if (tick_diff != 0) + return tick_diff; + return index - o.index; + } +} + +public class AltosEepromMegaIterable extends AltosRecordIterable { + + static final int seen_flight = 1; + static final int seen_sensor = 2; + static final int seen_temp_volt = 4; + static final int seen_deploy = 8; + static final int seen_gps_time = 16; + static final int seen_gps_lat = 32; + static final int seen_gps_lon = 64; + + static final int seen_basic = seen_flight|seen_sensor; + + boolean has_accel; + boolean has_gps; + boolean has_ignite; + + AltosEepromMega flight_record; + AltosEepromMega gps_date_record; + + TreeSet records; + + AltosMs5607 baro; + + LinkedList list; + + class EepromState { + int seen; + int n_pad_samples; + double ground_pres; + int gps_tick; + int boost_tick; + int sensor_tick; + + EepromState() { + seen = 0; + n_pad_samples = 0; + ground_pres = 0.0; + gps_tick = 0; + } + } + + void update_state(AltosRecord state, AltosEepromMega record, EepromState eeprom) { + state.tick = record.tick; + switch (record.cmd) { + case Altos.AO_LOG_FLIGHT: + eeprom.seen |= seen_flight; + state.ground_accel = record.ground_accel(); + state.flight_accel = record.ground_accel(); + state.ground_pres = baro.set(record.ground_pres(), record.ground_temp()); + state.flight_pres = state.ground_pres; + state.flight = record.data16(0); + eeprom.boost_tick = record.tick; + break; + case Altos.AO_LOG_SENSOR: + state.accel = record.accel(); + state.pres = baro.set(record.pres(), record.temp()); + state.temp = baro.cc; + state.imu = new AltosIMU(); + state.imu.accel_x = record.accel_x(); + state.imu.accel_y = record.accel_y(); + state.imu.accel_z = record.accel_z(); + state.imu.gyro_x = record.gyro_x(); + state.imu.gyro_y = record.gyro_y(); + state.imu.gyro_z = record.gyro_z(); + state.mag = new AltosMag(); + state.mag.x = record.mag_x(); + state.mag.y = record.mag_y(); + state.mag.z = record.mag_z(); + if (state.state < Altos.ao_flight_boost) { + eeprom.n_pad_samples++; + eeprom.ground_pres += state.pres; + state.ground_pres = (int) (eeprom.ground_pres / eeprom.n_pad_samples); + state.flight_pres = state.ground_pres; + } else { + state.flight_pres = (state.flight_pres * 15 + state.pres) / 16; + } + state.flight_accel = (state.flight_accel * 15 + state.accel) / 16; + if ((eeprom.seen & seen_sensor) == 0) + eeprom.sensor_tick = record.tick - 1; + state.flight_vel += (state.accel_plus_g - state.accel) * (record.tick - eeprom.sensor_tick); + eeprom.seen |= seen_sensor; + eeprom.sensor_tick = record.tick; + has_accel = true; + break; + case Altos.AO_LOG_PRESSURE: + state.pres = record.b; + state.flight_pres = state.pres; + if (eeprom.n_pad_samples == 0) { + eeprom.n_pad_samples++; + state.ground_pres = state.pres; + } + eeprom.seen |= seen_sensor; + break; + case Altos.AO_LOG_TEMP_VOLT: + state.batt = record.v_batt(); + eeprom.seen |= seen_temp_volt; + break; + case Altos.AO_LOG_DEPLOY: + state.drogue = record.a; + state.main = record.b; + eeprom.seen |= seen_deploy; + has_ignite = true; + break; + case Altos.AO_LOG_STATE: + state.state = record.state(); + break; + case Altos.AO_LOG_GPS_TIME: + eeprom.gps_tick = state.tick; + AltosGPS old = state.gps; + state.gps = new AltosGPS(); + + /* GPS date doesn't get repeated through the file */ + if (old != null) { + state.gps.year = old.year; + state.gps.month = old.month; + state.gps.day = old.day; + } + state.gps.hour = (record.a & 0xff); + state.gps.minute = (record.a >> 8); + state.gps.second = (record.b & 0xff); + + int flags = (record.b >> 8); + state.gps.connected = (flags & Altos.AO_GPS_RUNNING) != 0; + state.gps.locked = (flags & Altos.AO_GPS_VALID) != 0; + state.gps.nsat = (flags & Altos.AO_GPS_NUM_SAT_MASK) >> + Altos.AO_GPS_NUM_SAT_SHIFT; + state.new_gps = true; + has_gps = true; + break; + case Altos.AO_LOG_GPS_LAT: + int lat32 = record.a | (record.b << 16); + state.gps.lat = (double) lat32 / 1e7; + break; + case Altos.AO_LOG_GPS_LON: + int lon32 = record.a | (record.b << 16); + state.gps.lon = (double) lon32 / 1e7; + break; + case Altos.AO_LOG_GPS_ALT: + state.gps.alt = record.a; + break; + case Altos.AO_LOG_GPS_SAT: + if (state.tick == eeprom.gps_tick) { + int svid = record.a; + int c_n0 = record.b >> 8; + state.gps.add_sat(svid, c_n0); + } + break; + case Altos.AO_LOG_GPS_DATE: + state.gps.year = (record.a & 0xff) + 2000; + state.gps.month = record.a >> 8; + state.gps.day = record.b & 0xff; + break; + + case Altos.AO_LOG_CONFIG_VERSION: + break; + case Altos.AO_LOG_MAIN_DEPLOY: + break; + case Altos.AO_LOG_APOGEE_DELAY: + break; + case Altos.AO_LOG_RADIO_CHANNEL: + break; + case Altos.AO_LOG_CALLSIGN: + state.callsign = record.data; + break; + case Altos.AO_LOG_ACCEL_CAL: + state.accel_plus_g = record.a; + state.accel_minus_g = record.b; + break; + case Altos.AO_LOG_RADIO_CAL: + break; + case Altos.AO_LOG_MANUFACTURER: + break; + case Altos.AO_LOG_PRODUCT: + break; + case Altos.AO_LOG_SERIAL_NUMBER: + state.serial = record.a; + break; + case Altos.AO_LOG_SOFTWARE_VERSION: + break; + case Altos.AO_LOG_BARO_RESERVED: + baro.reserved = record.a; + break; + case Altos.AO_LOG_BARO_SENS: + baro.sens =record.a; + break; + case Altos.AO_LOG_BARO_OFF: + baro.off =record.a; + break; + case Altos.AO_LOG_BARO_TCS: + baro.tcs =record.a; + break; + case Altos.AO_LOG_BARO_TCO: + baro.tco =record.a; + break; + case Altos.AO_LOG_BARO_TREF: + baro.tref =record.a; + break; + case Altos.AO_LOG_BARO_TEMPSENS: + baro.tempsens =record.a; + break; + case Altos.AO_LOG_BARO_CRC: + baro.crc =record.a; + break; + } + state.seen |= eeprom.seen; + } + + LinkedList make_list() { + LinkedList list = new LinkedList(); + Iterator iterator = records.iterator(); + AltosOrderedMegaRecord record = null; + AltosRecord state = new AltosRecord(); + boolean last_reported = false; + EepromState eeprom = new EepromState(); + + state.state = Altos.ao_flight_pad; + state.accel_plus_g = 15758; + state.accel_minus_g = 16294; + + /* Pull in static data from the flight and gps_date records */ + if (flight_record != null) + update_state(state, flight_record, eeprom); + if (gps_date_record != null) + update_state(state, gps_date_record, eeprom); + + while (iterator.hasNext()) { + record = iterator.next(); + if ((eeprom.seen & seen_basic) == seen_basic && record.tick != state.tick) { + AltosRecord r = new AltosRecord(state); + r.time = (r.tick - eeprom.boost_tick) / 100.0; + list.add(r); + } + update_state(state, record, eeprom); + } + AltosRecord r = new AltosRecord(state); + r.time = (r.tick - eeprom.boost_tick) / 100.0; + list.add(r); + return list; + } + + public Iterator iterator() { + if (list == null) + list = make_list(); + return list.iterator(); + } + + public boolean has_gps() { return has_gps; } + public boolean has_accel() { return has_accel; } + public boolean has_ignite() { return has_ignite; } + + public void write_comments(PrintStream out) { + Iterator iterator = records.iterator(); + out.printf("# Comments\n"); + while (iterator.hasNext()) { + AltosOrderedMegaRecord record = iterator.next(); + switch (record.cmd) { + case Altos.AO_LOG_CONFIG_VERSION: + out.printf("# Config version: %s\n", record.data); + break; + case Altos.AO_LOG_MAIN_DEPLOY: + out.printf("# Main deploy: %s\n", record.a); + break; + case Altos.AO_LOG_APOGEE_DELAY: + out.printf("# Apogee delay: %s\n", record.a); + break; + case Altos.AO_LOG_RADIO_CHANNEL: + out.printf("# Radio channel: %s\n", record.a); + break; + case Altos.AO_LOG_CALLSIGN: + out.printf("# Callsign: %s\n", record.data); + break; + case Altos.AO_LOG_ACCEL_CAL: + out.printf ("# Accel cal: %d %d\n", record.a, record.b); + break; + case Altos.AO_LOG_RADIO_CAL: + out.printf ("# Radio cal: %d\n", record.a); + break; + case Altos.AO_LOG_MAX_FLIGHT_LOG: + out.printf ("# Max flight log: %d\n", record.a); + break; + case Altos.AO_LOG_MANUFACTURER: + out.printf ("# Manufacturer: %s\n", record.data); + break; + case Altos.AO_LOG_PRODUCT: + out.printf ("# Product: %s\n", record.data); + break; + case Altos.AO_LOG_SERIAL_NUMBER: + out.printf ("# Serial number: %d\n", record.a); + break; + case Altos.AO_LOG_SOFTWARE_VERSION: + out.printf ("# Software version: %s\n", record.data); + break; + case Altos.AO_LOG_BARO_RESERVED: + out.printf ("# Baro reserved: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_SENS: + out.printf ("# Baro sens: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_OFF: + out.printf ("# Baro off: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TCS: + out.printf ("# Baro tcs: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TCO: + out.printf ("# Baro tco: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TREF: + out.printf ("# Baro tref: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_TEMPSENS: + out.printf ("# Baro tempsens: %d\n", record.a); + break; + case Altos.AO_LOG_BARO_CRC: + out.printf ("# Baro crc: %d\n", record.a); + break; + } + } + } + + /* + * Given an AO_LOG_GPS_TIME record with correct time, and one + * missing time, rewrite the missing time values with the good + * ones, assuming that the difference between them is 'diff' seconds + */ + void update_time(AltosOrderedMegaRecord good, AltosOrderedMegaRecord bad) { + + int diff = (bad.tick - good.tick + 50) / 100; + + int hour = (good.a & 0xff); + int minute = (good.a >> 8); + int second = (good.b & 0xff); + int flags = (good.b >> 8); + int seconds = hour * 3600 + minute * 60 + second; + + /* Make sure this looks like a good GPS value */ + if ((flags & Altos.AO_GPS_NUM_SAT_MASK) >> Altos.AO_GPS_NUM_SAT_SHIFT < 4) + flags = (flags & ~Altos.AO_GPS_NUM_SAT_MASK) | (4 << Altos.AO_GPS_NUM_SAT_SHIFT); + flags |= Altos.AO_GPS_RUNNING; + flags |= Altos.AO_GPS_VALID; + + int new_seconds = seconds + diff; + if (new_seconds < 0) + new_seconds += 24 * 3600; + int new_second = (new_seconds % 60); + int new_minutes = (new_seconds / 60); + int new_minute = (new_minutes % 60); + int new_hours = (new_minutes / 60); + int new_hour = (new_hours % 24); + + bad.a = new_hour + (new_minute << 8); + bad.b = new_second + (flags << 8); + } + + /* + * Read the whole file, dumping records into a RB tree so + * we can enumerate them in time order -- the eeprom data + * are sometimes out of order with GPS data getting timestamps + * matching the first packet out of the GPS unit but not + * written until the final GPS packet has been received. + */ + public AltosEepromMegaIterable (FileInputStream input) { + records = new TreeSet(); + + AltosOrderedMegaRecord last_gps_time = null; + + baro = new AltosMs5607(); + + int index = 0; + int prev_tick = 0; + boolean prev_tick_valid = false; + boolean missing_time = false; + + try { + for (;;) { + String line = AltosRecord.gets(input); + if (line == null) + break; + AltosOrderedMegaRecord record = new AltosOrderedMegaRecord(line, index++, prev_tick, prev_tick_valid); + if (record == null) + break; + if (record.cmd == Altos.AO_LOG_INVALID) + continue; + prev_tick = record.tick; + if (record.cmd < Altos.AO_LOG_CONFIG_VERSION) + prev_tick_valid = true; + if (record.cmd == Altos.AO_LOG_FLIGHT) { + flight_record = record; + continue; + } + + /* Two firmware bugs caused the loss of some GPS data. + * The flight date would never be recorded, and often + * the flight time would get overwritten by another + * record. Detect the loss of the GPS date and fix up the + * missing time records + */ + if (record.cmd == Altos.AO_LOG_GPS_DATE) { + gps_date_record = record; + continue; + } + + /* go back and fix up any missing time values */ + if (record.cmd == Altos.AO_LOG_GPS_TIME) { + last_gps_time = record; + if (missing_time) { + Iterator iterator = records.iterator(); + while (iterator.hasNext()) { + AltosOrderedMegaRecord old = iterator.next(); + if (old.cmd == Altos.AO_LOG_GPS_TIME && + old.a == -1 && old.b == -1) + { + update_time(record, old); + } + } + missing_time = false; + } + } + + if (record.cmd == Altos.AO_LOG_GPS_LAT) { + if (last_gps_time == null || last_gps_time.tick != record.tick) { + AltosOrderedMegaRecord add_gps_time = new AltosOrderedMegaRecord(Altos.AO_LOG_GPS_TIME, + record.tick, + -1, -1, index-1); + if (last_gps_time != null) + update_time(last_gps_time, add_gps_time); + else + missing_time = true; + + records.add(add_gps_time); + record.index = index++; + } + } + records.add(record); + + /* Bail after reading the 'landed' record; we're all done */ + if (record.cmd == Altos.AO_LOG_STATE && + record.a == Altos.ao_flight_landed) + break; + } + } catch (IOException io) { + } catch (ParseException pe) { + } + try { + input.close(); + } catch (IOException ie) { + } + } +} diff --git a/altosui/AltosIMU.java b/altosui/AltosIMU.java new file mode 100644 index 00000000..1f865a65 --- /dev/null +++ b/altosui/AltosIMU.java @@ -0,0 +1,29 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +public class AltosIMU { + int accel_x; + int accel_y; + int accel_z; + + int gyro_x; + int gyro_y; + int gyro_z; +} + \ No newline at end of file diff --git a/altosui/AltosMag.java b/altosui/AltosMag.java new file mode 100644 index 00000000..b3fc542b --- /dev/null +++ b/altosui/AltosMag.java @@ -0,0 +1,25 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +public class AltosMag { + int x; + int y; + int z; +} + \ No newline at end of file diff --git a/altosui/AltosMs5607.java b/altosui/AltosMs5607.java new file mode 100644 index 00000000..6f8bdbbe --- /dev/null +++ b/altosui/AltosMs5607.java @@ -0,0 +1,76 @@ +/* + * Copyright © 2012 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +public class AltosMs5607 { + int reserved; + int sens; + int off; + int tcs; + int tco; + int tref; + int tempsens; + int crc; + + int raw_pres; + int raw_temp; + public int pa; + public int cc; + + void convert() { + int dT; + int TEMP; + long OFF; + long SENS; + int P; + + dT = raw_temp - ((int) tref << 8); + + TEMP = (int) (2000 + (((long) dT * tempsens) >> 23)); + + OFF = ((long) off << 17) + (((long) tco * dT) >> 6); + + SENS = ((long) sens << 16) + (((long) tcs * dT) >> 7); + + if (TEMP < 2000) { + int T2 = (int) (((long) dT * (long) dT) >> 31); + int TEMPM = TEMP - 2000; + long OFF2 = (61 * (long) TEMPM * (long) TEMPM) >> 4; + long SENS2 = 2 * (long) TEMPM * (long) TEMPM; + if (TEMP < 1500) { + int TEMPP = TEMP + 1500; + long TEMPP2 = TEMPP * TEMPP; + OFF2 = OFF2 + 15 * TEMPP2; + SENS2 = SENS2 + 8 * TEMPP2; + } + TEMP -= T2; + OFF -= OFF2; + SENS -= SENS2; + } + + pa = (int) (((((long) raw_pres * SENS) >> 21) - OFF) >> 15); + cc = TEMP; + } + + public int set(int in_pres, int in_temp) { + raw_pres = in_pres; + raw_temp = in_temp; + convert(); + return pa; + } +} diff --git a/altosui/AltosRecord.java b/altosui/AltosRecord.java index 4dfa98be..4643d69a 100644 --- a/altosui/AltosRecord.java +++ b/altosui/AltosRecord.java @@ -67,6 +67,9 @@ public class AltosRecord implements Comparable { AltosGPS gps; boolean new_gps; + AltosIMU imu; + AltosMag mag; + double time; /* seconds since boost */ int device_type; @@ -277,6 +280,8 @@ public class AltosRecord implements Comparable { gps = new AltosGPS(old.gps); new_gps = false; companion = old.companion; + imu = old.imu; + mag = old.mag; } public AltosRecord() { diff --git a/altosui/AltosState.java b/altosui/AltosState.java index da498bc1..9c6f85eb 100644 --- a/altosui/AltosState.java +++ b/altosui/AltosState.java @@ -54,6 +54,9 @@ public class AltosState { AltosGPS gps; + AltosIMU imu; + AltosMag mag; + double pad_lat; double pad_lon; double pad_alt; @@ -107,6 +110,8 @@ public class AltosState { max_acceleration = prev_state.max_acceleration; max_speed = prev_state.max_speed; max_baro_speed = prev_state.max_baro_speed; + imu = prev_state.imu; + mag = prev_state.mag; /* make sure the clock is monotonic */ while (tick < prev_state.tick) diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 6993abab..7d4b2edb 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -365,6 +365,8 @@ public class AltosUI extends AltosFrame { in = new FileInputStream(file); if (filename.endsWith("eeprom")) return new AltosEepromIterable(in); + else if (filename.endsWith("mega")) + return new AltosEepromMegaIterable(in); else return new AltosTelemetryIterable(in); } catch (FileNotFoundException fe) { diff --git a/altosui/Makefile.am b/altosui/Makefile.am index d436c6a0..16b57d40 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -48,6 +48,11 @@ altosui_JAVA = \ AltosEepromIterable.java \ AltosEepromRecord.java \ AltosEepromTeleScience.java \ + AltosEepromMega.java \ + AltosEepromMegaIterable.java \ + AltosMs5607.java \ + AltosIMU.java \ + AltosMag.java \ AltosEepromSelect.java \ AltosFile.java \ AltosFlash.java \ -- cgit v1.2.3 From 3c2f601139d36761de6a8a2210545d082ef16133 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Jan 2012 17:26:59 -0800 Subject: altosui: Complete split out of separate java library Signed-off-by: Keith Packard --- altosui/Altos.java | 1 + altosui/AltosAscent.java | 1 + altosui/AltosBTManage.java | 1 + altosui/AltosCSV.java | 1 + altosui/AltosCSVUI.java | 1 + altosui/AltosChannelMenu.java | 1 + altosui/AltosCompanionInfo.java | 1 + altosui/AltosConfig.java | 1 + altosui/AltosConfigData.java | 1 + altosui/AltosConfigFreqUI.java | 1 + altosui/AltosConfigUI.java | 1 + altosui/AltosConfigureUI.java | 1 + altosui/AltosDataChooser.java | 1 + altosui/AltosDataPointReader.java | 1 + altosui/AltosDebug.java | 1 + altosui/AltosDescent.java | 1 + altosui/AltosDialog.java | 1 + altosui/AltosDisplayThread.java | 1 + altosui/AltosEepromChunk.java | 1 + altosui/AltosEepromDelete.java | 1 + altosui/AltosEepromDownload.java | 1 + altosui/AltosEepromIterable.java | 1 + altosui/AltosEepromList.java | 1 + altosui/AltosEepromLog.java | 1 + altosui/AltosEepromManage.java | 1 + altosui/AltosEepromMonitor.java | 1 + altosui/AltosEepromRecord.java | 1 + altosui/AltosEepromTeleScience.java | 1 + altosui/AltosFile.java | 1 + altosui/AltosFlash.java | 1 + altosui/AltosFlashUI.java | 1 + altosui/AltosFlightInfoTableModel.java | 1 + altosui/AltosFlightReader.java | 1 + altosui/AltosFlightStats.java | 1 + altosui/AltosFlightStatsTable.java | 1 + altosui/AltosFlightStatus.java | 1 + altosui/AltosFlightStatusTableModel.java | 1 + altosui/AltosFlightUI.java | 1 + altosui/AltosFrame.java | 1 + altosui/AltosFreqList.java | 1 + altosui/AltosGraph.java | 1 + altosui/AltosGraphTime.java | 1 + altosui/AltosGraphUI.java | 1 + altosui/AltosGreatCircle.java | 1 + altosui/AltosHexfile.java | 1 + altosui/AltosIdleMonitorUI.java | 1 + altosui/AltosIgnite.java | 1 + altosui/AltosIgniteUI.java | 1 + altosui/AltosInfoTable.java | 1 + altosui/AltosKML.java | 1 + altosui/AltosLanded.java | 1 + altosui/AltosLaunch.java | 1 + altosui/AltosLaunchUI.java | 1 + altosui/AltosLed.java | 1 + altosui/AltosLights.java | 1 + altosui/AltosLog.java | 1 + altosui/AltosPad.java | 1 + altosui/AltosPreferences.java | 383 --------------------- altosui/AltosReader.java | 1 + altosui/AltosReplayReader.java | 1 + altosui/AltosRomconfig.java | 1 + altosui/AltosRomconfigUI.java | 1 + altosui/AltosScanUI.java | 1 + altosui/AltosSerial.java | 1 + altosui/AltosSiteMap.java | 1 + altosui/AltosSiteMapCache.java | 1 + altosui/AltosSiteMapPreload.java | 1 + altosui/AltosSiteMapTile.java | 1 + altosui/AltosState.java | 2 + altosui/AltosTelemetryReader.java | 120 +++++++ altosui/AltosUI.java | 1 + altosui/AltosUIPreferences.java | 23 +- altosui/AltosWriter.java | 2 + altosui/GrabNDrag.java | 1 + altosui/Makefile.am | 53 ++- altosui/altoslib/Makefile.am | 3 +- .../src/org/altusmetrum/AltosLib/AltosConvert.java | 44 +-- .../org/altusmetrum/AltosLib/AltosFrequency.java | 4 +- .../src/org/altusmetrum/AltosLib/AltosGPS.java | 56 +-- .../src/org/altusmetrum/AltosLib/AltosGPSSat.java | 4 +- .../src/org/altusmetrum/AltosLib/AltosParse.java | 14 +- .../org/altusmetrum/AltosLib/AltosPreferences.java | 365 ++++++++++++++++++++ .../src/org/altusmetrum/AltosLib/AltosRecord.java | 128 +++---- .../altusmetrum/AltosLib/AltosRecordCompanion.java | 14 +- .../altusmetrum/AltosLib/AltosTelemetryReader.java | 119 ------- 85 files changed, 734 insertions(+), 669 deletions(-) delete mode 100644 altosui/AltosPreferences.java create mode 100644 altosui/AltosTelemetryReader.java create mode 100644 altosui/altoslib/src/org/altusmetrum/AltosLib/AltosPreferences.java delete mode 100644 altosui/altoslib/src/org/altusmetrum/AltosLib/AltosTelemetryReader.java (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/Altos.java b/altosui/Altos.java index 3e2a7a40..380796cc 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -96,6 +96,7 @@ public class Altos extends AltosLib { static boolean map_initialized = false; static final int tab_elt_pad = 5; + static Font label_font; static Font value_font; static Font status_font; diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index c8e5f3af..38b3b30f 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosAscent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java index 6d460701..d2899d65 100644 --- a/altosui/AltosBTManage.java +++ b/altosui/AltosBTManage.java @@ -29,6 +29,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index db398a61..be86a454 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -21,6 +21,7 @@ import java.lang.*; import java.io.*; import java.text.*; import java.util.*; +import org.altusmetrum.AltosLib.*; public class AltosCSV implements AltosWriter { File name; diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index 6d3e9065..2702668b 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosCSVUI extends AltosDialog diff --git a/altosui/AltosChannelMenu.java b/altosui/AltosChannelMenu.java index abbb86f4..0249a0bd 100644 --- a/altosui/AltosChannelMenu.java +++ b/altosui/AltosChannelMenu.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosChannelMenu extends JComboBox implements ActionListener { int channel; diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 82bde623..4ba8fe98 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosCompanionInfo extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index bd930206..35fef080 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosConfigData.java b/altosui/AltosConfigData.java index 64d9f095..ef34dd3e 100644 --- a/altosui/AltosConfigData.java +++ b/altosui/AltosConfigData.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index ecb55449..7958a21c 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -29,6 +29,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; class AltosEditFreqUI extends AltosDialog implements ActionListener { Frame frame; diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index eddb223f..62394fa6 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -28,6 +28,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index 1789cd25..deb179d6 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -30,6 +30,7 @@ import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; import javax.swing.plaf.basic.*; +import org.altusmetrum.AltosLib.*; class DelegatingRenderer implements ListCellRenderer { diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index c4a46d01..0d629b3c 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -26,6 +26,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.prefs.*; +import org.altusmetrum.AltosLib.*; public class AltosDataChooser extends JFileChooser { JFrame frame; diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index c3aabb0c..821b0771 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -9,6 +9,7 @@ import java.text.ParseException; import java.lang.UnsupportedOperationException; import java.util.NoSuchElementException; import java.util.Iterator; +import org.altusmetrum.AltosLib.*; class AltosDataPointReader implements Iterable { Iterator iter; diff --git a/altosui/AltosDebug.java b/altosui/AltosDebug.java index ce1cf5dd..23e38bc0 100644 --- a/altosui/AltosDebug.java +++ b/altosui/AltosDebug.java @@ -21,6 +21,7 @@ import java.lang.*; import java.io.*; import java.util.concurrent.*; import java.util.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 0fcd690b..664c5ea6 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosDescent extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosDialog.java b/altosui/AltosDialog.java index 1e8e538c..ff38c3e4 100644 --- a/altosui/AltosDialog.java +++ b/altosui/AltosDialog.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index ce8d9159..03ce4efd 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosDisplayThread extends Thread { diff --git a/altosui/AltosEepromChunk.java b/altosui/AltosEepromChunk.java index 77707f7b..e4d11658 100644 --- a/altosui/AltosEepromChunk.java +++ b/altosui/AltosEepromChunk.java @@ -21,6 +21,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosEepromChunk { diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index fcce8155..73f3a00f 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 8f7a8544..080bfc99 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosEepromIterable.java b/altosui/AltosEepromIterable.java index b8e21ece..11cb97e4 100644 --- a/altosui/AltosEepromIterable.java +++ b/altosui/AltosEepromIterable.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; /* * AltosRecords with an index field so they can be sorted by tick while preserving diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index 945746dd..6a656215 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosEepromLog.java b/altosui/AltosEepromLog.java index 475d7f12..a24e82c0 100644 --- a/altosui/AltosEepromLog.java +++ b/altosui/AltosEepromLog.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index 1e06f4ca..563c90b3 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index 34f5b891..75643442 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosEepromMonitor extends AltosDialog { diff --git a/altosui/AltosEepromRecord.java b/altosui/AltosEepromRecord.java index d8a07951..ea003a1e 100644 --- a/altosui/AltosEepromRecord.java +++ b/altosui/AltosEepromRecord.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosEepromTeleScience.java b/altosui/AltosEepromTeleScience.java index ee1840b0..0c237e11 100644 --- a/altosui/AltosEepromTeleScience.java +++ b/altosui/AltosEepromTeleScience.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosEepromTeleScience { int type; diff --git a/altosui/AltosFile.java b/altosui/AltosFile.java index e2b6d5a6..4cf7de3c 100644 --- a/altosui/AltosFile.java +++ b/altosui/AltosFile.java @@ -20,6 +20,7 @@ package altosui; import java.lang.*; import java.io.File; import java.util.*; +import org.altusmetrum.AltosLib.*; class AltosFile extends File { diff --git a/altosui/AltosFlash.java b/altosui/AltosFlash.java index e91e9806..bd0c8a50 100644 --- a/altosui/AltosFlash.java +++ b/altosui/AltosFlash.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosFlash { File file; diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index f91c542d..4ab73a6d 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosFlashUI extends AltosDialog diff --git a/altosui/AltosFlightInfoTableModel.java b/altosui/AltosFlightInfoTableModel.java index e23eff68..77969a89 100644 --- a/altosui/AltosFlightInfoTableModel.java +++ b/altosui/AltosFlightInfoTableModel.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosFlightInfoTableModel extends AbstractTableModel { final static private String[] columnNames = {"Field", "Value"}; diff --git a/altosui/AltosFlightReader.java b/altosui/AltosFlightReader.java index 3ddf171d..1ac9f848 100644 --- a/altosui/AltosFlightReader.java +++ b/altosui/AltosFlightReader.java @@ -21,6 +21,7 @@ import java.lang.*; import java.text.*; import java.io.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosFlightReader { String name; diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java index 578be3f9..ab094c80 100644 --- a/altosui/AltosFlightStats.java +++ b/altosui/AltosFlightStats.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosFlightStats { double max_height; diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index 2d34c6e2..c311b231 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosFlightStatsTable extends JComponent { GridBagLayout layout; diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index 45e55b4b..6a351004 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosFlightStatus extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index 4c24b6ac..75bf16eb 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosFlightStatusTableModel extends AbstractTableModel { private String[] columnNames = {"Height (m)", "State", "RSSI (dBm)", "Speed (m/s)" }; diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 5c6e0629..ddc54cbd 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosFlightUI extends AltosFrame implements AltosFlightDisplay, AltosFontListener { AltosVoice voice; diff --git a/altosui/AltosFrame.java b/altosui/AltosFrame.java index 36ddcae9..70598634 100644 --- a/altosui/AltosFrame.java +++ b/altosui/AltosFrame.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java index e4135df7..1bbc97c6 100644 --- a/altosui/AltosFreqList.java +++ b/altosui/AltosFreqList.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosFreqList extends JComboBox { diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java index fbcefd61..54d2bb0b 100644 --- a/altosui/AltosGraph.java +++ b/altosui/AltosGraph.java @@ -8,6 +8,7 @@ import java.io.*; import org.jfree.chart.JFreeChart; import org.jfree.chart.ChartUtilities; +import org.altusmetrum.AltosLib.*; abstract class AltosGraph { public String filename; diff --git a/altosui/AltosGraphTime.java b/altosui/AltosGraphTime.java index 6a084b2c..0955f6e6 100644 --- a/altosui/AltosGraphTime.java +++ b/altosui/AltosGraphTime.java @@ -12,6 +12,7 @@ import java.text.*; import java.awt.Color; import java.util.ArrayList; import java.util.HashMap; +import org.altusmetrum.AltosLib.*; import org.jfree.chart.ChartUtilities; import org.jfree.chart.JFreeChart; diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index c30dc476..527a7d28 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -12,6 +12,7 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.*; +import org.altusmetrum.AltosLib.*; import org.jfree.chart.ChartPanel; import org.jfree.chart.ChartUtilities; diff --git a/altosui/AltosGreatCircle.java b/altosui/AltosGreatCircle.java index fb1b6ab3..e4af3c18 100644 --- a/altosui/AltosGreatCircle.java +++ b/altosui/AltosGreatCircle.java @@ -18,6 +18,7 @@ package altosui; import java.lang.Math; +import org.altusmetrum.AltosLib.*; public class AltosGreatCircle { double distance; diff --git a/altosui/AltosHexfile.java b/altosui/AltosHexfile.java index 19e35ae1..d52b46c3 100644 --- a/altosui/AltosHexfile.java +++ b/altosui/AltosHexfile.java @@ -23,6 +23,7 @@ import java.util.concurrent.LinkedBlockingQueue; import java.util.LinkedList; import java.util.Iterator; import java.util.Arrays; +import org.altusmetrum.AltosLib.*; class HexFileInputStream extends PushbackInputStream { public int line; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 8eb0d520..02295ea9 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; class AltosADC { int tick; diff --git a/altosui/AltosIgnite.java b/altosui/AltosIgnite.java index 3e52ea36..c0cd44f1 100644 --- a/altosui/AltosIgnite.java +++ b/altosui/AltosIgnite.java @@ -25,6 +25,7 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.*; import javax.swing.event.*; +import org.altusmetrum.AltosLib.*; public class AltosIgnite { AltosDevice device; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 8623cbef..076d99b2 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -28,6 +28,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosIgniteUI extends AltosDialog diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index c023369e..aa6a6d4e 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosInfoTable extends JTable { private AltosFlightInfoTableModel model; diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java index 6bdbecca..2993607b 100644 --- a/altosui/AltosKML.java +++ b/altosui/AltosKML.java @@ -21,6 +21,7 @@ import java.lang.*; import java.io.*; import java.text.*; import java.util.*; +import org.altusmetrum.AltosLib.*; public class AltosKML implements AltosWriter { diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 4dd9a2dd..a47e1cbd 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosLanded extends JComponent implements AltosFlightDisplay, ActionListener { GridBagLayout layout; diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java index 77f681b8..0e493b91 100644 --- a/altosui/AltosLaunch.java +++ b/altosui/AltosLaunch.java @@ -25,6 +25,7 @@ import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.*; import javax.swing.event.*; +import org.altusmetrum.AltosLib.*; public class AltosLaunch { AltosDevice device; diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index a6c36604..eb76243d 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -28,6 +28,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; class FireButton extends JButton { protected void processMouseEvent(MouseEvent e) { diff --git a/altosui/AltosLed.java b/altosui/AltosLed.java index e08e9960..1358cd48 100644 --- a/altosui/AltosLed.java +++ b/altosui/AltosLed.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosLed extends JLabel { ImageIcon on, off; diff --git a/altosui/AltosLights.java b/altosui/AltosLights.java index 2fa38412..8bd9e7de 100644 --- a/altosui/AltosLights.java +++ b/altosui/AltosLights.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosLights extends JComponent { diff --git a/altosui/AltosLog.java b/altosui/AltosLog.java index a5f1830d..740f0be6 100644 --- a/altosui/AltosLog.java +++ b/altosui/AltosLog.java @@ -22,6 +22,7 @@ import java.lang.*; import java.util.*; import java.text.ParseException; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; /* * This creates a thread to capture telemetry data and write it to diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 6ef66f7a..0a3f3d65 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; public class AltosPad extends JComponent implements AltosFlightDisplay { GridBagLayout layout; diff --git a/altosui/AltosPreferences.java b/altosui/AltosPreferences.java deleted file mode 100644 index 7510c7c2..00000000 --- a/altosui/AltosPreferences.java +++ /dev/null @@ -1,383 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package altosui; -import java.io.*; -import java.util.*; -import java.text.*; -import java.util.prefs.*; -import java.util.concurrent.LinkedBlockingQueue; -import java.awt.Component; -import javax.swing.*; -import javax.swing.filechooser.FileSystemView; - -class AltosPreferences { - public static Preferences preferences; - - /* logdir preference name */ - final static String logdirPreference = "LOGDIR"; - - /* channel preference name */ - final static String channelPreferenceFormat = "CHANNEL-%d"; - - /* frequency preference name */ - final static String frequencyPreferenceFormat = "FREQUENCY-%d"; - - /* telemetry format preference name */ - final static String telemetryPreferenceFormat = "TELEMETRY-%d"; - - /* voice preference name */ - final static String voicePreference = "VOICE"; - - /* callsign preference name */ - final static String callsignPreference = "CALLSIGN"; - - /* firmware directory preference name */ - final static String firmwaredirPreference = "FIRMWARE"; - - /* serial debug preference name */ - final static String serialDebugPreference = "SERIAL-DEBUG"; - - /* scanning telemetry preferences name */ - final static String scanningTelemetryPreference = "SCANNING-TELEMETRY"; - - /* Launcher serial preference name */ - final static String launcherSerialPreference = "LAUNCHER-SERIAL"; - - /* Launcher channel preference name */ - final static String launcherChannelPreference = "LAUNCHER-CHANNEL"; - - /* Default logdir is ~/TeleMetrum */ - final static String logdirName = "TeleMetrum"; - - /* Log directory */ - static File logdir; - - /* Map directory -- hangs of logdir */ - static File mapdir; - - /* Frequency (map serial to frequency) */ - static Hashtable frequencies; - - /* Telemetry (map serial to telemetry format) */ - static Hashtable telemetries; - - /* Voice preference */ - static boolean voice; - - /* Callsign preference */ - static String callsign; - - /* Firmware directory */ - static File firmwaredir; - - /* Serial debug */ - static boolean serial_debug; - - /* Scanning telemetry */ - static int scanning_telemetry; - - /* List of frequencies */ - final static String common_frequencies_node_name = "COMMON-FREQUENCIES"; - static AltosFrequency[] common_frequencies; - - final static String frequency_count = "COUNT"; - final static String frequency_format = "FREQUENCY-%d"; - final static String description_format = "DESCRIPTION-%d"; - - static AltosFrequency[] load_common_frequencies() { - AltosFrequency[] frequencies = null; - boolean existing = false; - try { - existing = preferences.nodeExists(common_frequencies_node_name); - } catch (BackingStoreException be) { - existing = false; - } - if (existing) { - Preferences node = preferences.node(common_frequencies_node_name); - int count = node.getInt(frequency_count, 0); - - frequencies = new AltosFrequency[count]; - for (int i = 0; i < count; i++) { - double frequency; - String description; - - frequency = node.getDouble(String.format(frequency_format, i), 0.0); - description = node.get(String.format(description_format, i), null); - frequencies[i] = new AltosFrequency(frequency, description); - } - } else { - frequencies = new AltosFrequency[10]; - for (int i = 0; i < 10; i++) { - frequencies[i] = new AltosFrequency(434.550 + i * .1, - String.format("Channel %d", i)); - } - } - return frequencies; - } - - static void save_common_frequencies(AltosFrequency[] frequencies) { - Preferences node = preferences.node(common_frequencies_node_name); - - node.putInt(frequency_count, frequencies.length); - for (int i = 0; i < frequencies.length; i++) { - node.putDouble(String.format(frequency_format, i), frequencies[i].frequency); - node.put(String.format(description_format, i), frequencies[i].description); - } - } - static int launcher_serial; - - static int launcher_channel; - - public static void init() { - preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); - - /* Initialize logdir from preferences */ - String logdir_string = preferences.get(logdirPreference, null); - if (logdir_string != null) - logdir = new File(logdir_string); - else { - /* Use the file system view default directory */ - logdir = new File(FileSystemView.getFileSystemView().getDefaultDirectory(), logdirName); - if (!logdir.exists()) - logdir.mkdirs(); - } - mapdir = new File(logdir, "maps"); - if (!mapdir.exists()) - mapdir.mkdirs(); - - frequencies = new Hashtable(); - - telemetries = new Hashtable(); - - voice = preferences.getBoolean(voicePreference, true); - - callsign = preferences.get(callsignPreference,"N0CALL"); - - scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << Altos.ao_telemetry_standard)); - - launcher_serial = preferences.getInt(launcherSerialPreference, 0); - - launcher_channel = preferences.getInt(launcherChannelPreference, 0); - - String firmwaredir_string = preferences.get(firmwaredirPreference, null); - if (firmwaredir_string != null) - firmwaredir = new File(firmwaredir_string); - else - firmwaredir = null; - - serial_debug = preferences.getBoolean(serialDebugPreference, false); - AltosSerial.set_debug(serial_debug); - - common_frequencies = load_common_frequencies(); - - } - - static { init(); } - - static void flush_preferences() { - try { - preferences.flush(); - } catch (BackingStoreException ee) { -/* - if (component != null) - JOptionPane.showMessageDialog(component, - preferences.absolutePath(), - "Cannot save prefernces", - JOptionPane.ERROR_MESSAGE); - else -*/ - System.err.printf("Cannot save preferences\n"); - } - } - - public static void set_logdir(File new_logdir) { - logdir = new_logdir; - mapdir = new File(logdir, "maps"); - if (!mapdir.exists()) - mapdir.mkdirs(); - synchronized (preferences) { - preferences.put(logdirPreference, logdir.getPath()); - flush_preferences(); - } - } - - public static File logdir() { - return logdir; - } - - public static File mapdir() { - return mapdir; - } - - public static void set_frequency(int serial, double new_frequency) { - frequencies.put(serial, new_frequency); - synchronized (preferences) { - preferences.putDouble(String.format(frequencyPreferenceFormat, serial), new_frequency); - flush_preferences(); - } - } - - public static double frequency(int serial) { - if (frequencies.containsKey(serial)) - return frequencies.get(serial); - double frequency = preferences.getDouble(String.format(frequencyPreferenceFormat, serial), 0); - if (frequency == 0.0) { - int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0); - frequency = AltosConvert.radio_channel_to_frequency(channel); - } - frequencies.put(serial, frequency); - return frequency; - } - - public static void set_telemetry(int serial, int new_telemetry) { - telemetries.put(serial, new_telemetry); - synchronized (preferences) { - preferences.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry); - flush_preferences(); - } - } - - public static int telemetry(int serial) { - if (telemetries.containsKey(serial)) - return telemetries.get(serial); - int telemetry = preferences.getInt(String.format(telemetryPreferenceFormat, serial), - Altos.ao_telemetry_standard); - telemetries.put(serial, telemetry); - return telemetry; - } - - public static void set_scanning_telemetry(int new_scanning_telemetry) { - scanning_telemetry = new_scanning_telemetry; - synchronized (preferences) { - preferences.putInt(scanningTelemetryPreference, scanning_telemetry); - flush_preferences(); - } - } - - public static int scanning_telemetry() { - return scanning_telemetry; - } - - public static void set_voice(boolean new_voice) { - voice = new_voice; - synchronized (preferences) { - preferences.putBoolean(voicePreference, voice); - flush_preferences(); - } - } - - public static boolean voice() { - return voice; - } - - public static void set_callsign(String new_callsign) { - callsign = new_callsign; - synchronized(preferences) { - preferences.put(callsignPreference, callsign); - flush_preferences(); - } - } - - public static String callsign() { - return callsign; - } - - public static void set_firmwaredir(File new_firmwaredir) { - firmwaredir = new_firmwaredir; - synchronized (preferences) { - preferences.put(firmwaredirPreference, firmwaredir.getPath()); - flush_preferences(); - } - } - - public static File firmwaredir() { - return firmwaredir; - } - - public static void set_serial_debug(boolean new_serial_debug) { - serial_debug = new_serial_debug; - AltosSerial.set_debug(serial_debug); - synchronized (preferences) { - preferences.putBoolean(serialDebugPreference, serial_debug); - flush_preferences(); - } - } - - public static boolean serial_debug() { - return serial_debug; - } - - public static void set_launcher_serial(int new_launcher_serial) { - launcher_serial = new_launcher_serial; - System.out.printf("set launcher serial to %d\n", new_launcher_serial); - synchronized (preferences) { - preferences.putInt(launcherSerialPreference, launcher_serial); - flush_preferences(); - } - } - - public static int launcher_serial() { - return launcher_serial; - } - - public static void set_launcher_channel(int new_launcher_channel) { - launcher_channel = new_launcher_channel; - System.out.printf("set launcher channel to %d\n", new_launcher_channel); - synchronized (preferences) { - preferences.putInt(launcherChannelPreference, launcher_channel); - flush_preferences(); - } - } - - public static int launcher_channel() { - return launcher_channel; - } - - public static Preferences bt_devices() { - return preferences.node("bt_devices"); - } - - public static AltosFrequency[] common_frequencies() { - return common_frequencies; - } - - public static void set_common_frequencies(AltosFrequency[] frequencies) { - common_frequencies = frequencies; - synchronized(preferences) { - save_common_frequencies(frequencies); - flush_preferences(); - } - } - - public static void add_common_frequency(AltosFrequency frequency) { - AltosFrequency[] new_frequencies = new AltosFrequency[common_frequencies.length + 1]; - int i; - - for (i = 0; i < common_frequencies.length; i++) { - if (frequency.frequency == common_frequencies[i].frequency) - return; - if (frequency.frequency < common_frequencies[i].frequency) - break; - new_frequencies[i] = common_frequencies[i]; - } - new_frequencies[i] = frequency; - for (; i < common_frequencies.length; i++) - new_frequencies[i+1] = common_frequencies[i]; - set_common_frequencies(new_frequencies); - } -} diff --git a/altosui/AltosReader.java b/altosui/AltosReader.java index b9280a0c..aafd5f81 100644 --- a/altosui/AltosReader.java +++ b/altosui/AltosReader.java @@ -20,6 +20,7 @@ package altosui; import java.io.*; import java.util.*; import java.text.*; +import org.altusmetrum.AltosLib.*; public class AltosReader { public AltosRecord read() throws IOException, ParseException { return null; } diff --git a/altosui/AltosReplayReader.java b/altosui/AltosReplayReader.java index eed56cff..f92c0328 100644 --- a/altosui/AltosReplayReader.java +++ b/altosui/AltosReplayReader.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.LinkedBlockingQueue; +import org.altusmetrum.AltosLib.*; /* * Open an existing telemetry file and replay it in realtime diff --git a/altosui/AltosRomconfig.java b/altosui/AltosRomconfig.java index 55056b5e..0a283e51 100644 --- a/altosui/AltosRomconfig.java +++ b/altosui/AltosRomconfig.java @@ -17,6 +17,7 @@ package altosui; import java.io.*; +import org.altusmetrum.AltosLib.*; public class AltosRomconfig { public boolean valid; diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java index e4e38c9c..306b8623 100644 --- a/altosui/AltosRomconfigUI.java +++ b/altosui/AltosRomconfigUI.java @@ -27,6 +27,7 @@ import java.io.*; import java.util.*; import java.text.*; import java.util.prefs.*; +import org.altusmetrum.AltosLib.*; public class AltosRomconfigUI extends AltosDialog diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 2b9137d8..1be8aa26 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -28,6 +28,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; class AltosScanResult { String callsign; diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index afb9f21a..74e945f3 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -31,6 +31,7 @@ import java.awt.event.*; import javax.swing.*; import javax.swing.filechooser.FileNameExtensionFilter; import javax.swing.table.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 93c54d02..b57edcab 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -32,6 +32,7 @@ import java.lang.Math; import java.awt.geom.Point2D; import java.awt.geom.Line2D; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; public class AltosSiteMap extends JScrollPane implements AltosFlightDisplay { // preferred vertical step in a tile in naut. miles diff --git a/altosui/AltosSiteMapCache.java b/altosui/AltosSiteMapCache.java index 2e62cc45..f729a298 100644 --- a/altosui/AltosSiteMapCache.java +++ b/altosui/AltosSiteMapCache.java @@ -29,6 +29,7 @@ import java.text.*; import java.util.prefs.*; import java.net.URL; import java.net.URLConnection; +import org.altusmetrum.AltosLib.*; public class AltosSiteMapCache extends JLabel { public static boolean fetchMap(File file, String url) { diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java index 5de7a05e..676b0790 100644 --- a/altosui/AltosSiteMapPreload.java +++ b/altosui/AltosSiteMapPreload.java @@ -33,6 +33,7 @@ import java.awt.geom.Point2D; import java.awt.geom.Line2D; import java.net.URL; import java.net.URLConnection; +import org.altusmetrum.AltosLib.*; class AltosMapPos extends Box { AltosUI owner; diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java index 9e62bb47..34550219 100644 --- a/altosui/AltosSiteMapTile.java +++ b/altosui/AltosSiteMapTile.java @@ -30,6 +30,7 @@ import java.util.prefs.*; import java.lang.Math; import java.awt.geom.Point2D; import java.awt.geom.Line2D; +import org.altusmetrum.AltosLib.*; public class AltosSiteMapTile extends JLayeredPane { JLabel mapLabel; diff --git a/altosui/AltosState.java b/altosui/AltosState.java index 9c6f85eb..403c74be 100644 --- a/altosui/AltosState.java +++ b/altosui/AltosState.java @@ -21,6 +21,8 @@ package altosui; +import org.altusmetrum.AltosLib.*; + public class AltosState { AltosRecord data; diff --git a/altosui/AltosTelemetryReader.java b/altosui/AltosTelemetryReader.java new file mode 100644 index 00000000..dc7e4a75 --- /dev/null +++ b/altosui/AltosTelemetryReader.java @@ -0,0 +1,120 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package altosui; + +import java.lang.*; +import java.text.*; +import java.io.*; +import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; + +class AltosTelemetryReader extends AltosFlightReader { + AltosDevice device; + AltosSerial serial; + AltosLog log; + AltosRecord previous; + double frequency; + int telemetry; + + LinkedBlockingQueue telem; + + AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException { + AltosLine l = telem.take(); + if (l.line == null) + throw new IOException("IO error"); + AltosRecord next = AltosTelemetry.parse(l.line, previous); + previous = next; + return next; + } + + void flush() { + telem.clear(); + } + + void close(boolean interrupted) { + serial.remove_monitor(telem); + log.close(); + serial.close(); + } + + public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException { + frequency = in_frequency; + serial.set_radio_frequency(frequency); + } + + public boolean supports_telemetry(int telemetry) { + + try { + /* Version 1.0 or later firmware supports all telemetry formats */ + if (serial.config_data().compare_version("1.0") >= 0) + return true; + + /* Version 0.9 firmware only supports 0.9 telemetry */ + if (serial.config_data().compare_version("0.9") >= 0) { + if (telemetry == Altos.ao_telemetry_0_9) + return true; + else + return false; + } + + /* Version 0.8 firmware only supports 0.8 telemetry */ + if (telemetry == Altos.ao_telemetry_0_8) + return true; + else + return false; + } catch (InterruptedException ie) { + return true; + } catch (TimeoutException te) { + return true; + } + } + + void save_frequency() { + AltosPreferences.set_frequency(device.getSerial(), frequency); + } + + void set_telemetry(int in_telemetry) { + telemetry = in_telemetry; + serial.set_telemetry(telemetry); + } + + void save_telemetry() { + AltosPreferences.set_telemetry(device.getSerial(), telemetry); + } + + File backing_file() { + return log.file(); + } + + public AltosTelemetryReader (AltosDevice in_device) + throws FileNotFoundException, AltosSerialInUseException, IOException, InterruptedException, TimeoutException { + device = in_device; + serial = new AltosSerial(device); + log = new AltosLog(serial); + name = device.toShortString(); + previous = null; + + telem = new LinkedBlockingQueue(); + frequency = AltosPreferences.frequency(device.getSerial()); + set_frequency(frequency); + telemetry = AltosPreferences.telemetry(device.getSerial()); + set_telemetry(telemetry); + serial.set_callsign(AltosUIPreferences.callsign()); + serial.add_monitor(telem); + } +} diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index a2816a3a..25c6c36b 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -27,6 +27,7 @@ import java.util.*; import java.text.*; import java.util.prefs.*; import java.util.concurrent.*; +import org.altusmetrum.AltosLib.*; import libaltosJNI.*; diff --git a/altosui/AltosUIPreferences.java b/altosui/AltosUIPreferences.java index da6c3968..38af734e 100644 --- a/altosui/AltosUIPreferences.java +++ b/altosui/AltosUIPreferences.java @@ -25,10 +25,9 @@ import java.util.concurrent.LinkedBlockingQueue; import java.awt.Component; import javax.swing.*; import javax.swing.filechooser.FileSystemView; +import org.altusmetrum.AltosLib.*; -/* import org.altusmetrum.AltosLib.*; */ - -class AltosUIPreferences extends AltosPreferences { +public class AltosUIPreferences extends AltosPreferences { /* font size preferences name */ final static String fontSizePreference = "FONT-SIZE"; @@ -47,6 +46,9 @@ class AltosUIPreferences extends AltosPreferences { static String look_and_feel = null; + /* Serial debug */ + static boolean serial_debug; + public static void init() { font_listeners = new LinkedList(); @@ -55,6 +57,8 @@ class AltosUIPreferences extends AltosPreferences { look_and_feel = preferences.get(lookAndFeelPreference, UIManager.getSystemLookAndFeelClassName()); ui_listeners = new LinkedList(); + serial_debug = preferences.getBoolean(serialDebugPreference, false); + AltosSerial.set_debug(serial_debug); } static { init(); } @@ -156,4 +160,17 @@ class AltosUIPreferences extends AltosPreferences { ui_listeners.remove(l); } } + public static void set_serial_debug(boolean new_serial_debug) { + serial_debug = new_serial_debug; + AltosSerial.set_debug(serial_debug); + synchronized (preferences) { + preferences.putBoolean(serialDebugPreference, serial_debug); + flush_preferences(); + } + } + + public static boolean serial_debug() { + return serial_debug; + } + } \ No newline at end of file diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java index a172dff0..b7375204 100644 --- a/altosui/AltosWriter.java +++ b/altosui/AltosWriter.java @@ -21,6 +21,8 @@ import java.lang.*; import java.io.*; import java.text.*; import java.util.*; +import org.altusmetrum.AltosLib.*; + public interface AltosWriter { diff --git a/altosui/GrabNDrag.java b/altosui/GrabNDrag.java index e6b87b58..c350efec 100644 --- a/altosui/GrabNDrag.java +++ b/altosui/GrabNDrag.java @@ -27,6 +27,7 @@ import javax.swing.table.*; import java.io.*; import java.util.*; import java.text.*; +import org.altusmetrum.AltosLib.*; class GrabNDrag extends MouseInputAdapter { private JComponent scroll; diff --git a/altosui/Makefile.am b/altosui/Makefile.am index c3fd6bb6..cfe45302 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -6,7 +6,7 @@ man_MANS=altosui.1 altoslibdir=$(libdir)/altos -CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:libaltos:$(FREETTS)/*:/usr/share/java/*" +CLASSPATH_ENV=mkdir -p $(JAVAROOT); CLASSPATH=".:classes:altoslib/bin:libaltos:$(FREETTS)/*:/usr/share/java/*" bin_SCRIPTS=altosui @@ -66,10 +66,7 @@ altosui_JAVA = \ AltosFlightStatusUpdate.java \ AltosFlightUI.java \ AltosFontListener.java \ - AltosFrequency.java \ AltosFreqList.java \ - AltosGPS.java \ - AltosGPSSat.java \ AltosGreatCircle.java \ AltosHexfile.java \ Altos.java \ @@ -83,27 +80,11 @@ altosui_JAVA = \ AltosLanded.java \ AltosLed.java \ AltosLights.java \ - AltosLine.java \ AltosLog.java \ AltosPad.java \ - AltosParse.java \ - AltosUIPreferences.java \ - AltosPreferences.java \ AltosUIPreferences.java \ AltosReader.java \ - AltosRecord.java \ - AltosRecordCompanion.java \ - AltosRecordIterable.java \ AltosTelemetryReader.java \ - AltosTelemetryRecord.java \ - AltosTelemetryRecordRaw.java \ - AltosTelemetryRecordSensor.java \ - AltosTelemetryRecordConfiguration.java \ - AltosTelemetryRecordLocation.java \ - AltosTelemetryRecordSatellite.java \ - AltosTelemetryRecordCompanion.java \ - AltosTelemetryRecordLegacy.java \ - AltosTelemetryMap.java \ AltosReplayReader.java \ AltosRomconfig.java \ AltosRomconfigUI.java \ @@ -116,8 +97,7 @@ altosui_JAVA = \ AltosSiteMapCache.java \ AltosSiteMapTile.java \ AltosState.java \ - AltosTelemetry.java \ - AltosTelemetryIterable.java \ + AltosTelemetryReader.java \ AltosUI.java \ AltosUIListener.java \ AltosFrame.java \ @@ -148,6 +128,9 @@ FREETTS_CLASS= \ en_us.jar \ freetts.jar +ALTOSLIB_CLASS=\ + AltosLib.jar + LIBALTOS= \ libaltos.so \ libaltos.dylib \ @@ -200,7 +183,7 @@ LINUX_DIST=Altos-Linux-$(VERSION).tar.bz2 MACOSX_DIST=Altos-Mac-$(VERSION).zip WINDOWS_DIST=Altos-Windows-$(VERSION_DASH).exe -FAT_FILES=$(FATJAR) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) +FAT_FILES=$(FATJAR) $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) LINUX_FILES=$(FAT_FILES) libaltos.so $(FIRMWARE) $(DOC) LINUX_EXTRA=altosui-fat @@ -214,7 +197,7 @@ all-local: classes/altosui $(JAR) altosui altosui-test altosui-jdb clean-local: -rm -rf classes $(JAR) $(FATJAR) \ - $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(FREETTS_CLASS) \ + $(LINUX_DIST) $(MACOSX_DIST) windows $(WINDOWS_DIST) $(ALTOSLIB_CLASS) $(FREETTS_CLASS) \ $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) Manifest.txt Manifest-fat.txt altos-windows.log \ altosui altosui-test altosui-jdb macosx linux @@ -256,13 +239,13 @@ install-altosuiJAVA: altosui.jar classes/altosui: mkdir -p classes/altosui -$(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICON) +$(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICON) $(ALTOSLIB_CLASS) jar cfm $@ Manifest.txt \ $(ICONJAR) \ -C classes altosui \ -C libaltos libaltosJNI -$(FATJAR): classaltosui.stamp Manifest-fat.txt $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICON) +$(FATJAR): classaltosui.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICON) jar cfm $@ Manifest-fat.txt \ $(ICONJAR) \ -C classes altosui \ @@ -270,11 +253,11 @@ $(FATJAR): classaltosui.stamp Manifest-fat.txt $(FREETTS_CLASS) $(JFREECHART_CLA Manifest.txt: Makefile echo 'Main-Class: altosui.AltosUI' > $@ - echo "Class-Path: $(FREETTS)/freetts.jar $(JFREECHART)/jfreechart.jar $(JCOMMON)/jcommon.jar" >> $@ + echo "Class-Path: altoslib.jar $(FREETTS)/freetts.jar $(JFREECHART)/jfreechart.jar $(JCOMMON)/jcommon.jar" >> $@ Manifest-fat.txt: echo 'Main-Class: altosui.AltosUI' > $@ - echo "Class-Path: freetts.jar jfreechart.jar jcommon.jar" >> $@ + echo "Class-Path: altoslib.jar freetts.jar jfreechart.jar jcommon.jar" >> $@ altosui: Makefile echo "#!/bin/sh" > $@ @@ -283,7 +266,7 @@ altosui: Makefile altosui-test: Makefile echo "#!/bin/sh" > $@ - echo 'exec java -cp "$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar altosui.jar "$$@"' >> $@ + echo 'exec java -cp ":altoslib/*:$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar altosui.jar "$$@"' >> $@ chmod +x $@ altosui-jdb: Makefile @@ -317,6 +300,10 @@ build-altos-dll: build-altos64-dll: +cd libaltos && make altos64.dll +$(ALTOSLIB_CLASS): + -rm -f "$@" + $(LN_S) altoslib/"$@" . + $(FREETTS_CLASS): -rm -f "$@" $(LN_S) "$(FREETTS)"/"$@" . @@ -345,9 +332,11 @@ $(MACOSX_DIST): $(MACOSX_FILES) $(MACOSX_EXTRA) cp -a AltosUI.app macosx/ mkdir -p macosx/AltOS macosx/AltosUI.app/Contents/Resources/Java cp -p $(FATJAR) macosx/AltosUI.app/Contents/Resources/Java/altosui.jar - cp -p $(FREETTS_CLASS) libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java - cp -p $(JFREECHART_CLASS) libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java - cp -p $(JCOMMON_CLASS) libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java + cp -p libaltos.dylib macosx/AltosUI.app/Contents/Resources/Java + cp -p $(ALTOSLIB_CLASS) macosx/AltosUI.app/Contents/Resources/Java + cp -p $(FREETTS_CLASS) macosx/AltosUI.app/Contents/Resources/Java + cp -p $(JFREECHART_CLASS) macosx/AltosUI.app/Contents/Resources/Java + cp -p $(JCOMMON_CLASS) macosx/AltosUI.app/Contents/Resources/Java cp -p $(MACOSX_EXTRA) macosx/AltOS cd macosx && zip -r ../$@ AltosUI.app AltOS diff --git a/altosui/altoslib/Makefile.am b/altosui/altoslib/Makefile.am index 9c655131..967c8d06 100644 --- a/altosui/altoslib/Makefile.am +++ b/altosui/altoslib/Makefile.am @@ -18,11 +18,12 @@ AltosLib_JAVA = \ $(SRC)/AltosGPSSat.java \ $(SRC)/AltosLine.java \ $(SRC)/AltosParse.java \ + $(SRC)/AltosPreferences.java \ $(SRC)/AltosRecordCompanion.java \ $(SRC)/AltosRecordIterable.java \ $(SRC)/AltosRecord.java \ - $(SRC)/AltosTelemetryIterable.java \ $(SRC)/AltosTelemetry.java \ + $(SRC)/AltosTelemetryIterable.java \ $(SRC)/AltosTelemetryMap.java \ $(SRC)/AltosTelemetryRecordCompanion.java \ $(SRC)/AltosTelemetryRecordConfiguration.java \ diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConvert.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConvert.java index 6773ab7e..3527b575 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConvert.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosConvert.java @@ -41,27 +41,27 @@ public class AltosConvert { * in Joules/(kilogram-Kelvin). */ - static final double GRAVITATIONAL_ACCELERATION = -9.80665; - static final double AIR_GAS_CONSTANT = 287.053; - static final double NUMBER_OF_LAYERS = 7; - static final double MAXIMUM_ALTITUDE = 84852.0; - static final double MINIMUM_PRESSURE = 0.3734; - static final double LAYER0_BASE_TEMPERATURE = 288.15; - static final double LAYER0_BASE_PRESSURE = 101325; + public static final double GRAVITATIONAL_ACCELERATION = -9.80665; + public static final double AIR_GAS_CONSTANT = 287.053; + public static final double NUMBER_OF_LAYERS = 7; + public static final double MAXIMUM_ALTITUDE = 84852.0; + public static final double MINIMUM_PRESSURE = 0.3734; + public static final double LAYER0_BASE_TEMPERATURE = 288.15; + public static final double LAYER0_BASE_PRESSURE = 101325; /* lapse rate and base altitude for each layer in the atmosphere */ - static final double[] lapse_rate = { + public static final double[] lapse_rate = { -0.0065, 0.0, 0.001, 0.0028, 0.0, -0.0028, -0.002 }; - static final int[] base_altitude = { + public static final int[] base_altitude = { 0, 11000, 20000, 32000, 47000, 51000, 71000 }; /* outputs atmospheric pressure associated with the given altitude. * altitudes are measured with respect to the mean sea level */ - static double + public static double altitude_to_pressure(double altitude) { double base_temperature = LAYER0_BASE_TEMPERATURE; @@ -114,7 +114,7 @@ public class AltosConvert { /* outputs the altitude associated with the given pressure. the altitude returned is measured with respect to the mean sea level */ - static double + public static double pressure_to_altitude(double pressure) { @@ -178,19 +178,19 @@ public class AltosConvert { return altitude; } - static double + public static double cc_battery_to_voltage(double battery) { return battery / 32767.0 * 5.0; } - static double + public static double cc_ignitor_to_voltage(double ignite) { return ignite / 32767 * 15.0; } - static double radio_to_frequency(int freq, int setting, int cal, int channel) { + public static double radio_to_frequency(int freq, int setting, int cal, int channel) { double f; if (freq > 0) @@ -205,13 +205,13 @@ public class AltosConvert { return f + channel * 0.100; } - static int radio_frequency_to_setting(double frequency, int cal) { + public static int radio_frequency_to_setting(double frequency, int cal) { double set = frequency / 434.550 * cal; return (int) Math.floor (set + 0.5); } - static int radio_frequency_to_channel(double frequency) { + public static int radio_frequency_to_channel(double frequency) { int channel = (int) Math.floor ((frequency - 434.550) / 0.100 + 0.5); if (channel < 0) @@ -221,11 +221,11 @@ public class AltosConvert { return channel; } - static double radio_channel_to_frequency(int channel) { + public static double radio_channel_to_frequency(int channel) { return 434.550 + channel * 0.100; } - static int[] ParseHex(String line) { + public static int[] ParseHex(String line) { String[] tokens = line.split("\\s+"); int[] array = new int[tokens.length]; @@ -238,19 +238,19 @@ public class AltosConvert { return array; } - static double meters_to_feet(double meters) { + public static double meters_to_feet(double meters) { return meters * (100 / (2.54 * 12)); } - static double meters_to_mach(double meters) { + public static double meters_to_mach(double meters) { return meters / 343; /* something close to mach at usual rocket sites */ } - static double meters_to_g(double meters) { + public static double meters_to_g(double meters) { return meters / 9.80665; } - static int checksum(int[] data, int start, int length) { + public static int checksum(int[] data, int start, int length) { int csum = 0x5a; for (int i = 0; i < length; i++) csum += data[i + start]; diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosFrequency.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosFrequency.java index 6fd26dfd..f08ff116 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosFrequency.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosFrequency.java @@ -22,8 +22,8 @@ import java.util.*; import java.text.*; public class AltosFrequency { - double frequency; - String description; + public double frequency; + public String description; public String toString() { return String.format("%7.3f MHz %-20s", diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPS.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPS.java index 8cc7aa69..f078a469 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPS.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPS.java @@ -22,32 +22,32 @@ import java.text.*; public class AltosGPS { - final static int MISSING = AltosRecord.MISSING; - - int nsat; - boolean locked; - boolean connected; - double lat; /* degrees (+N -S) */ - double lon; /* degrees (+E -W) */ - int alt; /* m */ - int year; - int month; - int day; - int hour; - int minute; - int second; - - double ground_speed; /* m/s */ - int course; /* degrees */ - double climb_rate; /* m/s */ - double hdop; /* unitless */ - double vdop; /* unitless */ - int h_error; /* m */ - int v_error; /* m */ - - AltosGPSSat[] cc_gps_sat; /* tracking data */ - - void ParseGPSDate(String date) throws ParseException { + public final static int MISSING = AltosRecord.MISSING; + + public int nsat; + public boolean locked; + public boolean connected; + public double lat; /* degrees (+N -S) */ + public double lon; /* degrees (+E -W) */ + public int alt; /* m */ + public int year; + public int month; + public int day; + public int hour; + public int minute; + public int second; + + public double ground_speed; /* m/s */ + public int course; /* degrees */ + public double climb_rate; /* m/s */ + public double hdop; /* unitless */ + public double vdop; /* unitless */ + public int h_error; /* m */ + public int v_error; /* m */ + + public AltosGPSSat[] cc_gps_sat; /* tracking data */ + + public void ParseGPSDate(String date) throws ParseException { String[] ymd = date.split("-"); if (ymd.length != 3) throw new ParseException("error parsing GPS date " + date + " got " + ymd.length, 0); @@ -56,7 +56,7 @@ public class AltosGPS { day = AltosParse.parse_int(ymd[2]); } - void ParseGPSTime(String time) throws ParseException { + public void ParseGPSTime(String time) throws ParseException { String[] hms = time.split(":"); if (hms.length != 3) throw new ParseException("Error parsing GPS time " + time + " got " + hms.length, 0); @@ -65,7 +65,7 @@ public class AltosGPS { second = AltosParse.parse_int(hms[2]); } - void ClearGPSTime() { + public void ClearGPSTime() { year = month = day = 0; hour = minute = second = 0; } diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPSSat.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPSSat.java index 5fa8f987..faa1ec8d 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPSSat.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosGPSSat.java @@ -18,8 +18,8 @@ package org.altusmetrum.AltosLib; public class AltosGPSSat { - int svid; - int c_n0; + public int svid; + public int c_n0; public AltosGPSSat(int s, int c) { svid = s; diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosParse.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosParse.java index 4c0a59cb..7d832f1a 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosParse.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosParse.java @@ -21,11 +21,11 @@ import java.text.*; import java.lang.*; public class AltosParse { - static boolean isdigit(char c) { + public static boolean isdigit(char c) { return '0' <= c && c <= '9'; } - static int parse_int(String v) throws ParseException { + public static int parse_int(String v) throws ParseException { try { return AltosLib.fromdec(v); } catch (NumberFormatException e) { @@ -33,7 +33,7 @@ public class AltosParse { } } - static int parse_hex(String v) throws ParseException { + public static int parse_hex(String v) throws ParseException { try { return AltosLib.fromhex(v); } catch (NumberFormatException e) { @@ -41,7 +41,7 @@ public class AltosParse { } } - static double parse_double(String v) throws ParseException { + public static double parse_double(String v) throws ParseException { try { return Double.parseDouble(v); } catch (NumberFormatException e) { @@ -49,7 +49,7 @@ public class AltosParse { } } - static double parse_coord(String coord) throws ParseException { + public static double parse_coord(String coord) throws ParseException { String[] dsf = coord.split("\\D+"); if (dsf.length != 3) { @@ -65,13 +65,13 @@ public class AltosParse { return r; } - static String strip_suffix(String v, String suffix) { + public static String strip_suffix(String v, String suffix) { if (v.endsWith(suffix)) return v.substring(0, v.length() - suffix.length()); return v; } - static void word(String v, String m) throws ParseException { + public static void word(String v, String m) throws ParseException { if (!v.equals(m)) { throw new ParseException("error matching '" + v + "' '" + m + "'", 0); } diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosPreferences.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosPreferences.java new file mode 100644 index 00000000..43c7088d --- /dev/null +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosPreferences.java @@ -0,0 +1,365 @@ +/* + * Copyright © 2010 Keith Packard + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; version 2 of the License. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. + */ + +package org.altusmetrum.AltosLib; + +import java.io.*; +import java.util.*; +import java.text.*; +import java.util.prefs.*; +import java.util.concurrent.LinkedBlockingQueue; +import java.awt.Component; +import javax.swing.*; +import javax.swing.filechooser.FileSystemView; + +public class AltosPreferences { + public static Preferences preferences; + + /* logdir preference name */ + public final static String logdirPreference = "LOGDIR"; + + /* channel preference name */ + public final static String channelPreferenceFormat = "CHANNEL-%d"; + + /* frequency preference name */ + public final static String frequencyPreferenceFormat = "FREQUENCY-%d"; + + /* telemetry format preference name */ + public final static String telemetryPreferenceFormat = "TELEMETRY-%d"; + + /* voice preference name */ + public final static String voicePreference = "VOICE"; + + /* callsign preference name */ + public final static String callsignPreference = "CALLSIGN"; + + /* firmware directory preference name */ + public final static String firmwaredirPreference = "FIRMWARE"; + + /* serial debug preference name */ + public final static String serialDebugPreference = "SERIAL-DEBUG"; + + /* scanning telemetry preferences name */ + public final static String scanningTelemetryPreference = "SCANNING-TELEMETRY"; + + /* Launcher serial preference name */ + public final static String launcherSerialPreference = "LAUNCHER-SERIAL"; + + /* Launcher channel preference name */ + public final static String launcherChannelPreference = "LAUNCHER-CHANNEL"; + + /* Default logdir is ~/TeleMetrum */ + public final static String logdirName = "TeleMetrum"; + + /* Log directory */ + public static File logdir; + + /* Map directory -- hangs of logdir */ + public static File mapdir; + + /* Frequency (map serial to frequency) */ + public static Hashtable frequencies; + + /* Telemetry (map serial to telemetry format) */ + public static Hashtable telemetries; + + /* Voice preference */ + public static boolean voice; + + /* Callsign preference */ + public static String callsign; + + /* Firmware directory */ + public static File firmwaredir; + + /* Scanning telemetry */ + public static int scanning_telemetry; + + /* List of frequencies */ + public final static String common_frequencies_node_name = "COMMON-FREQUENCIES"; + public static AltosFrequency[] common_frequencies; + + public final static String frequency_count = "COUNT"; + public final static String frequency_format = "FREQUENCY-%d"; + public final static String description_format = "DESCRIPTION-%d"; + + public static AltosFrequency[] load_common_frequencies() { + AltosFrequency[] frequencies = null; + boolean existing = false; + try { + existing = preferences.nodeExists(common_frequencies_node_name); + } catch (BackingStoreException be) { + existing = false; + } + if (existing) { + Preferences node = preferences.node(common_frequencies_node_name); + int count = node.getInt(frequency_count, 0); + + frequencies = new AltosFrequency[count]; + for (int i = 0; i < count; i++) { + double frequency; + String description; + + frequency = node.getDouble(String.format(frequency_format, i), 0.0); + description = node.get(String.format(description_format, i), null); + frequencies[i] = new AltosFrequency(frequency, description); + } + } else { + frequencies = new AltosFrequency[10]; + for (int i = 0; i < 10; i++) { + frequencies[i] = new AltosFrequency(434.550 + i * .1, + String.format("Channel %d", i)); + } + } + return frequencies; + } + + public static void save_common_frequencies(AltosFrequency[] frequencies) { + Preferences node = preferences.node(common_frequencies_node_name); + + node.putInt(frequency_count, frequencies.length); + for (int i = 0; i < frequencies.length; i++) { + node.putDouble(String.format(frequency_format, i), frequencies[i].frequency); + node.put(String.format(description_format, i), frequencies[i].description); + } + } + public static int launcher_serial; + + public static int launcher_channel; + + public static void init() { + preferences = Preferences.userRoot().node("/org/altusmetrum/altosui"); + + /* Initialize logdir from preferences */ + String logdir_string = preferences.get(logdirPreference, null); + if (logdir_string != null) + logdir = new File(logdir_string); + else { + /* Use the file system view default directory */ + logdir = new File(FileSystemView.getFileSystemView().getDefaultDirectory(), logdirName); + if (!logdir.exists()) + logdir.mkdirs(); + } + mapdir = new File(logdir, "maps"); + if (!mapdir.exists()) + mapdir.mkdirs(); + + frequencies = new Hashtable(); + + telemetries = new Hashtable(); + + voice = preferences.getBoolean(voicePreference, true); + + callsign = preferences.get(callsignPreference,"N0CALL"); + + scanning_telemetry = preferences.getInt(scanningTelemetryPreference,(1 << AltosLib.ao_telemetry_standard)); + + launcher_serial = preferences.getInt(launcherSerialPreference, 0); + + launcher_channel = preferences.getInt(launcherChannelPreference, 0); + + String firmwaredir_string = preferences.get(firmwaredirPreference, null); + if (firmwaredir_string != null) + firmwaredir = new File(firmwaredir_string); + else + firmwaredir = null; + + common_frequencies = load_common_frequencies(); + + } + + static { init(); } + + public static void flush_preferences() { + try { + preferences.flush(); + } catch (BackingStoreException ee) { +/* + if (component != null) + JOptionPane.showMessageDialog(component, + preferences.absolutePath(), + "Cannot save prefernces", + JOptionPane.ERROR_MESSAGE); + else +*/ + System.err.printf("Cannot save preferences\n"); + } + } + + public static void set_logdir(File new_logdir) { + logdir = new_logdir; + mapdir = new File(logdir, "maps"); + if (!mapdir.exists()) + mapdir.mkdirs(); + synchronized (preferences) { + preferences.put(logdirPreference, logdir.getPath()); + flush_preferences(); + } + } + + public static File logdir() { + return logdir; + } + + public static File mapdir() { + return mapdir; + } + + public static void set_frequency(int serial, double new_frequency) { + frequencies.put(serial, new_frequency); + synchronized (preferences) { + preferences.putDouble(String.format(frequencyPreferenceFormat, serial), new_frequency); + flush_preferences(); + } + } + + public static double frequency(int serial) { + if (frequencies.containsKey(serial)) + return frequencies.get(serial); + double frequency = preferences.getDouble(String.format(frequencyPreferenceFormat, serial), 0); + if (frequency == 0.0) { + int channel = preferences.getInt(String.format(channelPreferenceFormat, serial), 0); + frequency = AltosConvert.radio_channel_to_frequency(channel); + } + frequencies.put(serial, frequency); + return frequency; + } + + public static void set_telemetry(int serial, int new_telemetry) { + telemetries.put(serial, new_telemetry); + synchronized (preferences) { + preferences.putInt(String.format(telemetryPreferenceFormat, serial), new_telemetry); + flush_preferences(); + } + } + + public static int telemetry(int serial) { + if (telemetries.containsKey(serial)) + return telemetries.get(serial); + int telemetry = preferences.getInt(String.format(telemetryPreferenceFormat, serial), + AltosLib.ao_telemetry_standard); + telemetries.put(serial, telemetry); + return telemetry; + } + + public static void set_scanning_telemetry(int new_scanning_telemetry) { + scanning_telemetry = new_scanning_telemetry; + synchronized (preferences) { + preferences.putInt(scanningTelemetryPreference, scanning_telemetry); + flush_preferences(); + } + } + + public static int scanning_telemetry() { + return scanning_telemetry; + } + + public static void set_voice(boolean new_voice) { + voice = new_voice; + synchronized (preferences) { + preferences.putBoolean(voicePreference, voice); + flush_preferences(); + } + } + + public static boolean voice() { + return voice; + } + + public static void set_callsign(String new_callsign) { + callsign = new_callsign; + synchronized(preferences) { + preferences.put(callsignPreference, callsign); + flush_preferences(); + } + } + + public static String callsign() { + return callsign; + } + + public static void set_firmwaredir(File new_firmwaredir) { + firmwaredir = new_firmwaredir; + synchronized (preferences) { + preferences.put(firmwaredirPreference, firmwaredir.getPath()); + flush_preferences(); + } + } + + public static File firmwaredir() { + return firmwaredir; + } + + public static void set_launcher_serial(int new_launcher_serial) { + launcher_serial = new_launcher_serial; + System.out.printf("set launcher serial to %d\n", new_launcher_serial); + synchronized (preferences) { + preferences.putInt(launcherSerialPreference, launcher_serial); + flush_preferences(); + } + } + + public static int launcher_serial() { + return launcher_serial; + } + + public static void set_launcher_channel(int new_launcher_channel) { + launcher_channel = new_launcher_channel; + System.out.printf("set launcher channel to %d\n", new_launcher_channel); + synchronized (preferences) { + preferences.putInt(launcherChannelPreference, launcher_channel); + flush_preferences(); + } + } + + public static int launcher_channel() { + return launcher_channel; + } + + public static Preferences bt_devices() { + return preferences.node("bt_devices"); + } + + public static AltosFrequency[] common_frequencies() { + return common_frequencies; + } + + public static void set_common_frequencies(AltosFrequency[] frequencies) { + common_frequencies = frequencies; + synchronized(preferences) { + save_common_frequencies(frequencies); + flush_preferences(); + } + } + + public static void add_common_frequency(AltosFrequency frequency) { + AltosFrequency[] new_frequencies = new AltosFrequency[common_frequencies.length + 1]; + int i; + + for (i = 0; i < common_frequencies.length; i++) { + if (frequency.frequency == common_frequencies[i].frequency) + return; + if (frequency.frequency < common_frequencies[i].frequency) + break; + new_frequencies[i] = common_frequencies[i]; + } + new_frequencies[i] = frequency; + for (; i < common_frequencies.length; i++) + new_frequencies[i+1] = common_frequencies[i]; + set_common_frequencies(new_frequencies); + } +} diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecord.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecord.java index 120004a7..e4915af0 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecord.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecord.java @@ -23,64 +23,66 @@ import java.util.HashMap; import java.io.*; public class AltosRecord implements Comparable { - final static int MISSING = 0x7fffffff; - - static final int seen_flight = 1; - static final int seen_sensor = 2; - static final int seen_temp_volt = 4; - static final int seen_deploy = 8; - static final int seen_gps_time = 16; - static final int seen_gps_lat = 32; - static final int seen_gps_lon = 64; - static final int seen_companion = 128; - int seen; - - int version; - String callsign; - int serial; - int flight; - int rssi; - int status; - int state; - int tick; - - int accel; - int pres; - int temp; - int batt; - int drogue; - int main; - - int ground_accel; - int ground_pres; - int accel_plus_g; - int accel_minus_g; - - double acceleration; - double speed; - double height; - - int flight_accel; - int flight_vel; - int flight_pres; - - AltosGPS gps; - boolean new_gps; - - AltosIMU imu; - AltosMag mag; - - double time; /* seconds since boost */ - - int device_type; - int config_major; - int config_minor; - int apogee_delay; - int main_deploy; - int flight_log_max; - String firmware_version; - - AltosRecordCompanion companion; + public final static int MISSING = 0x7fffffff; + + public static final int seen_flight = 1; + public static final int seen_sensor = 2; + public static final int seen_temp_volt = 4; + public static final int seen_deploy = 8; + public static final int seen_gps_time = 16; + public static final int seen_gps_lat = 32; + public static final int seen_gps_lon = 64; + public static final int seen_companion = 128; + public int seen; + + public int version; + public String callsign; + public int serial; + public int flight; + public int rssi; + public int status; + public int state; + public int tick; + + public int accel; + public int pres; + public int temp; + public int batt; + public int drogue; + public int main; + + public int ground_accel; + public int ground_pres; + public int accel_plus_g; + public int accel_minus_g; + + public double acceleration; + public double speed; + public double height; + + public int flight_accel; + public int flight_vel; + public int flight_pres; + + public AltosGPS gps; + public boolean new_gps; + + public AltosIMU imu; + public AltosMag mag; + + public double time; /* seconds since boost */ + + public int device_type; + public int config_major; + public int config_minor; + public int apogee_delay; + public int main_deploy; + public int flight_log_max; + public String firmware_version; + + public AltosRecordCompanion companion; + +>>>>>>> 5a249bc... altosui: Complete split out of separate java library /* * Values for our MP3H6115A pressure sensor * @@ -95,10 +97,10 @@ public class AltosRecord implements Comparable { * 2.82V * 2047 / 3.3 counts/V = 1749 counts/115 kPa */ - static final double counts_per_kPa = 27 * 2047 / 3300; - static final double counts_at_101_3kPa = 1674.0; + public static final double counts_per_kPa = 27 * 2047 / 3300; + public static final double counts_at_101_3kPa = 1674.0; - static double + public static double barometer_to_pressure(double count) { return ((count / 16.0) / 2047.0 + 0.095) / 0.009 * 1000.0; @@ -193,7 +195,7 @@ public class AltosRecord implements Comparable { * = (value - 19791.268) / 32768 * 1.25 / 0.00247 */ - static double + public static double thermometer_to_temperature(double thermo) { return (thermo - 19791.268) / 32728.0 * 1.25 / 0.00247; @@ -205,7 +207,7 @@ public class AltosRecord implements Comparable { return thermometer_to_temperature(temp); } - double accel_counts_per_mss() { + public double accel_counts_per_mss() { double counts_per_g = Math.abs(accel_minus_g - accel_plus_g) / 2; return counts_per_g / 9.80665; diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecordCompanion.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecordCompanion.java index 4f8e80dc..c8cc6cac 100644 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecordCompanion.java +++ b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosRecordCompanion.java @@ -18,14 +18,14 @@ package org.altusmetrum.AltosLib; public class AltosRecordCompanion { - final static int board_id_telescience = 0x0a; - final static int MAX_CHANNELS = 12; + public final static int board_id_telescience = 0x0a; + public final static int MAX_CHANNELS = 12; - int tick; - int board_id; - int update_period; - int channels; - int[] companion_data; + public int tick; + public int board_id; + public int update_period; + public int channels; + public int[] companion_data; public AltosRecordCompanion(int in_channels) { channels = in_channels; diff --git a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosTelemetryReader.java b/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosTelemetryReader.java deleted file mode 100644 index bd94ee36..00000000 --- a/altosui/altoslib/src/org/altusmetrum/AltosLib/AltosTelemetryReader.java +++ /dev/null @@ -1,119 +0,0 @@ -/* - * Copyright © 2010 Keith Packard - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; version 2 of the License. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program; if not, write to the Free Software Foundation, Inc., - * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. - */ - -package org.altusmetrum.AltosLib; - -import java.lang.*; -import java.text.*; -import java.io.*; -import java.util.concurrent.*; - -class AltosTelemetryReader extends AltosFlightReader { - AltosDevice device; - AltosSerial serial; - AltosLog log; - AltosRecord previous; - double frequency; - int telemetry; - - LinkedBlockingQueue telem; - - AltosRecord read() throws InterruptedException, ParseException, AltosCRCException, IOException { - AltosLine l = telem.take(); - if (l.line == null) - throw new IOException("IO error"); - AltosRecord next = AltosTelemetry.parse(l.line, previous); - previous = next; - return next; - } - - void flush() { - telem.clear(); - } - - void close(boolean interrupted) { - serial.remove_monitor(telem); - log.close(); - serial.close(); - } - - public void set_frequency(double in_frequency) throws InterruptedException, TimeoutException { - frequency = in_frequency; - serial.set_radio_frequency(frequency); - } - - public boolean supports_telemetry(int telemetry) { - - try { - /* Version 1.0 or later firmware supports all telemetry formats */ - if (serial.config_data().compare_version("1.0") >= 0) - return true; - - /* Version 0.9 firmware only supports 0.9 telemetry */ - if (serial.config_data().compare_version("0.9") >= 0) { - if (telemetry == Altos.ao_telemetry_0_9) - return true; - else - return false; - } - - /* Version 0.8 firmware only supports 0.8 telemetry */ - if (telemetry == Altos.ao_telemetry_0_8) - return true; - else - return false; - } catch (InterruptedException ie) { - return true; - } catch (TimeoutException te) { - return true; - } - } - - void save_frequency() { - AltosUIPreferences.set_frequency(device.getSerial(), frequency); - } - - void set_telemetry(int in_telemetry) { - telemetry = in_telemetry; - serial.set_telemetry(telemetry); - } - - void save_telemetry() { - AltosUIPreferences.set_telemetry(device.getSerial(), telemetry); - } - - File backing_file() { - return log.file(); - } - - public AltosTelemetryReader (AltosDevice in_device) - throws FileNotFoundException, AltosSerialInUseException, IOException, InterruptedException, TimeoutException { - device = in_device; - serial = new AltosSerial(device); - log = new AltosLog(serial); - name = device.toShortString(); - previous = null; - - telem = new LinkedBlockingQueue(); - frequency = AltosUIPreferences.frequency(device.getSerial()); - set_frequency(frequency); - telemetry = AltosUIPreferences.telemetry(device.getSerial()); - set_telemetry(telemetry); - serial.set_callsign(AltosUIPreferences.callsign()); - serial.add_monitor(telem); - } -} -- cgit v1.2.3 From b8c363d9411fd5e79e3f806894dbc12bcc106b88 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 4 Jun 2012 20:56:25 -0700 Subject: altosui: More changes to migrate code to altoslib Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 1 + altosui/Altos.java | 184 --------------------------------------- altosui/AltosEepromDownload.java | 10 +-- 3 files changed, 6 insertions(+), 189 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 27d72079..e74eaf99 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -185,6 +185,7 @@ public class AltosLib { public static final int AO_LOG_FORMAT_TINY = 2; public static final int AO_LOG_FORMAT_TELEMETRY = 3; public static final int AO_LOG_FORMAT_TELESCIENCE = 4; + public static final int AO_LOG_FORMAT_MEGAMETRUM = 5; public static final int AO_LOG_FORMAT_NONE = 127; public static boolean isspace(int c) { diff --git a/altosui/Altos.java b/altosui/Altos.java index 351927ee..78e56970 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -86,190 +86,6 @@ public class Altos extends AltosLib { return state_to_string[state]; } - static final int AO_GPS_VALID = (1 << 4); - static final int AO_GPS_RUNNING = (1 << 5); - static final int AO_GPS_DATE_VALID = (1 << 6); - static final int AO_GPS_NUM_SAT_SHIFT = 0; - static final int AO_GPS_NUM_SAT_MASK = 0xf; - - static final int AO_LOG_FORMAT_UNKNOWN = 0; - static final int AO_LOG_FORMAT_FULL = 1; - static final int AO_LOG_FORMAT_TINY = 2; - static final int AO_LOG_FORMAT_TELEMETRY = 3; - static final int AO_LOG_FORMAT_TELESCIENCE = 4; - static final int AO_LOG_FORMAT_MEGAMETRUM = 5; - static final int AO_LOG_FORMAT_NONE = 127; - - static boolean isspace(int c) { - switch (c) { - case ' ': - case '\t': - return true; - } - return false; - } - - static boolean ishex(int c) { - if ('0' <= c && c <= '9') - return true; - if ('a' <= c && c <= 'f') - return true; - if ('A' <= c && c <= 'F') - return true; - return false; - } - - static boolean ishex(String s) { - for (int i = 0; i < s.length(); i++) - if (!ishex(s.charAt(i))) - return false; - return true; - } - - static int fromhex(int c) { - if ('0' <= c && c <= '9') - return c - '0'; - if ('a' <= c && c <= 'f') - return c - 'a' + 10; - if ('A' <= c && c <= 'F') - return c - 'A' + 10; - return -1; - } - - static int fromhex(String s) throws NumberFormatException { - int c, v = 0; - for (int i = 0; i < s.length(); i++) { - c = s.charAt(i); - if (!ishex(c)) { - if (i == 0) - throw new NumberFormatException(String.format("invalid hex \"%s\"", s)); - return v; - } - v = v * 16 + fromhex(c); - } - return v; - } - - static boolean isdec(int c) { - if ('0' <= c && c <= '9') - return true; - return false; - } - - static boolean isdec(String s) { - for (int i = 0; i < s.length(); i++) - if (!isdec(s.charAt(i))) - return false; - return true; - } - - static int fromdec(int c) { - if ('0' <= c && c <= '9') - return c - '0'; - return -1; - } - - static int int8(int[] bytes, int i) { - return (int) (byte) bytes[i]; - } - - static int uint8(int[] bytes, int i) { - return bytes[i]; - } - - static int int16(int[] bytes, int i) { - return (int) (short) (bytes[i] + (bytes[i+1] << 8)); - } - - static int uint16(int[] bytes, int i) { - return bytes[i] + (bytes[i+1] << 8); - } - - static int uint32(int[] bytes, int i) { - return bytes[i] + - (bytes[i+1] << 8) + - (bytes[i+2] << 16) + - (bytes[i+3] << 24); - } - - static final Charset unicode_set = Charset.forName("UTF-8"); - - static String string(int[] bytes, int s, int l) { - if (s + l > bytes.length) { - if (s > bytes.length) { - s = bytes.length; - l = 0; - } else { - l = bytes.length - s; - } - } - - int i; - for (i = l - 1; i >= 0; i--) - if (bytes[s+i] != 0) - break; - - l = i + 1; - byte[] b = new byte[l]; - - for (i = 0; i < l; i++) - b[i] = (byte) bytes[s+i]; - String n = new String(b, unicode_set); - return n; - } - - static int hexbyte(String s, int i) { - int c0, c1; - - if (s.length() < i + 2) - throw new NumberFormatException(String.format("invalid hex \"%s\"", s)); - c0 = s.charAt(i); - if (!Altos.ishex(c0)) - throw new NumberFormatException(String.format("invalid hex \"%c\"", c0)); - c1 = s.charAt(i+1); - if (!Altos.ishex(c1)) - throw new NumberFormatException(String.format("invalid hex \"%c\"", c1)); - return Altos.fromhex(c0) * 16 + Altos.fromhex(c1); - } - - static int[] hexbytes(String s) { - int n; - int[] r; - int i; - - if ((s.length() & 1) != 0) - throw new NumberFormatException(String.format("invalid line \"%s\"", s)); - n = s.length() / 2; - r = new int[n]; - for (i = 0; i < n; i++) - r[i] = Altos.hexbyte(s, i * 2); - return r; - } - - static int fromdec(String s) throws NumberFormatException { - int c, v = 0; - int sign = 1; - for (int i = 0; i < s.length(); i++) { - c = s.charAt(i); - if (i == 0 && c == '-') { - sign = -1; - } else if (!isdec(c)) { - if (i == 0) - throw new NumberFormatException(String.format("invalid number \"%s\"", s)); - return v; - } else - v = v * 10 + fromdec(c); - } - return v * sign; - } - - static String replace_extension(String input, String extension) { - int dot = input.lastIndexOf("."); - if (dot > 0) - input = input.substring(0,dot); - return input.concat(extension); - } - static public boolean initialized = false; static public boolean loaded_library = false; diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 080bfc99..d1e5fdf0 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -357,23 +357,23 @@ public class AltosEepromDownload implements Runnable { } switch (log_format) { - case Altos.AO_LOG_FORMAT_FULL: + case AltosLib.AO_LOG_FORMAT_FULL: extension = "eeprom"; CaptureFull(eechunk); break; - case Altos.AO_LOG_FORMAT_TINY: + case AltosLib.AO_LOG_FORMAT_TINY: extension = "eeprom"; CaptureTiny(eechunk); break; - case Altos.AO_LOG_FORMAT_TELEMETRY: + case AltosLib.AO_LOG_FORMAT_TELEMETRY: extension = "telem"; CaptureTelemetry(eechunk); break; - case Altos.AO_LOG_FORMAT_TELESCIENCE: + case AltosLib.AO_LOG_FORMAT_TELESCIENCE: extension = "science"; CaptureTeleScience(eechunk); break; - case Altos.AO_LOG_FORMAT_MEGAMETRUM: + case AltosLib.AO_LOG_FORMAT_MEGAMETRUM: extension = "mega"; CaptureMega(eechunk); } -- cgit v1.2.3 From ea957f9e6144f8411ac84ee2905700f55f5a6e8a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Tue, 3 Jul 2012 00:29:43 -0700 Subject: altosui: Fix flight data download for TM. Look for MM flights when graphing A couple of minor fixes, the first to not force the log format so that TM/Tm data will be downloaded correctly and the second to expand the set of files to include '.mega' files when plotting data. Signed-off-by: Keith Packard --- altosui/AltosDataChooser.java | 2 +- altosui/AltosEepromDownload.java | 6 ++---- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index 0d629b3c..4bd51c39 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -77,7 +77,7 @@ public class AltosDataChooser extends JFileChooser { frame = in_frame; setDialogTitle("Select Flight Record File"); setFileFilter(new FileNameExtensionFilter("Flight data file", - "telem", "eeprom")); + "telem", "eeprom", "mega")); setCurrentDirectory(AltosUIPreferences.logdir()); } } diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index d1e5fdf0..4a35c2f1 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -319,11 +319,9 @@ public class AltosEepromDownload implements Runnable { done = false; start = true; -// if (flights.config_data.serial == 0) -// throw new IOException("no serial number found"); + if (flights.config_data.serial == 0) + throw new IOException("no serial number found"); - log_format = 5; - System.out.printf ("log format: %d\n", log_format); /* Reset per-capture variables */ flight = 0; year = 0; -- cgit v1.2.3 From d65d921b9b2340fa23d3b55b4ae755324d392303 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 9 Sep 2012 12:20:08 -0700 Subject: altosui: Catch errors in state value when saving flight logs Use AltosLib.state_name() instead of directly accessing the state_to_string array so that any invalid state values are caught and replaced with 'invalid' instead of raising an exception. Signed-off-by: Keith Packard --- altosui/AltosEepromDownload.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index 4a35c2f1..b04890cd 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -336,7 +336,7 @@ public class AltosEepromDownload implements Runnable { state = 0; state_block = log.start_block; for (block = log.start_block; !done && block < log.end_block; block++) { - monitor.set_value(Altos.state_to_string[state], state, block - state_block); + monitor.set_value(AltosLib.state_name(state), state, block - state_block); AltosEepromChunk eechunk = new AltosEepromChunk(serial_line, block, block == log.start_block); -- cgit v1.2.3 From 708e7937cba52982b91244cf89bfbff46d346135 Mon Sep 17 00:00:00 2001 From: Tom Marble Date: Mon, 10 Sep 2012 16:54:27 -0500 Subject: Changed package name from altosui to AltosUI --- altosui/Altos.java | 2 +- altosui/AltosAscent.java | 2 +- altosui/AltosBTDevice.java | 2 +- altosui/AltosBTDeviceIterator.java | 2 +- altosui/AltosBTKnown.java | 2 +- altosui/AltosBTManage.java | 2 +- altosui/AltosCSV.java | 2 +- altosui/AltosCSVUI.java | 2 +- altosui/AltosChannelMenu.java | 2 +- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfig.java | 2 +- altosui/AltosConfigFreqUI.java | 2 +- altosui/AltosConfigTD.java | 2 +- altosui/AltosConfigTDUI.java | 2 +- altosui/AltosConfigUI.java | 2 +- altosui/AltosConfigureUI.java | 2 +- altosui/AltosDataChooser.java | 2 +- altosui/AltosDataPoint.java | 2 +- altosui/AltosDataPointReader.java | 2 +- altosui/AltosDebug.java | 2 +- altosui/AltosDescent.java | 2 +- altosui/AltosDevice.java | 2 +- altosui/AltosDeviceDialog.java | 2 +- altosui/AltosDialog.java | 2 +- altosui/AltosDisplayThread.java | 2 +- altosui/AltosEepromDelete.java | 2 +- altosui/AltosEepromDownload.java | 2 +- altosui/AltosEepromList.java | 2 +- altosui/AltosEepromManage.java | 2 +- altosui/AltosEepromMonitor.java | 2 +- altosui/AltosEepromSelect.java | 2 +- altosui/AltosFlash.java | 2 +- altosui/AltosFlashUI.java | 2 +- altosui/AltosFlightDisplay.java | 2 +- altosui/AltosFlightInfoTableModel.java | 2 +- altosui/AltosFlightStats.java | 2 +- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightStatus.java | 2 +- altosui/AltosFlightStatusTableModel.java | 2 +- altosui/AltosFlightStatusUpdate.java | 2 +- altosui/AltosFlightUI.java | 2 +- altosui/AltosFontListener.java | 2 +- altosui/AltosFrame.java | 2 +- altosui/AltosFreqList.java | 2 +- altosui/AltosGraph.java | 2 +- altosui/AltosGraphTime.java | 2 +- altosui/AltosGraphUI.java | 2 +- altosui/AltosHexfile.java | 2 +- altosui/AltosIdleMonitorUI.java | 2 +- altosui/AltosIgniteUI.java | 2 +- altosui/AltosInfoTable.java | 2 +- altosui/AltosKML.java | 2 +- altosui/AltosLanded.java | 2 +- altosui/AltosLaunch.java | 2 +- altosui/AltosLaunchUI.java | 2 +- altosui/AltosLed.java | 2 +- altosui/AltosLights.java | 2 +- altosui/AltosPad.java | 2 +- altosui/AltosRomconfig.java | 2 +- altosui/AltosRomconfigUI.java | 2 +- altosui/AltosScanUI.java | 2 +- altosui/AltosSerial.java | 2 +- altosui/AltosSerialInUseException.java | 2 +- altosui/AltosSiteMap.java | 2 +- altosui/AltosSiteMapCache.java | 2 +- altosui/AltosSiteMapPreload.java | 2 +- altosui/AltosSiteMapTile.java | 2 +- altosui/AltosUI.java | 2 +- altosui/AltosUIListener.java | 2 +- altosui/AltosUIPreferences.java | 2 +- altosui/AltosUSBDevice.java | 2 +- altosui/AltosVersion.java.in | 2 +- altosui/AltosVoice.java | 2 +- altosui/AltosWriter.java | 2 +- altosui/GrabNDrag.java | 2 +- altosui/Makefile.am | 28 +++++++++++++--------------- 76 files changed, 88 insertions(+), 90 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/altosui/Altos.java b/altosui/Altos.java index cd17a93e..d3aad6b2 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.util.*; diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index a158eb21..de6c90a1 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index 5e353fdd..a6eee085 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosBTDeviceIterator.java b/altosui/AltosBTDeviceIterator.java index 58ed86d5..8d9e6fe6 100644 --- a/altosui/AltosBTDeviceIterator.java +++ b/altosui/AltosBTDeviceIterator.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index 6a8e53cb..ad0672c6 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java index aeb964bb..a411c83e 100644 --- a/altosui/AltosBTManage.java +++ b/altosui/AltosBTManage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index c876d9ca..c672b78f 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.io.*; diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index 2702668b..a28c4ca6 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosChannelMenu.java b/altosui/AltosChannelMenu.java index 0249a0bd..d7e7f58f 100644 --- a/altosui/AltosChannelMenu.java +++ b/altosui/AltosChannelMenu.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 4ba8fe98..16c972b3 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index cae41858..0b386ac9 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index 7958a21c..4f8bd0f2 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index 324a5988..f5d30250 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index f2058f69..f653d941 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index 62394fa6..b0624ef2 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index da82e8e0..b46c1fae 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index 4bd51c39..b003a606 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDataPoint.java b/altosui/AltosDataPoint.java index 5e077320..80f62c2c 100644 --- a/altosui/AltosDataPoint.java +++ b/altosui/AltosDataPoint.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package altosui; +package AltosUI; interface AltosDataPoint { int version(); diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index 821b0771..371c48cb 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package altosui; +package AltosUI; import java.io.IOException; import java.text.ParseException; diff --git a/altosui/AltosDebug.java b/altosui/AltosDebug.java index 23e38bc0..4e394011 100644 --- a/altosui/AltosDebug.java +++ b/altosui/AltosDebug.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.io.*; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 62258814..2e3f26bd 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDevice.java b/altosui/AltosDevice.java index 1b5c1a91..dc045d7b 100644 --- a/altosui/AltosDevice.java +++ b/altosui/AltosDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosDeviceDialog.java b/altosui/AltosDeviceDialog.java index fa9d0013..7ab08b30 100644 --- a/altosui/AltosDeviceDialog.java +++ b/altosui/AltosDeviceDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.util.*; diff --git a/altosui/AltosDialog.java b/altosui/AltosDialog.java index ff38c3e4..1de11317 100644 --- a/altosui/AltosDialog.java +++ b/altosui/AltosDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index cf69c414..0cf942e7 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index 73f3a00f..21f09d0e 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index b04890cd..a4d6b26e 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index 6a656215..2a88134c 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index 563c90b3..27b03bed 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index 75643442..daf8d0ba 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index 4ad78896..cb242183 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.util.*; diff --git a/altosui/AltosFlash.java b/altosui/AltosFlash.java index bd0c8a50..996456fd 100644 --- a/altosui/AltosFlash.java +++ b/altosui/AltosFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 66991d10..01421de9 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java index 826f9522..e677fd6f 100644 --- a/altosui/AltosFlightDisplay.java +++ b/altosui/AltosFlightDisplay.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import org.altusmetrum.AltosLib.*; diff --git a/altosui/AltosFlightInfoTableModel.java b/altosui/AltosFlightInfoTableModel.java index 77969a89..cb798bcb 100644 --- a/altosui/AltosFlightInfoTableModel.java +++ b/altosui/AltosFlightInfoTableModel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java index ab094c80..d37f90b8 100644 --- a/altosui/AltosFlightStats.java +++ b/altosui/AltosFlightStats.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index 87ba6aa8..bcfdd84e 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index 6a351004..ee03698b 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index c2cf8cd1..919c7704 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index d70fc7f8..a0b4e304 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index ddc54cbd..08e8550f 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFontListener.java b/altosui/AltosFontListener.java index 0dda0f29..a0cb8a56 100644 --- a/altosui/AltosFontListener.java +++ b/altosui/AltosFontListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; public interface AltosFontListener { void font_size_changed(int font_size); diff --git a/altosui/AltosFrame.java b/altosui/AltosFrame.java index 70598634..cdbfe7d3 100644 --- a/altosui/AltosFrame.java +++ b/altosui/AltosFrame.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java index 1bbc97c6..a17afce6 100644 --- a/altosui/AltosFreqList.java +++ b/altosui/AltosFreqList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java index 54d2bb0b..a61a0976 100644 --- a/altosui/AltosGraph.java +++ b/altosui/AltosGraph.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package altosui; +package AltosUI; import java.io.*; diff --git a/altosui/AltosGraphTime.java b/altosui/AltosGraphTime.java index 0955f6e6..f00170ec 100644 --- a/altosui/AltosGraphTime.java +++ b/altosui/AltosGraphTime.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package altosui; +package AltosUI; import java.lang.*; import java.io.*; diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index 527a7d28..b571fc7d 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package altosui; +package AltosUI; import java.io.*; import java.util.ArrayList; diff --git a/altosui/AltosHexfile.java b/altosui/AltosHexfile.java index d52b46c3..435f13ee 100644 --- a/altosui/AltosHexfile.java +++ b/altosui/AltosHexfile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.io.*; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 46ca3e5d..f67644fc 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 78eba8e6..8c4c939f 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index c1400976..8caf5a80 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java index ff0734b8..7e3b0e08 100644 --- a/altosui/AltosKML.java +++ b/altosui/AltosKML.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.io.*; diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index a47e1cbd..5c3111a2 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java index 0e493b91..67512cef 100644 --- a/altosui/AltosLaunch.java +++ b/altosui/AltosLaunch.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.io.*; import java.util.concurrent.*; diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index 44481544..a4f12997 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosLed.java b/altosui/AltosLed.java index 1358cd48..4bf43a53 100644 --- a/altosui/AltosLed.java +++ b/altosui/AltosLed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosLights.java b/altosui/AltosLights.java index 8bd9e7de..92d11212 100644 --- a/altosui/AltosLights.java +++ b/altosui/AltosLights.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 0a3f3d65..8006190d 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosRomconfig.java b/altosui/AltosRomconfig.java index 0a283e51..1e3d7294 100644 --- a/altosui/AltosRomconfig.java +++ b/altosui/AltosRomconfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.io.*; import org.altusmetrum.AltosLib.*; diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java index 306b8623..25d8d087 100644 --- a/altosui/AltosRomconfigUI.java +++ b/altosui/AltosRomconfigUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 9da1290f..534451cb 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index 6cee1609..61865bbd 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -19,7 +19,7 @@ * Deal with TeleDongle on a serial port */ -package altosui; +package AltosUI; import java.lang.*; import java.io.*; diff --git a/altosui/AltosSerialInUseException.java b/altosui/AltosSerialInUseException.java index 7380f331..ae97b3d2 100644 --- a/altosui/AltosSerialInUseException.java +++ b/altosui/AltosSerialInUseException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; public class AltosSerialInUseException extends Exception { public AltosDevice device; diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index b57edcab..4195fc3f 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosSiteMapCache.java b/altosui/AltosSiteMapCache.java index f729a298..6e7e423b 100644 --- a/altosui/AltosSiteMapCache.java +++ b/altosui/AltosSiteMapCache.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java index 676b0790..8c0850fa 100644 --- a/altosui/AltosSiteMapPreload.java +++ b/altosui/AltosSiteMapPreload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java index 34550219..1e1cca5a 100644 --- a/altosui/AltosSiteMapTile.java +++ b/altosui/AltosSiteMapTile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index 926d66f0..a1678299 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosUIListener.java b/altosui/AltosUIListener.java index 7ee62afc..e50b30b2 100644 --- a/altosui/AltosUIListener.java +++ b/altosui/AltosUIListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; public interface AltosUIListener { public void ui_changed(String look_and_feel); diff --git a/altosui/AltosUIPreferences.java b/altosui/AltosUIPreferences.java index 10ab26c3..010d8e6a 100644 --- a/altosui/AltosUIPreferences.java +++ b/altosui/AltosUIPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.io.*; import java.util.*; diff --git a/altosui/AltosUSBDevice.java b/altosui/AltosUSBDevice.java index ed5f8307..0c953cbf 100644 --- a/altosui/AltosUSBDevice.java +++ b/altosui/AltosUSBDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosVersion.java.in b/altosui/AltosVersion.java.in index b0b3c0cf..d72e0936 100644 --- a/altosui/AltosVersion.java.in +++ b/altosui/AltosVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; public class AltosVersion { public final static String version = "@VERSION@"; diff --git a/altosui/AltosVoice.java b/altosui/AltosVoice.java index ab74e0b3..ff83ac29 100644 --- a/altosui/AltosVoice.java +++ b/altosui/AltosVoice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java index b7375204..9031c268 100644 --- a/altosui/AltosWriter.java +++ b/altosui/AltosWriter.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.lang.*; import java.io.*; diff --git a/altosui/GrabNDrag.java b/altosui/GrabNDrag.java index c350efec..a984c43e 100644 --- a/altosui/GrabNDrag.java +++ b/altosui/GrabNDrag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package altosui; +package AltosUI; import java.awt.*; import java.awt.image.*; diff --git a/altosui/Makefile.am b/altosui/Makefile.am index eb6ea2a3..9ca4f86e 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -112,11 +112,9 @@ LIBALTOS= \ libaltos.dylib \ altos.dll -# tmarble: test comment for change of package name -# from altosui to AltosUI -JAR=altosui.jar +JAR=AltosUI.jar -FATJAR=altosui-fat.jar +FATJAR=AltosUI-fat.jar # Icons ICONDIR=$(top_srcdir)/icon @@ -172,7 +170,7 @@ MACOSX_EXTRA=$(FIRMWARE) WINDOWS_FILES=$(FAT_FILES) altos.dll altos64.dll $(top_srcdir)/telemetrum.inf $(WINDOWS_ICON) -all-local: classes/altosui $(JAR) altosui altosui-test altosui-jdb +all-local: classes/AltosUI $(JAR) altosui altosui-test altosui-jdb clean-local: -rm -rf classes $(JAR) $(FATJAR) \ @@ -209,43 +207,43 @@ endif altosuidir=$(datadir)/java -install-altosuiJAVA: altosui.jar +install-altosuiJAVA: AltosUI.jar @$(NORMAL_INSTALL) test -z "$(altosuidir)" || $(MKDIR_P) "$(DESTDIR)$(altosuidir)" - echo " $(INSTALL_DATA)" "$<" "'$(DESTDIR)$(altosuidir)/altosui.jar'"; \ + echo " $(INSTALL_DATA)" "$<" "'$(DESTDIR)$(altosuidir)/AltosUI.jar'"; \ $(INSTALL_DATA) "$<" "$(DESTDIR)$(altosuidir)" -classes/altosui: - mkdir -p classes/altosui +classes/AltosUI: + mkdir -p classes/AltosUI $(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICON) $(ALTOSLIB_CLASS) jar cfm $@ Manifest.txt \ $(ICONJAR) \ - -C classes altosui \ + -C classes AltosUI \ -C libaltos libaltosJNI $(FATJAR): classaltosui.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICON) jar cfm $@ Manifest-fat.txt \ $(ICONJAR) \ - -C classes altosui \ + -C classes AltosUI \ -C libaltos libaltosJNI Manifest.txt: Makefile - echo 'Main-Class: altosui.AltosUI' > $@ + echo 'Main-Class: AltosUI.AltosUI' > $@ echo "Class-Path: AltosLib.jar $(FREETTS)/freetts.jar $(JFREECHART)/jfreechart.jar $(JCOMMON)/jcommon.jar" >> $@ Manifest-fat.txt: - echo 'Main-Class: altosui.AltosUI' > $@ + echo 'Main-Class: AltosUI.AltosUI' > $@ echo "Class-Path: AltosLib.jar freetts.jar jfreechart.jar jcommon.jar" >> $@ altosui: Makefile echo "#!/bin/sh" > $@ - echo 'exec java -cp "$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="$(altoslibdir)" -jar "$(altosuidir)/altosui.jar" "$$@"' >> $@ + echo 'exec java -cp "$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="$(altoslibdir)" -jar "$(altosuidir)/AltosUI.jar" "$$@"' >> $@ chmod +x $@ altosui-test: Makefile echo "#!/bin/sh" > $@ - echo 'exec java -cp "./*:$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar altosui.jar "$$@"' >> $@ + echo 'exec java -cp "./*:$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar AltosUI.jar "$$@"' >> $@ chmod +x $@ altosui-jdb: Makefile -- cgit v1.2.3 From 95268d681c9a6652d84db383f55a4fe8a4ac5173 Mon Sep 17 00:00:00 2001 From: Tom Marble Date: Tue, 11 Sep 2012 12:54:31 -0500 Subject: Reverted package name to 'altosui' from 'AltosUI' Also added emacs backup regex (*~) to .gitignore --- .gitignore | 2 +- altosui/Altos.java | 2 +- altosui/AltosAscent.java | 2 +- altosui/AltosBTDevice.java | 2 +- altosui/AltosBTDeviceIterator.java | 2 +- altosui/AltosBTKnown.java | 2 +- altosui/AltosBTManage.java | 2 +- altosui/AltosCSV.java | 2 +- altosui/AltosCSVUI.java | 2 +- altosui/AltosChannelMenu.java | 2 +- altosui/AltosCompanionInfo.java | 2 +- altosui/AltosConfig.java | 2 +- altosui/AltosConfigFreqUI.java | 2 +- altosui/AltosConfigTD.java | 2 +- altosui/AltosConfigTDUI.java | 2 +- altosui/AltosConfigUI.java | 2 +- altosui/AltosConfigureUI.java | 2 +- altosui/AltosDataChooser.java | 2 +- altosui/AltosDataPoint.java | 2 +- altosui/AltosDataPointReader.java | 2 +- altosui/AltosDebug.java | 2 +- altosui/AltosDescent.java | 2 +- altosui/AltosDevice.java | 2 +- altosui/AltosDeviceDialog.java | 2 +- altosui/AltosDialog.java | 2 +- altosui/AltosDisplayThread.java | 2 +- altosui/AltosEepromDelete.java | 2 +- altosui/AltosEepromDownload.java | 2 +- altosui/AltosEepromList.java | 2 +- altosui/AltosEepromManage.java | 2 +- altosui/AltosEepromMonitor.java | 2 +- altosui/AltosEepromSelect.java | 2 +- altosui/AltosFlash.java | 2 +- altosui/AltosFlashUI.java | 2 +- altosui/AltosFlightDisplay.java | 2 +- altosui/AltosFlightInfoTableModel.java | 2 +- altosui/AltosFlightStats.java | 2 +- altosui/AltosFlightStatsTable.java | 2 +- altosui/AltosFlightStatus.java | 2 +- altosui/AltosFlightStatusTableModel.java | 2 +- altosui/AltosFlightStatusUpdate.java | 2 +- altosui/AltosFlightUI.java | 2 +- altosui/AltosFontListener.java | 2 +- altosui/AltosFrame.java | 2 +- altosui/AltosFreqList.java | 2 +- altosui/AltosGraph.java | 2 +- altosui/AltosGraphTime.java | 2 +- altosui/AltosGraphUI.java | 2 +- altosui/AltosHexfile.java | 2 +- altosui/AltosIdleMonitorUI.java | 2 +- altosui/AltosIgniteUI.java | 2 +- altosui/AltosInfoTable.java | 2 +- altosui/AltosKML.java | 2 +- altosui/AltosLanded.java | 2 +- altosui/AltosLaunch.java | 2 +- altosui/AltosLaunchUI.java | 2 +- altosui/AltosLed.java | 2 +- altosui/AltosLights.java | 2 +- altosui/AltosPad.java | 2 +- altosui/AltosRomconfig.java | 2 +- altosui/AltosRomconfigUI.java | 2 +- altosui/AltosScanUI.java | 2 +- altosui/AltosSerial.java | 2 +- altosui/AltosSerialInUseException.java | 2 +- altosui/AltosSiteMap.java | 2 +- altosui/AltosSiteMapCache.java | 2 +- altosui/AltosSiteMapPreload.java | 2 +- altosui/AltosSiteMapTile.java | 2 +- altosui/AltosUI.java | 2 +- altosui/AltosUIListener.java | 2 +- altosui/AltosUIPreferences.java | 2 +- altosui/AltosUSBDevice.java | 2 +- altosui/AltosVersion.java.in | 2 +- altosui/AltosVoice.java | 2 +- altosui/AltosWriter.java | 2 +- altosui/GrabNDrag.java | 2 +- altosui/Makefile.am | 26 +++++++++++++------------- 77 files changed, 89 insertions(+), 89 deletions(-) (limited to 'altosui/AltosEepromDownload.java') diff --git a/.gitignore b/.gitignore index 782be7f6..9f33ea3c 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +*~ *.a *.adb *.asm @@ -41,7 +42,6 @@ autom4te.cache config.* config.h config.h.in -config.h.in~ config.log config.status build-stamp diff --git a/altosui/Altos.java b/altosui/Altos.java index d3aad6b2..cd17a93e 100644 --- a/altosui/Altos.java +++ b/altosui/Altos.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.util.*; diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index de6c90a1..a158eb21 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosBTDevice.java b/altosui/AltosBTDevice.java index a6eee085..5e353fdd 100644 --- a/altosui/AltosBTDevice.java +++ b/altosui/AltosBTDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosBTDeviceIterator.java b/altosui/AltosBTDeviceIterator.java index 8d9e6fe6..58ed86d5 100644 --- a/altosui/AltosBTDeviceIterator.java +++ b/altosui/AltosBTDeviceIterator.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosBTKnown.java b/altosui/AltosBTKnown.java index ad0672c6..6a8e53cb 100644 --- a/altosui/AltosBTKnown.java +++ b/altosui/AltosBTKnown.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosBTManage.java b/altosui/AltosBTManage.java index a411c83e..aeb964bb 100644 --- a/altosui/AltosBTManage.java +++ b/altosui/AltosBTManage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosCSV.java b/altosui/AltosCSV.java index c672b78f..c876d9ca 100644 --- a/altosui/AltosCSV.java +++ b/altosui/AltosCSV.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.io.*; diff --git a/altosui/AltosCSVUI.java b/altosui/AltosCSVUI.java index a28c4ca6..2702668b 100644 --- a/altosui/AltosCSVUI.java +++ b/altosui/AltosCSVUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosChannelMenu.java b/altosui/AltosChannelMenu.java index d7e7f58f..0249a0bd 100644 --- a/altosui/AltosChannelMenu.java +++ b/altosui/AltosChannelMenu.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosCompanionInfo.java b/altosui/AltosCompanionInfo.java index 16c972b3..4ba8fe98 100644 --- a/altosui/AltosCompanionInfo.java +++ b/altosui/AltosCompanionInfo.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfig.java b/altosui/AltosConfig.java index 0b386ac9..cae41858 100644 --- a/altosui/AltosConfig.java +++ b/altosui/AltosConfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigFreqUI.java b/altosui/AltosConfigFreqUI.java index 4f8bd0f2..7958a21c 100644 --- a/altosui/AltosConfigFreqUI.java +++ b/altosui/AltosConfigFreqUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigTD.java b/altosui/AltosConfigTD.java index f5d30250..324a5988 100644 --- a/altosui/AltosConfigTD.java +++ b/altosui/AltosConfigTD.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigTDUI.java b/altosui/AltosConfigTDUI.java index f653d941..f2058f69 100644 --- a/altosui/AltosConfigTDUI.java +++ b/altosui/AltosConfigTDUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigUI.java b/altosui/AltosConfigUI.java index b0624ef2..62394fa6 100644 --- a/altosui/AltosConfigUI.java +++ b/altosui/AltosConfigUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosConfigureUI.java b/altosui/AltosConfigureUI.java index b46c1fae..da82e8e0 100644 --- a/altosui/AltosConfigureUI.java +++ b/altosui/AltosConfigureUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDataChooser.java b/altosui/AltosDataChooser.java index b003a606..4bd51c39 100644 --- a/altosui/AltosDataChooser.java +++ b/altosui/AltosDataChooser.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDataPoint.java b/altosui/AltosDataPoint.java index 80f62c2c..5e077320 100644 --- a/altosui/AltosDataPoint.java +++ b/altosui/AltosDataPoint.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package AltosUI; +package altosui; interface AltosDataPoint { int version(); diff --git a/altosui/AltosDataPointReader.java b/altosui/AltosDataPointReader.java index 371c48cb..821b0771 100644 --- a/altosui/AltosDataPointReader.java +++ b/altosui/AltosDataPointReader.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package AltosUI; +package altosui; import java.io.IOException; import java.text.ParseException; diff --git a/altosui/AltosDebug.java b/altosui/AltosDebug.java index 4e394011..23e38bc0 100644 --- a/altosui/AltosDebug.java +++ b/altosui/AltosDebug.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.io.*; diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 2e3f26bd..62258814 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDevice.java b/altosui/AltosDevice.java index dc045d7b..1b5c1a91 100644 --- a/altosui/AltosDevice.java +++ b/altosui/AltosDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosDeviceDialog.java b/altosui/AltosDeviceDialog.java index 7ab08b30..fa9d0013 100644 --- a/altosui/AltosDeviceDialog.java +++ b/altosui/AltosDeviceDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.util.*; diff --git a/altosui/AltosDialog.java b/altosui/AltosDialog.java index 1de11317..ff38c3e4 100644 --- a/altosui/AltosDialog.java +++ b/altosui/AltosDialog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosDisplayThread.java b/altosui/AltosDisplayThread.java index 0cf942e7..cf69c414 100644 --- a/altosui/AltosDisplayThread.java +++ b/altosui/AltosDisplayThread.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromDelete.java b/altosui/AltosEepromDelete.java index 21f09d0e..73f3a00f 100644 --- a/altosui/AltosEepromDelete.java +++ b/altosui/AltosEepromDelete.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromDownload.java b/altosui/AltosEepromDownload.java index a4d6b26e..b04890cd 100644 --- a/altosui/AltosEepromDownload.java +++ b/altosui/AltosEepromDownload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromList.java b/altosui/AltosEepromList.java index 2a88134c..6a656215 100644 --- a/altosui/AltosEepromList.java +++ b/altosui/AltosEepromList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromManage.java b/altosui/AltosEepromManage.java index 27b03bed..563c90b3 100644 --- a/altosui/AltosEepromManage.java +++ b/altosui/AltosEepromManage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromMonitor.java b/altosui/AltosEepromMonitor.java index daf8d0ba..75643442 100644 --- a/altosui/AltosEepromMonitor.java +++ b/altosui/AltosEepromMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosEepromSelect.java b/altosui/AltosEepromSelect.java index cb242183..4ad78896 100644 --- a/altosui/AltosEepromSelect.java +++ b/altosui/AltosEepromSelect.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.util.*; diff --git a/altosui/AltosFlash.java b/altosui/AltosFlash.java index 996456fd..bd0c8a50 100644 --- a/altosui/AltosFlash.java +++ b/altosui/AltosFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlashUI.java b/altosui/AltosFlashUI.java index 01421de9..66991d10 100644 --- a/altosui/AltosFlashUI.java +++ b/altosui/AltosFlashUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightDisplay.java b/altosui/AltosFlightDisplay.java index e677fd6f..826f9522 100644 --- a/altosui/AltosFlightDisplay.java +++ b/altosui/AltosFlightDisplay.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import org.altusmetrum.AltosLib.*; diff --git a/altosui/AltosFlightInfoTableModel.java b/altosui/AltosFlightInfoTableModel.java index cb798bcb..77969a89 100644 --- a/altosui/AltosFlightInfoTableModel.java +++ b/altosui/AltosFlightInfoTableModel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStats.java b/altosui/AltosFlightStats.java index d37f90b8..ab094c80 100644 --- a/altosui/AltosFlightStats.java +++ b/altosui/AltosFlightStats.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatsTable.java b/altosui/AltosFlightStatsTable.java index bcfdd84e..87ba6aa8 100644 --- a/altosui/AltosFlightStatsTable.java +++ b/altosui/AltosFlightStatsTable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatus.java b/altosui/AltosFlightStatus.java index ee03698b..6a351004 100644 --- a/altosui/AltosFlightStatus.java +++ b/altosui/AltosFlightStatus.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatusTableModel.java b/altosui/AltosFlightStatusTableModel.java index 919c7704..c2cf8cd1 100644 --- a/altosui/AltosFlightStatusTableModel.java +++ b/altosui/AltosFlightStatusTableModel.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightStatusUpdate.java b/altosui/AltosFlightStatusUpdate.java index a0b4e304..d70fc7f8 100644 --- a/altosui/AltosFlightStatusUpdate.java +++ b/altosui/AltosFlightStatusUpdate.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFlightUI.java b/altosui/AltosFlightUI.java index 08e8550f..ddc54cbd 100644 --- a/altosui/AltosFlightUI.java +++ b/altosui/AltosFlightUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFontListener.java b/altosui/AltosFontListener.java index a0cb8a56..0dda0f29 100644 --- a/altosui/AltosFontListener.java +++ b/altosui/AltosFontListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; public interface AltosFontListener { void font_size_changed(int font_size); diff --git a/altosui/AltosFrame.java b/altosui/AltosFrame.java index cdbfe7d3..70598634 100644 --- a/altosui/AltosFrame.java +++ b/altosui/AltosFrame.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosFreqList.java b/altosui/AltosFreqList.java index a17afce6..1bbc97c6 100644 --- a/altosui/AltosFreqList.java +++ b/altosui/AltosFreqList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosGraph.java b/altosui/AltosGraph.java index a61a0976..54d2bb0b 100644 --- a/altosui/AltosGraph.java +++ b/altosui/AltosGraph.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package AltosUI; +package altosui; import java.io.*; diff --git a/altosui/AltosGraphTime.java b/altosui/AltosGraphTime.java index f00170ec..0955f6e6 100644 --- a/altosui/AltosGraphTime.java +++ b/altosui/AltosGraphTime.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package AltosUI; +package altosui; import java.lang.*; import java.io.*; diff --git a/altosui/AltosGraphUI.java b/altosui/AltosGraphUI.java index b571fc7d..527a7d28 100644 --- a/altosui/AltosGraphUI.java +++ b/altosui/AltosGraphUI.java @@ -2,7 +2,7 @@ // Copyright (c) 2010 Anthony Towns // GPL v2 or later -package AltosUI; +package altosui; import java.io.*; import java.util.ArrayList; diff --git a/altosui/AltosHexfile.java b/altosui/AltosHexfile.java index 435f13ee..d52b46c3 100644 --- a/altosui/AltosHexfile.java +++ b/altosui/AltosHexfile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.io.*; diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index f67644fc..46ca3e5d 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosIgniteUI.java b/altosui/AltosIgniteUI.java index 8c4c939f..78eba8e6 100644 --- a/altosui/AltosIgniteUI.java +++ b/altosui/AltosIgniteUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosInfoTable.java b/altosui/AltosInfoTable.java index 8caf5a80..c1400976 100644 --- a/altosui/AltosInfoTable.java +++ b/altosui/AltosInfoTable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosKML.java b/altosui/AltosKML.java index 7e3b0e08..ff0734b8 100644 --- a/altosui/AltosKML.java +++ b/altosui/AltosKML.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.io.*; diff --git a/altosui/AltosLanded.java b/altosui/AltosLanded.java index 5c3111a2..a47e1cbd 100644 --- a/altosui/AltosLanded.java +++ b/altosui/AltosLanded.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosLaunch.java b/altosui/AltosLaunch.java index 67512cef..0e493b91 100644 --- a/altosui/AltosLaunch.java +++ b/altosui/AltosLaunch.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.io.*; import java.util.concurrent.*; diff --git a/altosui/AltosLaunchUI.java b/altosui/AltosLaunchUI.java index a4f12997..44481544 100644 --- a/altosui/AltosLaunchUI.java +++ b/altosui/AltosLaunchUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosLed.java b/altosui/AltosLed.java index 4bf43a53..1358cd48 100644 --- a/altosui/AltosLed.java +++ b/altosui/AltosLed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosLights.java b/altosui/AltosLights.java index 92d11212..8bd9e7de 100644 --- a/altosui/AltosLights.java +++ b/altosui/AltosLights.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index 8006190d..0a3f3d65 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosRomconfig.java b/altosui/AltosRomconfig.java index 1e3d7294..0a283e51 100644 --- a/altosui/AltosRomconfig.java +++ b/altosui/AltosRomconfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.io.*; import org.altusmetrum.AltosLib.*; diff --git a/altosui/AltosRomconfigUI.java b/altosui/AltosRomconfigUI.java index 25d8d087..306b8623 100644 --- a/altosui/AltosRomconfigUI.java +++ b/altosui/AltosRomconfigUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosScanUI.java b/altosui/AltosScanUI.java index 534451cb..9da1290f 100644 --- a/altosui/AltosScanUI.java +++ b/altosui/AltosScanUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index 61865bbd..6cee1609 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -19,7 +19,7 @@ * Deal with TeleDongle on a serial port */ -package AltosUI; +package altosui; import java.lang.*; import java.io.*; diff --git a/altosui/AltosSerialInUseException.java b/altosui/AltosSerialInUseException.java index ae97b3d2..7380f331 100644 --- a/altosui/AltosSerialInUseException.java +++ b/altosui/AltosSerialInUseException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; public class AltosSerialInUseException extends Exception { public AltosDevice device; diff --git a/altosui/AltosSiteMap.java b/altosui/AltosSiteMap.java index 4195fc3f..b57edcab 100644 --- a/altosui/AltosSiteMap.java +++ b/altosui/AltosSiteMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosSiteMapCache.java b/altosui/AltosSiteMapCache.java index 6e7e423b..f729a298 100644 --- a/altosui/AltosSiteMapCache.java +++ b/altosui/AltosSiteMapCache.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosSiteMapPreload.java b/altosui/AltosSiteMapPreload.java index 8c0850fa..676b0790 100644 --- a/altosui/AltosSiteMapPreload.java +++ b/altosui/AltosSiteMapPreload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosSiteMapTile.java b/altosui/AltosSiteMapTile.java index 1e1cca5a..34550219 100644 --- a/altosui/AltosSiteMapTile.java +++ b/altosui/AltosSiteMapTile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.image.*; diff --git a/altosui/AltosUI.java b/altosui/AltosUI.java index a1678299..926d66f0 100644 --- a/altosui/AltosUI.java +++ b/altosui/AltosUI.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.event.*; diff --git a/altosui/AltosUIListener.java b/altosui/AltosUIListener.java index e50b30b2..7ee62afc 100644 --- a/altosui/AltosUIListener.java +++ b/altosui/AltosUIListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; public interface AltosUIListener { public void ui_changed(String look_and_feel); diff --git a/altosui/AltosUIPreferences.java b/altosui/AltosUIPreferences.java index 010d8e6a..10ab26c3 100644 --- a/altosui/AltosUIPreferences.java +++ b/altosui/AltosUIPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.io.*; import java.util.*; diff --git a/altosui/AltosUSBDevice.java b/altosui/AltosUSBDevice.java index 0c953cbf..ed5f8307 100644 --- a/altosui/AltosUSBDevice.java +++ b/altosui/AltosUSBDevice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.util.*; import libaltosJNI.*; diff --git a/altosui/AltosVersion.java.in b/altosui/AltosVersion.java.in index d72e0936..b0b3c0cf 100644 --- a/altosui/AltosVersion.java.in +++ b/altosui/AltosVersion.java.in @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; public class AltosVersion { public final static String version = "@VERSION@"; diff --git a/altosui/AltosVoice.java b/altosui/AltosVoice.java index ff83ac29..ab74e0b3 100644 --- a/altosui/AltosVoice.java +++ b/altosui/AltosVoice.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import com.sun.speech.freetts.Voice; import com.sun.speech.freetts.VoiceManager; diff --git a/altosui/AltosWriter.java b/altosui/AltosWriter.java index 9031c268..b7375204 100644 --- a/altosui/AltosWriter.java +++ b/altosui/AltosWriter.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.lang.*; import java.io.*; diff --git a/altosui/GrabNDrag.java b/altosui/GrabNDrag.java index a984c43e..c350efec 100644 --- a/altosui/GrabNDrag.java +++ b/altosui/GrabNDrag.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package AltosUI; +package altosui; import java.awt.*; import java.awt.image.*; diff --git a/altosui/Makefile.am b/altosui/Makefile.am index ca5d2b35..9f75d5e3 100644 --- a/altosui/Makefile.am +++ b/altosui/Makefile.am @@ -112,9 +112,9 @@ LIBALTOS= \ libaltos.dylib \ altos.dll -JAR=AltosUI.jar +JAR=altosui.jar -FATJAR=AltosUI-fat.jar +FATJAR=altosui-fat.jar # Icons ICONDIR=$(top_srcdir)/icon @@ -170,7 +170,7 @@ MACOSX_EXTRA=$(FIRMWARE) WINDOWS_FILES=$(FAT_FILES) altos.dll altos64.dll $(top_srcdir)/telemetrum.inf $(WINDOWS_ICON) -all-local: classes/AltosUI $(JAR) altosui altosui-test altosui-jdb +all-local: classes/altosui $(JAR) altosui altosui-test altosui-jdb clean-local: -rm -rf classes $(JAR) $(FATJAR) \ @@ -207,43 +207,43 @@ endif altosuidir=$(datadir)/java -install-altosuiJAVA: AltosUI.jar +install-altosuiJAVA: altosui.jar @$(NORMAL_INSTALL) test -z "$(altosuidir)" || $(MKDIR_P) "$(DESTDIR)$(altosuidir)" - echo " $(INSTALL_DATA)" "$<" "'$(DESTDIR)$(altosuidir)/AltosUI.jar'"; \ + echo " $(INSTALL_DATA)" "$<" "'$(DESTDIR)$(altosuidir)/altosui.jar'"; \ $(INSTALL_DATA) "$<" "$(DESTDIR)$(altosuidir)" -classes/AltosUI: - mkdir -p classes/AltosUI +classes/altosui: + mkdir -p classes/altosui $(JAR): classaltosui.stamp Manifest.txt $(JAVA_ICON) $(ALTOSLIB_CLASS) jar cfm $@ Manifest.txt \ $(ICONJAR) \ - -C classes AltosUI \ + -C classes altosui \ -C libaltos libaltosJNI $(FATJAR): classaltosui.stamp Manifest-fat.txt $(ALTOSLIB_CLASS) $(FREETTS_CLASS) $(JFREECHART_CLASS) $(JCOMMON_CLASS) $(LIBALTOS) $(JAVA_ICON) jar cfm $@ Manifest-fat.txt \ $(ICONJAR) \ - -C classes AltosUI \ + -C classes altosui \ -C libaltos libaltosJNI Manifest.txt: Makefile - echo 'Main-Class: AltosUI.AltosUI' > $@ + echo 'Main-Class: altosui.AltosUI' > $@ echo "Class-Path: AltosLib.jar $(FREETTS)/freetts.jar $(JFREECHART)/jfreechart.jar $(JCOMMON)/jcommon.jar" >> $@ Manifest-fat.txt: - echo 'Main-Class: AltosUI.AltosUI' > $@ + echo 'Main-Class: altosui.AltosUI' > $@ echo "Class-Path: AltosLib.jar freetts.jar jfreechart.jar jcommon.jar" >> $@ altosui: Makefile echo "#!/bin/sh" > $@ - echo 'exec java -cp "$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="$(altoslibdir)" -jar "$(altosuidir)/AltosUI.jar" "$$@"' >> $@ + echo 'exec java -cp "$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="$(altoslibdir)" -jar "$(altosuidir)/altosui.jar" "$$@"' >> $@ chmod +x $@ altosui-test: Makefile echo "#!/bin/sh" > $@ - echo 'exec java -cp "./*:$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar AltosUI.jar "$$@"' >> $@ + echo 'exec java -cp "./*:$(FREETTS)/*:$(JFREECHART)/*:$(JCOMMON)/*" -Djava.library.path="libaltos/.libs" -jar altosui.jar "$$@"' >> $@ chmod +x $@ altosui-jdb: Makefile -- cgit v1.2.3