From 216405bc49ef2fc0e9941989f054e41f2fef9cfe Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 18 Dec 2013 12:40:22 -0800 Subject: altoslib: Don't close telemetry reader at startup unless something fails Was always closing the file, which led to very little telemetry being received. Signed-off-by: Keith Packard --- altoslib/AltosTelemetryReader.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 405c555b..eeb35cb5 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -124,6 +124,7 @@ public class AltosTelemetryReader extends AltosFlightReader { public AltosTelemetryReader (AltosLink in_link) throws IOException, InterruptedException, TimeoutException { link = in_link; + boolean success = false; try { log = new AltosLog(link); name = link.name; @@ -133,8 +134,10 @@ public class AltosTelemetryReader extends AltosFlightReader { telemetry = AltosPreferences.telemetry(link.serial); set_telemetry(telemetry); link.add_monitor(telem); + success = true; } finally { - close(true); + if (!success) + close(true); } } } -- cgit v1.2.3 From b19a648b667c298d2d9d5ed4ee9db661be058d1a Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 18 Dec 2013 13:09:48 -0800 Subject: altoslib: create eeprom download thread before telling monitor about it Telling the monitor too early resulted in passing a null thread handle, which meant that 'cancel' wouldn't ever work. Signed-off-by: Keith Packard --- altoslib/AltosEepromDownload.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib') diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index 542defee..1b043167 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -239,6 +239,7 @@ public class AltosEepromDownload implements Runnable { public void start() { eeprom_thread = new Thread(this); + monitor.set_thread(eeprom_thread); eeprom_thread.start(); } @@ -255,7 +256,6 @@ public class AltosEepromDownload implements Runnable { monitor.set_states(AltosLib.ao_flight_boost, AltosLib.ao_flight_landed); - monitor.set_thread(eeprom_thread); monitor.start(); } } -- cgit v1.2.3 From dbcf3264f950c4e1d450828c9f161b4c418bee97 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 18 Dec 2013 13:22:45 -0800 Subject: altoslib: Define 3.8 as a good battery and 3.5 as a good igniter Use defined values everywhere instead of copying. Adjust battery up to 3.8 to ensure there's enough voltage to not trip the comparators Signed-off-by: Keith Packard --- altoslib/AltosLib.java | 5 +++++ altosui/AltosAscent.java | 4 ++-- altosui/AltosDescent.java | 4 ++-- altosui/AltosPad.java | 8 ++++---- 4 files changed, 13 insertions(+), 8 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 36a2ab32..efbc3ddb 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -143,6 +143,11 @@ public class AltosLib { /* Bluetooth "identifier" (bluetooth sucks) */ public final static String bt_product_telebt = "TeleBT"; + /* "good" voltages */ + + public final static double ao_battery_good = 3.8; + public final static double ao_igniter_good = 3.5; + /* Telemetry modes */ public static final int ao_telemetry_off = 0; public static final int ao_telemetry_min = 1; diff --git a/altosui/AltosAscent.java b/altosui/AltosAscent.java index 1d9af546..ba4fc614 100644 --- a/altosui/AltosAscent.java +++ b/altosui/AltosAscent.java @@ -285,7 +285,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { class Apogee extends AscentStatus { void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.apogee_voltage); - lights.set(state.apogee_voltage > 3.7); + lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good); } public Apogee (GridBagLayout layout, int y) { super(layout, y, "Apogee Igniter Voltage"); @@ -297,7 +297,7 @@ public class AltosAscent extends JComponent implements AltosFlightDisplay { class Main extends AscentStatus { void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.main_voltage); - lights.set(state.main_voltage > 3.7); + lights.set(state.main_voltage >= AltosLib.ao_igniter_good); } public Main (GridBagLayout layout, int y) { super(layout, y, "Main Igniter Voltage"); diff --git a/altosui/AltosDescent.java b/altosui/AltosDescent.java index 77776ff2..e73d990c 100644 --- a/altosui/AltosDescent.java +++ b/altosui/AltosDescent.java @@ -323,7 +323,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Apogee extends DescentStatus { void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.apogee_voltage); - lights.set(state.apogee_voltage > 3.7); + lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good); } public Apogee (GridBagLayout layout, int y) { super(layout, y, "Apogee Igniter Voltage"); @@ -335,7 +335,7 @@ public class AltosDescent extends JComponent implements AltosFlightDisplay { class Main extends DescentStatus { void show (AltosState state, AltosListenerState listener_state) { show("%4.2f V", state.main_voltage); - lights.set(state.main_voltage > 3.7); + lights.set(state.main_voltage >= AltosLib.ao_igniter_good); } public Main (GridBagLayout layout, int y) { super(layout, y, "Main Igniter Voltage"); diff --git a/altosui/AltosPad.java b/altosui/AltosPad.java index b35bd23a..06a0f1ef 100644 --- a/altosui/AltosPad.java +++ b/altosui/AltosPad.java @@ -180,7 +180,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { hide(); else { show("%4.2f V", state.battery_voltage); - lights.set(state.battery_voltage > 3.7); + lights.set(state.battery_voltage >= AltosLib.ao_battery_good); } } public Battery (GridBagLayout layout, int y) { @@ -196,7 +196,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { hide(); else { show("%4.2f V", state.apogee_voltage); - lights.set(state.apogee_voltage > 3.7); + lights.set(state.apogee_voltage >= AltosLib.ao_igniter_good); } } public Apogee (GridBagLayout layout, int y) { @@ -212,7 +212,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { hide(); else { show("%4.2f V", state.main_voltage); - lights.set(state.main_voltage > 3.7); + lights.set(state.main_voltage >= AltosLib.ao_igniter_good); } } public Main (GridBagLayout layout, int y) { @@ -287,7 +287,7 @@ public class AltosPad extends JComponent implements AltosFlightDisplay { hide(); else { show("%4.2f V", listener_state.battery); - lights.set(listener_state.battery > 3.7); + lights.set(listener_state.battery > AltosLib.ao_battery_good); } } public ReceiverBattery (GridBagLayout layout, int y) { -- cgit v1.2.3 From c1bfe09b6d3eb28d0c7cfe07a248843cf81bcd25 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 18 Dec 2013 13:36:04 -0800 Subject: altosui: Remove some debug printfs Signed-off-by: Keith Packard --- altoslib/AltosIdleMonitor.java | 3 --- altoslib/AltosMs5607.java | 8 -------- altosui/AltosIdleMonitorUI.java | 2 -- 3 files changed, 13 deletions(-) (limited to 'altoslib') diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index c816c202..d9d71143 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -91,14 +91,11 @@ public class AltosIdleMonitor extends Thread { } public void abort() throws InterruptedException { - System.out.printf("Attempting to abort monitor thread\n"); while (isAlive()) { - System.out.printf("Interrupting\n"); interrupt(); link.abort_reply(); Thread.sleep(100); } - System.out.printf("Appears to be dead now\n"); join(); } diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 23d65ea9..2319d5b8 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -85,12 +85,10 @@ public class AltosMs5607 { } public boolean parse_line(String line) { - System.out.printf ("parse %s\n", line); String[] items = line.split("\\s+"); if (line.startsWith("Pressure:")) { if (items.length >= 2) { raw_pres = Integer.parseInt(items[1]); - System.out.printf ("raw_pres %d\n", raw_pres); } } else if (line.startsWith("Temperature:")) { if (items.length >= 2) @@ -99,10 +97,8 @@ public class AltosMs5607 { if (items.length >= 3) reserved = Integer.parseInt(items[2]); } else if (line.startsWith("ms5607 sens:")) { - System.out.printf ("found sens length %d\n", items.length); if (items.length >= 3) { sens = Integer.parseInt(items[2]); - System.out.printf ("sens %d\n", sens); } } else if (line.startsWith("ms5607 off:")) { if (items.length >= 3) @@ -156,13 +152,9 @@ public class AltosMs5607 { throw new TimeoutException(); } if (!parse_line(line)) { - System.out.printf ("stop parsing at %s\n", line); break; } } - System.out.printf ("sens %d off %d tcs %d tco %d tref %d tempsens %d crc %d pres %d temp %d\n", - sens, off, tcs, tco, tref, tempsens, crc, raw_pres, raw_temp); convert(); - System.out.printf ("pa %d cc %d\n", pa, cc); } } diff --git a/altosui/AltosIdleMonitorUI.java b/altosui/AltosIdleMonitorUI.java index 6da920e2..6a79604e 100644 --- a/altosui/AltosIdleMonitorUI.java +++ b/altosui/AltosIdleMonitorUI.java @@ -195,13 +195,11 @@ public class AltosIdleMonitorUI extends AltosUIFrame implements AltosFlightDispl addWindowListener(new WindowAdapter() { @Override public void windowClosing(WindowEvent e) { - System.out.printf("Closing idle monitor window\n"); try { disconnect(); } catch (Exception ex) { System.out.println(Arrays.toString(ex.getStackTrace())); } - System.out.printf("hiding\n"); setVisible(false); dispose(); AltosUIPreferences.unregister_font_listener(AltosIdleMonitorUI.this); -- cgit v1.2.3