diff options
author | Bdale Garbee <bdale@gag.com> | 2015-02-07 22:39:54 -0700 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2015-02-07 22:39:54 -0700 |
commit | f766a457323268857b3f2dfc7f42427437b71cb7 (patch) | |
tree | 8afc8a661d682fc34b16fc0b1b44f2844d34f336 /altoslib | |
parent | db51224af01731e7323f6f696a7397d64eb80b92 (diff) | |
parent | e2cefd8593d269ce603aaf33f4a53a5c2dcb3350 (diff) |
Merge branch 'branch-1.6' into debian
Conflicts:
ChangeLog
altoslib/AltosTelemetryReader.java
configure.ac
Diffstat (limited to 'altoslib')
102 files changed, 985 insertions, 323 deletions
diff --git a/altoslib/AltosAccel.java b/altoslib/AltosAccel.java index d91da4da..b11dc3a1 100644 --- a/altoslib/AltosAccel.java +++ b/altoslib/AltosAccel.java @@ -15,9 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; -public class AltosAccel extends AltosUnits { +import java.io.*; + +public class AltosAccel extends AltosUnits implements Serializable { public double value(double v, boolean imperial_units) { if (imperial_units) @@ -46,4 +48,4 @@ public class AltosAccel extends AltosUnits { public int show_fraction(int width, boolean imperial_units) { return width / 9; } -}
\ No newline at end of file +} diff --git a/altoslib/AltosCRCException.java b/altoslib/AltosCRCException.java index 507c446b..4167aecf 100644 --- a/altoslib/AltosCRCException.java +++ b/altoslib/AltosCRCException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosCRCException extends Exception { public int rssi; diff --git a/altoslib/AltosCSV.java b/altoslib/AltosCSV.java index 4a9278d9..02f7806f 100644 --- a/altoslib/AltosCSV.java +++ b/altoslib/AltosCSV.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -158,21 +158,14 @@ public class AltosCSV implements AltosWriter { } void write_advanced_header() { - out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z"); + out.printf("accel_x,accel_y,accel_z,gyro_x,gyro_y,gyro_z,mag_x,mag_y,mag_z"); } void write_advanced(AltosState state) { - AltosIMU imu = state.imu; - AltosMag mag = state.mag; - - if (imu == null) - imu = new AltosIMU(); - if (mag == null) - mag = new AltosMag(); out.printf("%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f,%7.2f", - imu.accel_x, imu.accel_y, imu.accel_z, - imu.gyro_x, imu.gyro_y, imu.gyro_z, - mag.x, mag.y, mag.z); + state.accel_along(), state.accel_across(), state.accel_through(), + state.gyro_roll(), state.gyro_pitch(), state.gyro_yaw(), + state.mag_along(), state.mag_across(), state.mag_through()); } void write_gps_header() { @@ -381,7 +374,7 @@ public class AltosCSV implements AltosWriter { has_basic = true; if (state.battery_voltage != AltosLib.MISSING) has_battery = true; - if (state.imu != null || state.mag != null) + if (state.accel_across() != AltosLib.MISSING) has_advanced = true; if (state.gps != null) { has_gps = true; diff --git a/altoslib/AltosCompanion.java b/altoslib/AltosCompanion.java index 47deb2a3..8992b018 100644 --- a/altoslib/AltosCompanion.java +++ b/altoslib/AltosCompanion.java @@ -15,9 +15,11 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; -public class AltosCompanion { +import java.io.*; + +public class AltosCompanion implements Serializable { public final static int board_id_telescience = 0x0a; public final static int MAX_CHANNELS = 12; diff --git a/altoslib/AltosConfigData.java b/altoslib/AltosConfigData.java index fc1f2442..d8f4d945 100644 --- a/altoslib/AltosConfigData.java +++ b/altoslib/AltosConfigData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.*; import java.text.*; @@ -90,6 +90,19 @@ public class AltosConfigData implements Iterable<String> { public int tracker_motion; public int tracker_interval; + /* HAS_GYRO */ + public int accel_zero_along, accel_zero_across, accel_zero_through; + + /* ms5607 data */ + public int ms5607_reserved; + public int ms5607_sens; + public int ms5607_off; + public int ms5607_tcs; + public int ms5607_tco; + public int ms5607_tref; + public int ms5607_tempsens; + public int ms5607_crc; + public static String get_string(String line, String label) throws ParseException { if (line.startsWith(label)) { String quoted = line.substring(label.length()).trim(); @@ -266,6 +279,10 @@ public class AltosConfigData implements Iterable<String> { storage_size = -1; storage_erase_unit = -1; stored_flight = 0; + + accel_zero_along = -1; + accel_zero_across = -1; + accel_zero_through = -1; } public void parse_line(String line) { @@ -282,6 +299,15 @@ public class AltosConfigData implements Iterable<String> { /* Version also contains MS5607 info, which we ignore here */ + try { ms5607_reserved = get_int(line, "ms5607 reserved:"); } catch (Exception e) {} + try { ms5607_sens = get_int(line, "ms5607 sens:"); } catch (Exception e) {} + try { ms5607_off = get_int(line, "ms5607 off:"); } catch (Exception e) {} + try { ms5607_tcs = get_int(line, "ms5607 tcs:"); } catch (Exception e) {} + try { ms5607_tco = get_int(line, "ms5607 tco:"); } catch (Exception e) {} + try { ms5607_tref = get_int(line, "ms5607 tref:"); } catch (Exception e) {} + try { ms5607_tempsens = get_int(line, "ms5607 tempsens:"); } catch (Exception e) {} + try { ms5607_crc = get_int(line, "ms5607 crc:"); } catch (Exception e) {} + /* Config show replies */ /* HAS_FLIGHT */ @@ -361,6 +387,18 @@ public class AltosConfigData implements Iterable<String> { /* Log listing replies */ try { get_int(line, "flight"); stored_flight++; } catch (Exception e) {} + + /* HAS_GYRO */ + try { + if (line.startsWith("IMU call along")) { + String[] bits = line.split("\\s+"); + if (bits.length >= 8) { + accel_zero_along = Integer.parseInt(bits[3]); + accel_zero_across = Integer.parseInt(bits[5]); + accel_zero_through = Integer.parseInt(bits[7]); + } + } + } catch (Exception e) {} } public AltosConfigData() { @@ -539,6 +577,14 @@ public class AltosConfigData implements Iterable<String> { dest.set_tracker_interval(tracker_interval); } + public boolean log_has_state() { + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_TELEGPS: + return false; + } + return true; + } + public void save(AltosLink link, boolean remote) throws InterruptedException, TimeoutException { /* HAS_FLIGHT */ @@ -637,6 +683,9 @@ public class AltosConfigData implements Iterable<String> { if (tracker_motion >= 0 && tracker_interval >= 0) link.printf("c t %d %d\n", tracker_motion, tracker_interval); + /* HAS_GYRO */ + /* UI doesn't support accel cal */ + link.printf("c w\n"); link.flush_output(); } diff --git a/altoslib/AltosConfigDataException.java b/altoslib/AltosConfigDataException.java index a932d3e3..11aa4d24 100644 --- a/altoslib/AltosConfigDataException.java +++ b/altoslib/AltosConfigDataException.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosConfigDataException extends Exception { diff --git a/altoslib/AltosConfigValues.java b/altoslib/AltosConfigValues.java index 3f0a7075..cfe9fc8b 100644 --- a/altoslib/AltosConfigValues.java +++ b/altoslib/AltosConfigValues.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public interface AltosConfigValues { /* set and get all of the dialog values */ diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 18878c02..a5eb7ff8 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -18,7 +18,7 @@ /* * Sensor data conversion functions */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosConvert { /* diff --git a/altoslib/AltosDebug.java b/altoslib/AltosDebug.java index e58fbaf2..ef5edc6a 100644 --- a/altoslib/AltosDebug.java +++ b/altoslib/AltosDebug.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; diff --git a/altoslib/AltosDistance.java b/altoslib/AltosDistance.java index 67bb58e9..b0666f33 100644 --- a/altoslib/AltosDistance.java +++ b/altoslib/AltosDistance.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosDistance extends AltosUnits { diff --git a/altoslib/AltosEeprom.java b/altoslib/AltosEeprom.java index 532c9f1d..777988e7 100644 --- a/altoslib/AltosEeprom.java +++ b/altoslib/AltosEeprom.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index 4d12f564..19a8807d 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; import java.util.concurrent.*; @@ -75,7 +75,8 @@ public class AltosEepromChunk { case AltosLib.AO_LOG_FORMAT_TELESCIENCE: break; case AltosLib.AO_LOG_FORMAT_TELEMEGA: - eeprom = new AltosEepromMega(this, offset); + case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD: + eeprom = new AltosEepromMega(this, offset, log_format); break; case AltosLib.AO_LOG_FORMAT_TELEMETRUM: eeprom = new AltosEepromMetrum2(this, offset); diff --git a/altoslib/AltosEepromDownload.java b/altoslib/AltosEepromDownload.java index a448ee64..9598bd93 100644 --- a/altoslib/AltosEepromDownload.java +++ b/altoslib/AltosEepromDownload.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -75,7 +75,8 @@ public class AltosEepromDownload implements Runnable { } boolean done; - boolean start; + int prev_state; + int state_block; void LogEeprom(AltosEeprom r) throws IOException { if (r.cmd != AltosLib.AO_LOG_INVALID) { @@ -140,7 +141,6 @@ public class AltosEepromDownload implements Runnable { state = new AltosState(); done = false; - start = true; if (flights.config_data.serial < 0) throw new IOException("no serial number found"); @@ -154,12 +154,8 @@ public class AltosEepromDownload implements Runnable { /* Now scan the eeprom, reading blocks of data and converting to .eeprom file form */ state_block = log.start_block; + prev_state = AltosLib.ao_flight_startup; for (block = log.start_block; !done && block < log.end_block; block++) { - monitor.set_value(state.state_name(), - state.state, - block - state_block, - block - log.start_block); - AltosEepromChunk eechunk = new AltosEepromChunk(link, block, block == log.start_block); /* @@ -177,6 +173,16 @@ public class AltosEepromDownload implements Runnable { } CaptureEeprom (eechunk, log_format); + + if (state.state != prev_state && state.state != AltosLib.ao_flight_invalid) { + state_block = block; + prev_state = state.state; + } + + monitor.set_value(state.state_name(), + state.state, + block - state_block, + block - log.start_block); } CheckFile(true); if (eeprom_file != null) { @@ -254,7 +260,10 @@ public class AltosEepromDownload implements Runnable { flights = given_flights; success = false; - monitor.set_states(AltosLib.ao_flight_boost, AltosLib.ao_flight_landed); + if (flights.config_data.log_has_state()) + monitor.set_states(AltosLib.ao_flight_boost, AltosLib.ao_flight_landed); + else + monitor.set_states(AltosLib.ao_flight_invalid, AltosLib.ao_flight_invalid); monitor.start(); } diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index a1579b55..c8443549 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -94,7 +94,8 @@ public class AltosEepromFile extends AltosStateIterable { case AltosLib.AO_LOG_FORMAT_TELEMETRY: case AltosLib.AO_LOG_FORMAT_TELESCIENCE: case AltosLib.AO_LOG_FORMAT_TELEMEGA: - body = new AltosEepromIterable(AltosEepromMega.read(input)); + case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD: + body = new AltosEepromIterable(AltosEepromMega.read(input, start.log_format)); break; case AltosLib.AO_LOG_FORMAT_TELEMETRUM: body = new AltosEepromIterable(AltosEepromMetrum2.read(input)); diff --git a/altoslib/AltosEepromGPS.java b/altoslib/AltosEepromGPS.java index 8c991a6e..96cfc0e1 100644 --- a/altoslib/AltosEepromGPS.java +++ b/altoslib/AltosEepromGPS.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromHeader.java b/altoslib/AltosEepromHeader.java index 71030655..fc4e9caa 100644 --- a/altoslib/AltosEepromHeader.java +++ b/altoslib/AltosEepromHeader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -25,7 +25,7 @@ public class AltosEepromHeader extends AltosEeprom { public int cmd; public String data; - public int config_a, config_b; + public int config_a, config_b, config_c; public boolean last; public boolean valid; @@ -93,6 +93,9 @@ public class AltosEepromHeader extends AltosEeprom { state.make_baro(); state.baro.crc = config_a; break; + case AltosLib.AO_LOG_IMU_CAL: + state.set_accel_zero(config_a, config_b, config_c); + break; case AltosLib.AO_LOG_SOFTWARE_VERSION: state.set_firmware_version(data); break; @@ -100,7 +103,10 @@ public class AltosEepromHeader extends AltosEeprom { case AltosLib.AO_LOG_APOGEE_LOCKOUT: case AltosLib.AO_LOG_RADIO_RATE: case AltosLib.AO_LOG_IGNITE_MODE: + break; case AltosLib.AO_LOG_PAD_ORIENTATION: + state.set_pad_orientation(config_a); + break; case AltosLib.AO_LOG_RADIO_ENABLE: case AltosLib.AO_LOG_AES_KEY: case AltosLib.AO_LOG_APRS: @@ -177,11 +183,17 @@ public class AltosEepromHeader extends AltosEeprom { case AltosLib.AO_LOG_BARO_CRC: out.printf ("# Baro crc: %d\n", config_a); break; + case AltosLib.AO_LOG_IMU_CAL: + out.printf ("# IMU cal: %d %d %d\n", config_a, config_b, config_c); + break; case AltosLib.AO_LOG_FREQUENCY: case AltosLib.AO_LOG_APOGEE_LOCKOUT: case AltosLib.AO_LOG_RADIO_RATE: case AltosLib.AO_LOG_IGNITE_MODE: + break; case AltosLib.AO_LOG_PAD_ORIENTATION: + out.printf("# Pad orientation: %d\n", config_a); + break; case AltosLib.AO_LOG_RADIO_ENABLE: case AltosLib.AO_LOG_AES_KEY: case AltosLib.AO_LOG_APRS: @@ -273,6 +285,14 @@ public class AltosEepromHeader extends AltosEeprom { cmd = AltosLib.AO_LOG_INVALID; data = tokens[2]; } + } else if (tokens[0].equals("IMU") && tokens[1].equals("cal")) { + cmd = AltosLib.AO_LOG_IMU_CAL; + config_a = Integer.parseInt(tokens[3]); + config_b = Integer.parseInt(tokens[5]); + config_c = Integer.parseInt(tokens[7]); + } else if (tokens[0].equals("Pad") && tokens[1].equals("orientation:")) { + cmd = AltosLib.AO_LOG_PAD_ORIENTATION; + config_a = Integer.parseInt(tokens[2]); } else valid = false; } catch (Exception e) { diff --git a/altoslib/AltosEepromIterable.java b/altoslib/AltosEepromIterable.java index dd0afd9f..94487ab5 100644 --- a/altoslib/AltosEepromIterable.java +++ b/altoslib/AltosEepromIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromList.java b/altoslib/AltosEepromList.java index 740499d3..39768a21 100644 --- a/altoslib/AltosEepromList.java +++ b/altoslib/AltosEepromList.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromLog.java b/altoslib/AltosEepromLog.java index 5a11fa54..0fc82ab4 100644 --- a/altoslib/AltosEepromLog.java +++ b/altoslib/AltosEepromLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; import java.util.concurrent.*; diff --git a/altoslib/AltosEepromMega.java b/altoslib/AltosEepromMega.java index adaa7f31..c2edcf23 100644 --- a/altoslib/AltosEepromMega.java +++ b/altoslib/AltosEepromMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -26,6 +26,8 @@ public class AltosEepromMega extends AltosEeprom { public static final int max_sat = 12; + private int log_format; + public int record_length() { return record_length; } /* AO_LOG_FLIGHT elements */ @@ -35,9 +37,36 @@ public class AltosEepromMega extends AltosEeprom { public int ground_accel_along() { return data16(8); } public int ground_accel_across() { return data16(10); } public int ground_accel_through() { return data16(12); } - public int ground_roll() { return data16(14); } - public int ground_pitch() { return data16(16); } - public int ground_yaw() { return data16(18); } + public int ground_roll() { + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_TELEMEGA: + return data32(16); + case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD: + return data16(14); + default: + return AltosLib.MISSING; + } + } + public int ground_pitch() { + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_TELEMEGA: + return data32(20); + case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD: + return data16(16); + default: + return AltosLib.MISSING; + } + } + public int ground_yaw() { + switch (log_format) { + case AltosLib.AO_LOG_FORMAT_TELEMEGA: + return data32(24); + case AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD: + return data16(18); + default: + return AltosLib.MISSING; + } + } /* AO_LOG_STATE elements */ public int state() { return data16(0); } @@ -89,7 +118,8 @@ public class AltosEepromMega extends AltosEeprom { public int svid(int n) { return data8(2 + n * 2); } public int c_n(int n) { return data8(2 + n * 2 + 1); } - public AltosEepromMega (AltosEepromChunk chunk, int start) throws ParseException { + public AltosEepromMega (AltosEepromChunk chunk, int start, int log_format) throws ParseException { + this.log_format = log_format; parse_chunk(chunk, start); } @@ -119,6 +149,12 @@ public class AltosEepromMega extends AltosEeprom { state.set_flight(flight()); state.set_ground_accel(ground_accel()); state.set_ground_pressure(ground_pres()); + state.set_accel_ground(ground_accel_along(), + ground_accel_across(), + ground_accel_through()); + state.set_gyro_zero(ground_roll() / 512.0, + ground_pitch() / 512.0, + ground_yaw() / 512.0); break; case AltosLib.AO_LOG_STATE: state.set_tick(tick); @@ -128,22 +164,21 @@ public class AltosEepromMega extends AltosEeprom { state.set_tick(tick); state.set_ms5607(pres(), temp()); - AltosIMU imu = new AltosIMU(); - imu.accel_x = AltosIMU.convert_accel(accel_x()); - imu.accel_y = AltosIMU.convert_accel(accel_y()); - imu.accel_z = AltosIMU.convert_accel(accel_z()); + AltosIMU imu = new AltosIMU(accel_y(), /* along */ + accel_x(), /* across */ + accel_z(), /* through */ + gyro_y(), /* roll */ + gyro_x(), /* pitch */ + gyro_z()); /* yaw */ - imu.gyro_x = AltosIMU.convert_gyro(gyro_x()); - imu.gyro_y = AltosIMU.convert_gyro(gyro_y()); - imu.gyro_z = AltosIMU.convert_gyro(gyro_z()); - state.imu = imu; + if (log_format == AltosLib.AO_LOG_FORMAT_TELEMEGA_OLD) + state.check_imu_wrap(imu); - AltosMag mag = new AltosMag(); - mag.x = AltosMag.convert_gauss(mag_x()); - mag.y = AltosMag.convert_gauss(mag_y()); - mag.z = AltosMag.convert_gauss(mag_z()); + state.set_imu(imu); - state.mag = mag; + state.set_mag(new AltosMag(mag_x(), + mag_y(), + mag_z())); state.set_accel(accel()); @@ -221,11 +256,12 @@ public class AltosEepromMega extends AltosEeprom { } } - public AltosEepromMega (String line) { + public AltosEepromMega (String line, int log_format) { + this.log_format = log_format; parse_string(line); } - static public LinkedList<AltosEeprom> read(FileInputStream input) { + static public LinkedList<AltosEeprom> read(FileInputStream input, int log_format) { LinkedList<AltosEeprom> megas = new LinkedList<AltosEeprom>(); for (;;) { @@ -234,7 +270,7 @@ public class AltosEepromMega extends AltosEeprom { if (line == null) break; try { - AltosEepromMega mega = new AltosEepromMega(line); + AltosEepromMega mega = new AltosEepromMega(line, log_format); if (mega.cmd != AltosLib.AO_LOG_INVALID) megas.add(mega); } catch (Exception e) { diff --git a/altoslib/AltosEepromMetrum2.java b/altoslib/AltosEepromMetrum2.java index d9a65989..39425e10 100644 --- a/altoslib/AltosEepromMetrum2.java +++ b/altoslib/AltosEepromMetrum2.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMini.java b/altoslib/AltosEepromMini.java index f197539e..ef13d0a7 100644 --- a/altoslib/AltosEepromMini.java +++ b/altoslib/AltosEepromMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromMonitor.java b/altoslib/AltosEepromMonitor.java index 173a2cd8..35ed5a6e 100644 --- a/altoslib/AltosEepromMonitor.java +++ b/altoslib/AltosEepromMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public interface AltosEepromMonitor { diff --git a/altoslib/AltosEepromTM.java b/altoslib/AltosEepromTM.java index 6d36cf47..2bdd64f0 100644 --- a/altoslib/AltosEepromTM.java +++ b/altoslib/AltosEepromTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosEepromTm.java b/altoslib/AltosEepromTm.java index 81b42f21..36500393 100644 --- a/altoslib/AltosEepromTm.java +++ b/altoslib/AltosEepromTm.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosFile.java b/altoslib/AltosFile.java index ba639a04..a79216a2 100644 --- a/altoslib/AltosFile.java +++ b/altoslib/AltosFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.File; import java.util.*; diff --git a/altoslib/AltosFlash.java b/altoslib/AltosFlash.java index a8519550..e58b652e 100644 --- a/altoslib/AltosFlash.java +++ b/altoslib/AltosFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; diff --git a/altoslib/AltosFlashListener.java b/altoslib/AltosFlashListener.java index 7a51c330..1c7cd77d 100644 --- a/altoslib/AltosFlashListener.java +++ b/altoslib/AltosFlashListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public interface AltosFlashListener { public void position(String label, int percent); diff --git a/altoslib/AltosFlightReader.java b/altoslib/AltosFlightReader.java index be103838..03c53ff4 100644 --- a/altoslib/AltosFlightReader.java +++ b/altoslib/AltosFlightReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; import java.io.*; diff --git a/altoslib/AltosFlightStats.java b/altoslib/AltosFlightStats.java index 1b88cb9f..82e477f8 100644 --- a/altoslib/AltosFlightStats.java +++ b/altoslib/AltosFlightStats.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; @@ -37,6 +37,8 @@ public class AltosFlightStats { public double pad_lat, pad_lon; public boolean has_flight_data; public boolean has_gps; + public boolean has_gps_sats; + public boolean has_gps_detail; public boolean has_flight_adc; public boolean has_battery; public boolean has_rssi; @@ -113,6 +115,7 @@ public class AltosFlightStats { lat = lon = AltosLib.MISSING; has_flight_data = false; has_gps = false; + has_gps_sats = false; has_flight_adc = false; has_battery = false; has_rssi = false; @@ -174,6 +177,10 @@ public class AltosFlightStats { lat = state.gps.lat; lon = state.gps.lon; has_gps = true; + if (state.gps.cc_gps_sat != null) + has_gps_sats = true; + if (state.gps.course != AltosLib.MISSING) + has_gps_detail = true; } if (state.imu != null) has_imu = true; diff --git a/altoslib/AltosFrequency.java b/altoslib/AltosFrequency.java index 6093df49..1dd4819d 100644 --- a/altoslib/AltosFrequency.java +++ b/altoslib/AltosFrequency.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosFrequency { public double frequency; diff --git a/altoslib/AltosGPS.java b/altoslib/AltosGPS.java index 0154e95d..2139efb2 100644 --- a/altoslib/AltosGPS.java +++ b/altoslib/AltosGPS.java @@ -15,12 +15,13 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; import java.util.concurrent.*; +import java.io.*; -public class AltosGPS implements Cloneable { +public class AltosGPS implements Cloneable, Serializable { public final static int MISSING = AltosLib.MISSING; @@ -377,6 +378,7 @@ public class AltosGPS implements Cloneable { public AltosGPS (AltosLink link, AltosConfigData config_data) throws TimeoutException, InterruptedException { boolean says_done = config_data.compare_version("1.0") >= 0; + init(); link.printf("g\n"); for (;;) { String line = link.get_reply_no_dialog(5000); diff --git a/altoslib/AltosGPSSat.java b/altoslib/AltosGPSSat.java index adbcbe61..57491f4d 100644 --- a/altoslib/AltosGPSSat.java +++ b/altoslib/AltosGPSSat.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosGPSSat { public int svid; diff --git a/altoslib/AltosGreatCircle.java b/altoslib/AltosGreatCircle.java index 716eeef9..c48755be 100644 --- a/altoslib/AltosGreatCircle.java +++ b/altoslib/AltosGreatCircle.java @@ -15,11 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.lang.Math; +import java.io.*; -public class AltosGreatCircle implements Cloneable { +public class AltosGreatCircle implements Cloneable, Serializable { public double distance; public double bearing; public double range; diff --git a/altoslib/AltosHeight.java b/altoslib/AltosHeight.java index 8c67e043..c4419ae6 100644 --- a/altoslib/AltosHeight.java +++ b/altoslib/AltosHeight.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosHeight extends AltosUnits { diff --git a/altoslib/AltosHexfile.java b/altoslib/AltosHexfile.java index 9ee64bdc..9f45d65a 100644 --- a/altoslib/AltosHexfile.java +++ b/altoslib/AltosHexfile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.LinkedList; diff --git a/altoslib/AltosHexsym.java b/altoslib/AltosHexsym.java index 52eb81db..0c61fd02 100644 --- a/altoslib/AltosHexsym.java +++ b/altoslib/AltosHexsym.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosHexsym { String name; diff --git a/altoslib/AltosIMU.java b/altoslib/AltosIMU.java index 89d7def4..8c219d9f 100644 --- a/altoslib/AltosIMU.java +++ b/altoslib/AltosIMU.java @@ -15,41 +15,30 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.*; +import java.io.*; -public class AltosIMU implements Cloneable { - public double accel_x; - public double accel_y; - public double accel_z; +public class AltosIMU implements Cloneable, Serializable { + public int accel_along; + public int accel_across; + public int accel_through; - public double gyro_x; - public double gyro_y; - public double gyro_z; + public int gyro_roll; + public int gyro_pitch; + public int gyro_yaw; -/* - * XXX use ground measurements to adjust values - - public double ground_accel_x; - public double ground_accel_y; - public double ground_accel_z; - - public double ground_gyro_x; - public double ground_gyro_y; - public double ground_gyro_z; -*/ - - public static int counts_per_g = 2048; + public static double counts_per_g = 2048.0; - public static double convert_accel(int counts) { - return (double) counts / (double) counts_per_g * (-AltosConvert.GRAVITATIONAL_ACCELERATION); + public static double convert_accel(double counts) { + return counts / counts_per_g * (-AltosConvert.GRAVITATIONAL_ACCELERATION); } public static double counts_per_degsec = 16.4; - public static double convert_gyro(int counts) { - return (double) counts / counts_per_degsec; + public static double convert_gyro(double counts) { + return counts / counts_per_degsec; } public boolean parse_string(String line) { @@ -59,12 +48,12 @@ public class AltosIMU implements Cloneable { String[] items = line.split("\\s+"); if (items.length >= 8) { - accel_x = convert_accel(Integer.parseInt(items[1])); - accel_y = convert_accel(Integer.parseInt(items[2])); - accel_z = convert_accel(Integer.parseInt(items[3])); - gyro_x = convert_gyro(Integer.parseInt(items[5])); - gyro_y = convert_gyro(Integer.parseInt(items[6])); - gyro_z = convert_gyro(Integer.parseInt(items[7])); + accel_along = Integer.parseInt(items[1]); + accel_across = Integer.parseInt(items[2]); + accel_through = Integer.parseInt(items[3]); + gyro_roll = Integer.parseInt(items[5]); + gyro_pitch = Integer.parseInt(items[6]); + gyro_yaw = Integer.parseInt(items[7]); } return true; } @@ -72,13 +61,13 @@ public class AltosIMU implements Cloneable { public AltosIMU clone() { AltosIMU n = new AltosIMU(); - n.accel_x = accel_x; - n.accel_y = accel_y; - n.accel_z = accel_z; + n.accel_along = accel_along; + n.accel_across = accel_across; + n.accel_through = accel_through; - n.gyro_x = gyro_x; - n.gyro_y = gyro_y; - n.gyro_z = gyro_z; + n.gyro_roll = gyro_roll; + n.gyro_pitch = gyro_pitch; + n.gyro_yaw = gyro_yaw; return n; } @@ -93,13 +82,25 @@ public class AltosIMU implements Cloneable { } public AltosIMU() { - accel_x = AltosLib.MISSING; - accel_y = AltosLib.MISSING; - accel_z = AltosLib.MISSING; + accel_along = AltosLib.MISSING; + accel_across = AltosLib.MISSING; + accel_through = AltosLib.MISSING; + + gyro_roll = AltosLib.MISSING; + gyro_pitch = AltosLib.MISSING; + gyro_yaw = AltosLib.MISSING; + } + + public AltosIMU(int accel_along, int accel_across, int accel_through, + int gyro_roll, int gyro_pitch, int gyro_yaw) { + + this.accel_along = accel_along; + this.accel_across = accel_across; + this.accel_through = accel_through; - gyro_x = AltosLib.MISSING; - gyro_y = AltosLib.MISSING; - gyro_z = AltosLib.MISSING; + this.gyro_roll = gyro_roll; + this.gyro_pitch = gyro_pitch; + this.gyro_yaw = gyro_yaw; } public AltosIMU(AltosLink link) throws InterruptedException, TimeoutException { diff --git a/altoslib/AltosIdle.java b/altoslib/AltosIdle.java index 0f723d14..82b18ca2 100644 --- a/altoslib/AltosIdle.java +++ b/altoslib/AltosIdle.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 50745d97..4c5e8285 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -38,6 +38,7 @@ class AltosIdler { static final int idle_sensor_mega = 12; static final int idle_sensor_emini = 13; static final int idle_sensor_tmini = 14; + static final int idle_sensor_tgps = 15; public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException { for (int idler : idlers) { @@ -72,6 +73,10 @@ class AltosIdler { break; case idle_sensor_tmini: AltosSensorTMini.update_state(state, link, config_data); + break; + case idle_sensor_tgps: + AltosSensorTGPS.update_state(state, link, config_data); + break; } if (idle != null) idle.update_state(state); @@ -122,6 +127,9 @@ public class AltosIdleFetch implements AltosStateUpdate { AltosIdler.idle_ms5607, AltosIdler.idle_mma655x, AltosIdler.idle_imu, AltosIdler.idle_mag, AltosIdler.idle_sensor_mega), + new AltosIdler("TeleGPS", + AltosIdler.idle_gps, + AltosIdler.idle_sensor_tgps), }; AltosLink link; @@ -131,8 +139,9 @@ public class AltosIdleFetch implements AltosStateUpdate { public void update_state(AltosState state) throws InterruptedException { try { + /* Fetch config data from remote */ AltosConfigData config_data = new AltosConfigData(link); - state.set_state(AltosLib.ao_flight_startup); + state.set_state(AltosLib.ao_flight_stateless); state.set_serial(config_data.serial); state.set_callsign(config_data.callsign); state.set_ground_accel(config_data.accel_cal_plus); diff --git a/altoslib/AltosIdleMonitor.java b/altoslib/AltosIdleMonitor.java index 85bcff10..4d0968bf 100644 --- a/altoslib/AltosIdleMonitor.java +++ b/altoslib/AltosIdleMonitor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.concurrent.*; @@ -35,20 +35,6 @@ public class AltosIdleMonitor extends Thread { AltosConfigData config_data; AltosGPS gps; - int AltosRSSI() throws TimeoutException, InterruptedException { - link.printf("s\n"); - String line = link.get_reply_no_dialog(5000); - if (line == null) - throw new TimeoutException(); - String[] items = line.split("\\s+"); - if (items.length < 2) - return 0; - if (!items[0].equals("RSSI:")) - return 0; - int rssi = Integer.parseInt(items[1]); - return rssi; - } - void start_link() throws InterruptedException, TimeoutException { if (remote) { link.set_radio_frequency(frequency); @@ -58,26 +44,30 @@ public class AltosIdleMonitor extends Thread { link.flush_input(); } - void stop_link() throws InterruptedException, TimeoutException { + boolean stop_link() throws InterruptedException, TimeoutException { if (remote) link.stop_remote(); + return link.reply_abort; } - void update_state(AltosState state) throws InterruptedException, TimeoutException { + boolean update_state(AltosState state) throws InterruptedException, TimeoutException { boolean worked = false; + boolean aborted = false; try { start_link(); fetch.update_state(state); - worked = true; + if (!link.has_error && !link.reply_abort) + worked = true; } finally { - stop_link(); + aborted = stop_link(); if (worked) { if (remote) state.set_rssi(link.rssi(), 0); listener_state.battery = link.monitor_battery(); } } + return aborted; } public void set_frequency(double in_frequency) { @@ -102,13 +92,17 @@ public class AltosIdleMonitor extends Thread { public void run() { AltosState state = new AltosState(); try { - while (!link.has_error) { + for (;;) { try { link.config_data(); update_state(state); listener.update(state, listener_state); } catch (TimeoutException te) { } + if (link.has_error || link.reply_abort) { + listener.failed(); + break; + } Thread.sleep(1000); } } catch (InterruptedException ie) { diff --git a/altoslib/AltosIdleMonitorListener.java b/altoslib/AltosIdleMonitorListener.java index 4382430c..fdf4be9d 100644 --- a/altoslib/AltosIdleMonitorListener.java +++ b/altoslib/AltosIdleMonitorListener.java @@ -15,8 +15,9 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public interface AltosIdleMonitorListener { public void update(AltosState state, AltosListenerState listener_state); -}
\ No newline at end of file + public void failed(); +} diff --git a/altoslib/AltosIgnite.java b/altoslib/AltosIgnite.java index b458911e..ffb6ed15 100644 --- a/altoslib/AltosIgnite.java +++ b/altoslib/AltosIgnite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.*; import java.io.*; diff --git a/altoslib/AltosKML.java b/altoslib/AltosKML.java index e701fda3..aa80fc21 100644 --- a/altoslib/AltosKML.java +++ b/altoslib/AltosKML.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; diff --git a/altoslib/AltosLatitude.java b/altoslib/AltosLatitude.java index 2b507173..191a46ee 100644 --- a/altoslib/AltosLatitude.java +++ b/altoslib/AltosLatitude.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosLatitude extends AltosLocation { public String pos() { return "N"; } diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index 2e9dc648..b19f9f52 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.*; import java.io.*; @@ -74,6 +74,7 @@ public class AltosLib { public static final int AO_LOG_BARO_TREF = 3006; public static final int AO_LOG_BARO_TEMPSENS = 3007; public static final int AO_LOG_BARO_CRC = 3008; + public static final int AO_LOG_IMU_CAL = 3009; public static final int AO_LOG_SOFTWARE_VERSION = 9999; @@ -113,6 +114,9 @@ public class AltosLib { public final static int product_easymini = 0x0026; public final static int product_telemini = 0x0027; public final static int product_easymega = 0x0028; + public final static int product_usbtrng = 0x0029; + public final static int product_usbrelay = 0x002a; + public final static int product_mpusb = 0x002b; public final static int product_altusmetrum_min = 0x000a; public final static int product_altusmetrum_max = 0x002c; @@ -187,6 +191,7 @@ public class AltosLib { }; public static final String launch_sites_url = "http://www.altusmetrum.org/AltOS/launch-sites.txt"; +// public static final String launch_sites_url = "file:///home/keithp/misc/text/altusmetrum/AltOS/launch-sites.txt"; public static final int ao_telemetry_standard_len = 32; public static final int ao_telemetry_0_9_len = 95; @@ -315,11 +320,12 @@ 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_TELEMEGA = 5; + public static final int AO_LOG_FORMAT_TELEMEGA_OLD = 5; public static final int AO_LOG_FORMAT_EASYMINI = 6; public static final int AO_LOG_FORMAT_TELEMETRUM = 7; public static final int AO_LOG_FORMAT_TELEMINI = 8; public static final int AO_LOG_FORMAT_TELEGPS = 9; + public static final int AO_LOG_FORMAT_TELEMEGA = 10; public static final int AO_LOG_FORMAT_NONE = 127; public static boolean isspace(int c) { diff --git a/altoslib/AltosLine.java b/altoslib/AltosLine.java index f56938c6..a65ba593 100644 --- a/altoslib/AltosLine.java +++ b/altoslib/AltosLine.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosLine { public String line; diff --git a/altoslib/AltosLink.java b/altoslib/AltosLink.java index 62bd82b9..01c37864 100644 --- a/altoslib/AltosLink.java +++ b/altoslib/AltosLink.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.concurrent.*; @@ -55,8 +55,11 @@ public abstract class AltosLink implements Runnable { public void printf(String format, Object ... arguments) { String line = String.format(format, arguments); - if (debug) - pending_output.add(line); + if (debug) { + synchronized (pending_output) { + pending_output.add(line); + } + } try { print(line); } catch (InterruptedException ie) { @@ -286,12 +289,14 @@ public abstract class AltosLink implements Runnable { binary_queue.put(dup); } - public void flush_output() { + public synchronized void flush_output() { if (pending_output == null) return; - for (String s : pending_output) - System.out.print(s); - pending_output.clear(); + synchronized (pending_output) { + for (String s : pending_output) + System.out.print(s); + pending_output.clear(); + } } public void flush_input(int timeout) throws InterruptedException { @@ -381,7 +386,7 @@ public abstract class AltosLink implements Runnable { flush_output(); } - public void set_monitor(boolean monitor) { + public synchronized void set_monitor(boolean monitor) { monitor_mode = monitor; if (monitor) printf("m %x\n", telemetry_len()); @@ -390,6 +395,10 @@ public abstract class AltosLink implements Runnable { flush_output(); } + public synchronized boolean get_monitor() { + return monitor_mode; + } + private void set_channel(int channel) { if (monitor_mode) printf("m 0\nc r %d\nm %x\n", @@ -422,8 +431,10 @@ public abstract class AltosLink implements Runnable { public void set_callsign(String callsign) { this.callsign = callsign; - printf ("c c %s\n", callsign); - flush_output(); + if (callsign != null) { + printf ("c c %s\n", callsign); + flush_output(); + } } public boolean is_loader() throws InterruptedException { @@ -462,7 +473,7 @@ public abstract class AltosLink implements Runnable { if (telemetry_rate < 0) telemetry_rate = AltosPreferences.telemetry_rate(serial); set_telemetry_rate(telemetry_rate); - if (callsign.equals("")) + if (callsign == null || callsign.equals("")) callsign = AltosPreferences.callsign(); set_callsign(callsign); printf("p\nE 0\n"); diff --git a/altoslib/AltosListenerState.java b/altoslib/AltosListenerState.java index 054ff1d0..d7e18008 100644 --- a/altoslib/AltosListenerState.java +++ b/altoslib/AltosListenerState.java @@ -15,14 +15,18 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; -public class AltosListenerState { +import java.io.*; + +public class AltosListenerState implements Serializable { public int crc_errors; public double battery; + public boolean running; public AltosListenerState() { crc_errors = 0; battery = AltosLib.MISSING; + running = true; } } diff --git a/altoslib/AltosLocation.java b/altoslib/AltosLocation.java index 9bbbb899..b21014db 100644 --- a/altoslib/AltosLocation.java +++ b/altoslib/AltosLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public abstract class AltosLocation extends AltosUnits { diff --git a/altoslib/AltosLog.java b/altoslib/AltosLog.java index 28116e3d..9241581a 100644 --- a/altoslib/AltosLog.java +++ b/altoslib/AltosLog.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.text.*; diff --git a/altoslib/AltosLongitude.java b/altoslib/AltosLongitude.java index dbcd6bf0..ff4f0c2b 100644 --- a/altoslib/AltosLongitude.java +++ b/altoslib/AltosLongitude.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosLongitude extends AltosLocation { public String pos() { return "E"; } diff --git a/altoslib/AltosMag.java b/altoslib/AltosMag.java index 690241f1..f7595639 100644 --- a/altoslib/AltosMag.java +++ b/altoslib/AltosMag.java @@ -15,24 +15,25 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.*; +import java.io.*; -public class AltosMag implements Cloneable { - public double x; - public double y; - public double z; +public class AltosMag implements Cloneable, Serializable { + public int along; + public int across; + public int through; public static double counts_per_gauss = 1090; - public static double convert_gauss(int counts) { - return (double) counts / counts_per_gauss; + public static double convert_gauss(double counts) { + return counts / counts_per_gauss; } public boolean parse_string(String line) { // if (line.startsWith("Syntax error")) { -// x = y = z = 0; +// along = across = through = 0; // return true; // } @@ -42,9 +43,9 @@ public class AltosMag implements Cloneable { String[] items = line.split("\\s+"); if (items.length >= 6) { - x = convert_gauss(Integer.parseInt(items[1])); - y = convert_gauss(Integer.parseInt(items[3])); - z = convert_gauss(Integer.parseInt(items[5])); + along = Integer.parseInt(items[1]); + across = Integer.parseInt(items[3]); + through = Integer.parseInt(items[5]); } return true; } @@ -52,16 +53,22 @@ public class AltosMag implements Cloneable { public AltosMag clone() { AltosMag n = new AltosMag(); - n.x = x; - n.y = y; - n.z = z; + n.along = along; + n.across = across; + n.through = through; return n; } public AltosMag() { - x = AltosLib.MISSING; - y = AltosLib.MISSING; - z = AltosLib.MISSING; + along = AltosLib.MISSING; + across = AltosLib.MISSING; + through = AltosLib.MISSING; + } + + public AltosMag(int along, int across, int through) { + this.along = along; + this.across = across; + this.through = through; } static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { diff --git a/altoslib/AltosMma655x.java b/altoslib/AltosMma655x.java index 7f0dab98..c0b94b8c 100644 --- a/altoslib/AltosMma655x.java +++ b/altoslib/AltosMma655x.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.*; diff --git a/altoslib/AltosMs5607.java b/altoslib/AltosMs5607.java index 81e0641c..2bd4ba8f 100644 --- a/altoslib/AltosMs5607.java +++ b/altoslib/AltosMs5607.java @@ -15,11 +15,12 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.*; +import java.io.*; -public class AltosMs5607 { +public class AltosMs5607 implements Serializable { public int reserved; public int sens; public int off; @@ -126,7 +127,7 @@ public class AltosMs5607 { static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { try { - AltosMs5607 ms5607 = new AltosMs5607(link); + AltosMs5607 ms5607 = new AltosMs5607(link, config_data); if (ms5607 != null) { state.set_ms5607(ms5607); @@ -143,9 +144,17 @@ public class AltosMs5607 { cc = AltosLib.MISSING; } - public AltosMs5607 (AltosLink link) throws InterruptedException, TimeoutException { + public AltosMs5607 (AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException { this(); - link.printf("c s\nB\n"); + reserved = config_data.ms5607_reserved; + sens = config_data.ms5607_sens; + off = config_data.ms5607_off; + tcs = config_data.ms5607_tcs; + tco = config_data.ms5607_tco; + tref = config_data.ms5607_tref; + tempsens = config_data.ms5607_tempsens; + crc = config_data.ms5607_crc; + link.printf("B\n"); for (;;) { String line = link.get_reply_no_dialog(5000); if (line == null) { diff --git a/altoslib/AltosNoSymbol.java b/altoslib/AltosNoSymbol.java index d436c3f1..77410a25 100644 --- a/altoslib/AltosNoSymbol.java +++ b/altoslib/AltosNoSymbol.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosNoSymbol extends Exception { public AltosNoSymbol(String name) { diff --git a/altoslib/AltosOrient.java b/altoslib/AltosOrient.java index 348c6844..8cdde750 100644 --- a/altoslib/AltosOrient.java +++ b/altoslib/AltosOrient.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosOrient extends AltosUnits { diff --git a/altoslib/AltosParse.java b/altoslib/AltosParse.java index 9cb99a0d..2fb69c15 100644 --- a/altoslib/AltosParse.java +++ b/altoslib/AltosParse.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; diff --git a/altoslib/AltosPreferences.java b/altoslib/AltosPreferences.java index dba57dcb..5aa45d3f 100644 --- a/altoslib/AltosPreferences.java +++ b/altoslib/AltosPreferences.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -41,6 +41,9 @@ public class AltosPreferences { /* log file format preference name */ public final static String logfilePreferenceFormat = "LOGFILE-%d"; + /* state preference name */ + public final static String statePreferenceFormat = "STATE-%d"; + /* voice preference name */ public final static String voicePreference = "VOICE"; @@ -333,6 +336,48 @@ public class AltosPreferences { } } + public static void set_state(int serial, AltosState state, AltosListenerState listener_state) { + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + + try { + ObjectOutputStream oos = new ObjectOutputStream(baos); + + AltosSavedState saved_state = new AltosSavedState(state, listener_state); + oos.writeObject(saved_state); + + byte[] bytes = baos.toByteArray(); + + synchronized(backend) { + backend.putBytes(String.format(statePreferenceFormat, serial), bytes); + flush_preferences(); + } + } catch (IOException ie) { + } + } + + public static AltosSavedState state(int serial) { + byte[] bytes = null; + + synchronized(backend) { + bytes = backend.getBytes(String.format(statePreferenceFormat, serial), null); + } + + if (bytes == null) + return null; + + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + + try { + ObjectInputStream ois = new ObjectInputStream(bais); + AltosSavedState saved_state = (AltosSavedState) ois.readObject(); + return saved_state; + } catch (IOException ie) { + } catch (ClassNotFoundException ce) { + } + return null; + } + public static void set_scanning_telemetry(int new_scanning_telemetry) { synchronized (backend) { scanning_telemetry = new_scanning_telemetry; diff --git a/altoslib/AltosPreferencesBackend.java b/altoslib/AltosPreferencesBackend.java index 76a99acb..c83eaa47 100644 --- a/altoslib/AltosPreferencesBackend.java +++ b/altoslib/AltosPreferencesBackend.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.File; @@ -33,6 +33,9 @@ public interface AltosPreferencesBackend { public boolean getBoolean(String key, boolean def); public void putBoolean(String key, boolean value); + public byte[] getBytes(String key, byte[] def); + public void putBytes(String key, byte[] value); + public boolean nodeExists(String key); public AltosPreferencesBackend node(String key); diff --git a/altoslib/AltosProgrammer.java b/altoslib/AltosProgrammer.java index 443082d5..7a92c2d0 100644 --- a/altoslib/AltosProgrammer.java +++ b/altoslib/AltosProgrammer.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; diff --git a/altoslib/AltosPyro.java b/altoslib/AltosPyro.java index 60b8fe52..502e34de 100644 --- a/altoslib/AltosPyro.java +++ b/altoslib/AltosPyro.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.*; import java.text.*; diff --git a/altoslib/AltosQuaternion.java b/altoslib/AltosQuaternion.java new file mode 100644 index 00000000..4ad1f3d6 --- /dev/null +++ b/altoslib/AltosQuaternion.java @@ -0,0 +1,150 @@ +/* + * Copyright © 2014 Keith Packard <keithp@keithp.com> + * + * 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_6; + +public class AltosQuaternion { + double r; /* real bit */ + double x, y, z; /* imaginary bits */ + + public AltosQuaternion multiply(AltosQuaternion b) { + return new AltosQuaternion( + this.r * b.r - this.x * b.x - this.y * b.y - this.z * b.z, + this.r * b.x + this.x * b.r + this.y * b.z - this.z * b.y, + this.r * b.y - this.x * b.z + this.y * b.r + this.z * b.x, + this.r * b.z + this.x * b.y - this.y * b.x + this.z * b.r); + } + + public AltosQuaternion conjugate() { + return new AltosQuaternion( + this.r, + -this.x, + -this.y, + -this.z); + } + + public double normal() { + return (this.r * this.r + + this.x * this.x + + this.y * this.y + + this.z * this.z); + } + + public AltosQuaternion scale(double b) { + return new AltosQuaternion( + this.r * b, + this.x * b, + this.y * b, + this.z * b); + } + + public AltosQuaternion normalize() { + double n = normal(); + if (n <= 0) + return this; + return scale(1/Math.sqrt(n)); + } + + public double dot(AltosQuaternion b) { + return (this.r * b.r + + this.x * b.x + + this.y * b.y + + this.z * b.z); + } + + public AltosQuaternion rotate(AltosQuaternion b) { + return (b.multiply(this)).multiply(b.conjugate()); + } + + public AltosQuaternion vectors_to_rotation(AltosQuaternion b) { + /* + * The cross product will point orthogonally to the two + * vectors, forming our rotation axis. The length will be + * sin(θ), so these values are already multiplied by that. + */ + + double x = this.y * b.z - this.z * b.y; + double y = this.z * b.x - this.x * b.z; + double z = this.x * b.y - this.y * b.x; + + double s_2 = x*x + y*y + z*z; + double s = Math.sqrt(s_2); + + /* cos(θ) = a · b / (|a| |b|). + * + * a and b are both unit vectors, so the divisor is one + */ + double c = this.x*b.x + this.y*b.y + this.z*b.z; + + double c_half = Math.sqrt ((1 + c) / 2); + double s_half = Math.sqrt ((1 - c) / 2); + + /* + * Divide out the sine factor from the + * cross product, then multiply in the + * half sine factor needed for the quaternion + */ + double s_scale = s_half / s; + + AltosQuaternion r = new AltosQuaternion(c_half, + x * s_scale, + y * s_scale, + z * s_scale); + return r.normalize(); + } + + public AltosQuaternion(double r, double x, double y, double z) { + this.r = r; + this.x = x; + this.y = y; + this.z = z; + } + + public AltosQuaternion(AltosQuaternion q) { + this.r = q.r; + this.x = q.x; + this.y = q.y; + this.z = q.z; + } + + static public AltosQuaternion vector(double x, double y, double z) { + return new AltosQuaternion(0, x, y, z); + } + + static public AltosQuaternion rotation(double x, double y, double z, + double s, double c) { + return new AltosQuaternion(c, + s*x, + s*y, + s*z); + } + + static public AltosQuaternion zero_rotation() { + return new AltosQuaternion(1, 0, 0, 0); + } + + static public AltosQuaternion half_euler(double x, double y, double z) { + double s_x = Math.sin(x), c_x = Math.cos(x); + double s_y = Math.sin(y), c_y = Math.cos(y); + double s_z = Math.sin(z), c_z = Math.cos(z);; + + return new AltosQuaternion(c_x * c_y * c_z + s_x * s_y * s_z, + s_x * c_y * c_z - c_x * s_y * s_z, + c_x * s_y * c_z + s_x * c_y * s_z, + c_x * c_y * s_z - s_x * s_y * c_z); + } +} diff --git a/altoslib/AltosReplayReader.java b/altoslib/AltosReplayReader.java index 2864e02a..98f0e7d5 100644 --- a/altoslib/AltosReplayReader.java +++ b/altoslib/AltosReplayReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; @@ -27,7 +27,6 @@ import java.util.*; public class AltosReplayReader extends AltosFlightReader { Iterator<AltosState> iterator; File file; - boolean real_time; public AltosState read() { if (iterator.hasNext()) @@ -40,22 +39,16 @@ public class AltosReplayReader extends AltosFlightReader { public void update(AltosState state) throws InterruptedException { /* Make it run in realtime after the rocket leaves the pad */ - if (real_time && state.state > AltosLib.ao_flight_pad && state.time_change > 0) - Thread.sleep((int) (Math.min(state.time_change,10) * 1000)); + if (state.state > AltosLib.ao_flight_pad && state.time_change > 0) + Thread.sleep((int) (Math.min(state.time_change,10) * 100)); state.set_received_time(System.currentTimeMillis()); } public File backing_file() { return file; } - public AltosReplayReader(Iterator<AltosState> in_iterator, File in_file, - boolean in_real_time) { + public AltosReplayReader(Iterator<AltosState> in_iterator, File in_file) { iterator = in_iterator; file = in_file; - real_time = in_real_time; name = file.getName(); } - - public AltosReplayReader(Iterator<AltosState> in_iterator, File in_file) { - this(in_iterator, in_file, false); - } } diff --git a/altoslib/AltosRomconfig.java b/altoslib/AltosRomconfig.java index d0de5492..c93a01c3 100644 --- a/altoslib/AltosRomconfig.java +++ b/altoslib/AltosRomconfig.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; diff --git a/altoslib/AltosRotation.java b/altoslib/AltosRotation.java new file mode 100644 index 00000000..49225f77 --- /dev/null +++ b/altoslib/AltosRotation.java @@ -0,0 +1,50 @@ +/* + * Copyright © 2014 Keith Packard <keithp@keithp.com> + * + * 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_6; + +public class AltosRotation { + private AltosQuaternion rotation; + + public double tilt() { + double rotz = rotation.z * rotation.z - rotation.y * rotation.y - rotation.x * rotation.x + rotation.r * rotation.r; + + double tilt = Math.acos(rotz) * 180.0 / Math.PI; + return tilt; + } + + public void rotate(double dt, double x, double y, double z) { + AltosQuaternion rot = AltosQuaternion.half_euler(x * dt, y * dt, z * dt); + rotation = rot.multiply(rotation).normalize(); + } + + /* Clone an existing rotation value */ + public AltosRotation (AltosRotation old) { + this.rotation = new AltosQuaternion(old.rotation); + } + + /* Create a new rotation value given an acceleration vector pointing down */ + public AltosRotation(double x, + double y, + double z, + int pad_orientation) { + AltosQuaternion orient = AltosQuaternion.vector(x, y, z).normalize(); + double sky = pad_orientation == 0 ? 1 : -1; + AltosQuaternion up = new AltosQuaternion(0, 0, 0, sky); + rotation = up.vectors_to_rotation(orient); + } +} diff --git a/altoslib/AltosSavedState.java b/altoslib/AltosSavedState.java new file mode 100644 index 00000000..552e4533 --- /dev/null +++ b/altoslib/AltosSavedState.java @@ -0,0 +1,30 @@ +/* + * Copyright © 2014 Keith Packard <keithp@keithp.com> + * + * 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_6; + +import java.io.*; + +public class AltosSavedState implements Serializable { + public AltosState state; + public AltosListenerState listener_state; + + public AltosSavedState(AltosState state, AltosListenerState listener_state) { + this.state = state; + this.listener_state = listener_state; + } +} diff --git a/altoslib/AltosSelfFlash.java b/altoslib/AltosSelfFlash.java index 3ec69213..83be4be1 100644 --- a/altoslib/AltosSelfFlash.java +++ b/altoslib/AltosSelfFlash.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; diff --git a/altoslib/AltosSensorEMini.java b/altoslib/AltosSensorEMini.java index 53a8e998..cb8356a1 100644 --- a/altoslib/AltosSensorEMini.java +++ b/altoslib/AltosSensorEMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMM.java b/altoslib/AltosSensorMM.java index cdc2ac42..9d5649aa 100644 --- a/altoslib/AltosSensorMM.java +++ b/altoslib/AltosSensorMM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMega.java b/altoslib/AltosSensorMega.java index 3c7213eb..a3c2a033 100644 --- a/altoslib/AltosSensorMega.java +++ b/altoslib/AltosSensorMega.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorMetrum.java b/altoslib/AltosSensorMetrum.java index d977e886..39592b50 100644 --- a/altoslib/AltosSensorMetrum.java +++ b/altoslib/AltosSensorMetrum.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTGPS.java b/altoslib/AltosSensorTGPS.java new file mode 100644 index 00000000..32607fba --- /dev/null +++ b/altoslib/AltosSensorTGPS.java @@ -0,0 +1,55 @@ +/* + * Copyright © 2015 Keith Packard <keithp@keithp.com> + * + * 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_6; + +import java.util.concurrent.TimeoutException; + +public class AltosSensorTGPS { + public int tick; + public int batt; + + static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { + try { + AltosSensorTGPS sensor_tgps = new AltosSensorTGPS(link); + + if (sensor_tgps == null) + return; + state.set_battery_voltage(AltosConvert.tele_gps_voltage(sensor_tgps.batt)); + + } catch (TimeoutException te) { + } + } + + public AltosSensorTGPS(AltosLink link) throws InterruptedException, TimeoutException { + String[] items = link.adc(); + for (int i = 0; i < items.length - 1;) { + if (items[i].equals("tick:")) { + tick = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("batt:")) { + batt = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + i++; + } + } +} + diff --git a/altoslib/AltosSensorTM.java b/altoslib/AltosSensorTM.java index 344e7449..c82ba93c 100644 --- a/altoslib/AltosSensorTM.java +++ b/altoslib/AltosSensorTM.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini.java index edd76da2..0fc70e71 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.util.concurrent.TimeoutException; diff --git a/altoslib/AltosSpeed.java b/altoslib/AltosSpeed.java index d2f86214..b714412f 100644 --- a/altoslib/AltosSpeed.java +++ b/altoslib/AltosSpeed.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosSpeed extends AltosUnits { diff --git a/altoslib/AltosState.java b/altoslib/AltosState.java index 5fce15c4..d363027c 100644 --- a/altoslib/AltosState.java +++ b/altoslib/AltosState.java @@ -19,9 +19,11 @@ * Track flight state from telemetry or eeprom data stream */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; -public class AltosState implements Cloneable { +import java.io.*; + +public class AltosState implements Cloneable, Serializable { public static final int set_position = 1; public static final int set_gps = 2; @@ -43,9 +45,9 @@ public class AltosState implements Cloneable { private int prev_tick; public int boost_tick; - class AltosValue { - private double value; - private double prev_value; + class AltosValue implements Serializable{ + double value; + double prev_value; private double max_value; private double set_time; private double prev_set_time; @@ -179,9 +181,20 @@ public class AltosState implements Cloneable { } } - class AltosCValue { - AltosValue measured; - AltosValue computed; + class AltosCValue implements Serializable { + + class AltosIValue extends AltosValue implements Serializable { + boolean can_max() { + return c_can_max(); + } + }; + + public AltosIValue measured; + public AltosIValue computed; + + boolean can_max() { return true; } + + boolean c_can_max() { return can_max(); } double value() { double v = measured.value(); @@ -263,8 +276,8 @@ public class AltosState implements Cloneable { } AltosCValue() { - measured = new AltosValue(); - computed = new AltosValue(); + measured = new AltosIValue(); + computed = new AltosIValue(); } } @@ -301,7 +314,7 @@ public class AltosState implements Cloneable { ground_altitude.set_measured(a, time); } - class AltosGpsGroundAltitude extends AltosValue { + class AltosGpsGroundAltitude extends AltosValue implements Serializable { void set(double a, double t) { super.set(a, t); pad_alt = value(); @@ -325,7 +338,7 @@ public class AltosState implements Cloneable { gps_ground_altitude.set(a, time); } - class AltosGroundPressure extends AltosCValue { + class AltosGroundPressure extends AltosCValue implements Serializable { void set_filtered(double p, double time) { computed.set_filtered(p, time); if (!is_measured()) @@ -348,7 +361,7 @@ public class AltosState implements Cloneable { ground_pressure.set_measured(pressure, time); } - class AltosAltitude extends AltosCValue { + class AltosAltitude extends AltosCValue implements Serializable { private void set_speed(AltosValue v) { if (!acceleration.is_measured() || !ascent) @@ -370,7 +383,7 @@ public class AltosState implements Cloneable { private AltosAltitude altitude; - class AltosGpsAltitude extends AltosValue { + class AltosGpsAltitude extends AltosValue implements Serializable { private void set_gps_height() { double a = value(); @@ -453,7 +466,7 @@ public class AltosState implements Cloneable { return gps_speed.max(); } - class AltosPressure extends AltosValue { + class AltosPressure extends AltosValue implements Serializable { void set(double p, double time) { super.set(p, time); if (state == AltosLib.ao_flight_pad) @@ -523,7 +536,7 @@ public class AltosState implements Cloneable { return AltosLib.MISSING; } - class AltosSpeed extends AltosCValue { + class AltosSpeed extends AltosCValue implements Serializable { boolean can_max() { return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless; @@ -577,7 +590,7 @@ public class AltosState implements Cloneable { return AltosLib.MISSING; } - class AltosAccel extends AltosCValue { + class AltosAccel extends AltosCValue implements Serializable { boolean can_max() { return state < AltosLib.ao_flight_fast || state == AltosLib.ao_flight_stateless; @@ -600,10 +613,10 @@ public class AltosState implements Cloneable { return acceleration.max(); } - public AltosValue orient; + public AltosCValue orient; public void set_orient(double new_orient) { - orient.set(new_orient, time); + orient.set_measured(new_orient, time); } public double orient() { @@ -713,7 +726,7 @@ public class AltosState implements Cloneable { pressure = new AltosPressure(); speed = new AltosSpeed(); acceleration = new AltosAccel(); - orient = new AltosValue(); + orient = new AltosCValue(); temperature = AltosLib.MISSING; battery_voltage = AltosLib.MISSING; @@ -733,7 +746,24 @@ public class AltosState implements Cloneable { gps_pending = false; imu = null; + last_imu_time = AltosLib.MISSING; + rotation = null; + ground_rotation = null; + mag = null; + accel_zero_along = AltosLib.MISSING; + accel_zero_across = AltosLib.MISSING; + accel_zero_through = AltosLib.MISSING; + + accel_ground_along = AltosLib.MISSING; + accel_ground_across = AltosLib.MISSING; + accel_ground_through = AltosLib.MISSING; + + pad_orientation = AltosLib.MISSING; + + gyro_zero_roll = AltosLib.MISSING; + gyro_zero_pitch = AltosLib.MISSING; + gyro_zero_yaw = AltosLib.MISSING; set_npad(0); ngps = 0; @@ -861,6 +891,27 @@ public class AltosState implements Cloneable { imu = old.imu.clone(); else imu = null; + last_imu_time = old.last_imu_time; + + if (old.rotation != null) + rotation = new AltosRotation (old.rotation); + + if (old.ground_rotation != null) { + ground_rotation = new AltosRotation(old.ground_rotation); + } + + accel_zero_along = old.accel_zero_along; + accel_zero_across = old.accel_zero_across; + accel_zero_through = old.accel_zero_through; + + accel_ground_along = old.accel_ground_along; + accel_ground_across = old.accel_ground_across; + accel_ground_through = old.accel_ground_through; + pad_orientation = old.pad_orientation; + + gyro_zero_roll = old.gyro_zero_roll; + gyro_zero_pitch = old.gyro_zero_pitch; + gyro_zero_yaw = old.gyro_zero_yaw; if (old.mag != null) mag = old.mag.clone(); @@ -1112,16 +1163,170 @@ public class AltosState implements Cloneable { } } + + public double accel_zero_along; + public double accel_zero_across; + public double accel_zero_through; + + public AltosRotation rotation; + public AltosRotation ground_rotation; + + public void set_accel_zero(double zero_along, double zero_across, double zero_through) { + if (zero_along != AltosLib.MISSING) { + accel_zero_along = zero_along; + accel_zero_across = zero_across; + accel_zero_through = zero_through; + } + } + + public int pad_orientation; + + public double accel_ground_along, accel_ground_across, accel_ground_through; + + void update_pad_rotation() { + if (pad_orientation != AltosLib.MISSING && accel_ground_along != AltosLib.MISSING) { + rotation = new AltosRotation(AltosIMU.convert_accel(accel_ground_across - accel_zero_across), + AltosIMU.convert_accel(accel_ground_through - accel_zero_through), + AltosIMU.convert_accel(accel_ground_along - accel_zero_along), + pad_orientation); + ground_rotation = rotation; + orient.set_computed(rotation.tilt(), time); + } + } + + public void set_accel_ground(double ground_along, double ground_across, double ground_through) { + accel_ground_along = ground_along; + accel_ground_across = ground_across; + accel_ground_through = ground_through; + update_pad_rotation(); + } + + public void set_pad_orientation(int pad_orientation) { + this.pad_orientation = pad_orientation; + update_pad_rotation(); + } + + public double gyro_zero_roll; + public double gyro_zero_pitch; + public double gyro_zero_yaw; + + public void set_gyro_zero(double roll, double pitch, double yaw) { + if (roll != AltosLib.MISSING) { + gyro_zero_roll = roll; + gyro_zero_pitch = pitch; + gyro_zero_yaw = yaw; + } + } + + public double last_imu_time; + + private double radians(double degrees) { + if (degrees == AltosLib.MISSING) + return AltosLib.MISSING; + return degrees * Math.PI / 180.0; + } + + private void update_orient() { + if (last_imu_time != AltosLib.MISSING) { + double t = time - last_imu_time; + + double pitch = radians(gyro_pitch()); + double yaw = radians(gyro_yaw()); + double roll = radians(gyro_roll()); + + if (t > 0 & pitch != AltosLib.MISSING && rotation != null) { + rotation.rotate(t, pitch, yaw, roll); + orient.set_computed(rotation.tilt(), time); + } + } + last_imu_time = time; + } + public void set_imu(AltosIMU imu) { if (imu != null) imu = imu.clone(); this.imu = imu; + update_orient(); + } + + private double gyro_zero_overflow(double first) { + double v = first / 128.0; + if (v < 0) + v = Math.ceil(v); + else + v = Math.floor(v); + return v * 128.0; + } + + public void check_imu_wrap(AltosIMU imu) { + if (this.imu == null) { + gyro_zero_roll += gyro_zero_overflow(imu.gyro_roll); + gyro_zero_pitch += gyro_zero_overflow(imu.gyro_pitch); + gyro_zero_yaw += gyro_zero_overflow(imu.gyro_yaw); + } + } + + public double accel_along() { + if (imu != null && accel_zero_along != AltosLib.MISSING) + return AltosIMU.convert_accel(imu.accel_along - accel_zero_along); + return AltosLib.MISSING; + } + + public double accel_across() { + if (imu != null && accel_zero_across != AltosLib.MISSING) + return AltosIMU.convert_accel(imu.accel_across - accel_zero_across); + return AltosLib.MISSING; + } + + public double accel_through() { + if (imu != null && accel_zero_through != AltosLib.MISSING) + return AltosIMU.convert_accel(imu.accel_through - accel_zero_through); + return AltosLib.MISSING; + } + + public double gyro_roll() { + if (imu != null && gyro_zero_roll != AltosLib.MISSING) { + return AltosIMU.convert_gyro(imu.gyro_roll - gyro_zero_roll); + } + return AltosLib.MISSING; + } + + public double gyro_pitch() { + if (imu != null && gyro_zero_pitch != AltosLib.MISSING) { + return AltosIMU.convert_gyro(imu.gyro_pitch - gyro_zero_pitch); + } + return AltosLib.MISSING; + } + + public double gyro_yaw() { + if (imu != null && gyro_zero_yaw != AltosLib.MISSING) { + return AltosIMU.convert_gyro(imu.gyro_yaw - gyro_zero_yaw); + } + return AltosLib.MISSING; } public void set_mag(AltosMag mag) { this.mag = mag.clone(); } + public double mag_along() { + if (mag != null) + return AltosMag.convert_gauss(mag.along); + return AltosLib.MISSING; + } + + public double mag_across() { + if (mag != null) + return AltosMag.convert_gauss(mag.across); + return AltosLib.MISSING; + } + + public double mag_through() { + if (mag != null) + return AltosMag.convert_gauss(mag.through); + return AltosLib.MISSING; + } + public AltosMs5607 make_baro() { if (baro == null) baro = new AltosMs5607(); diff --git a/altoslib/AltosStateIterable.java b/altoslib/AltosStateIterable.java index 4154b71c..3b58fc32 100644 --- a/altoslib/AltosStateIterable.java +++ b/altoslib/AltosStateIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosStateUpdate.java b/altoslib/AltosStateUpdate.java index 70530f75..93b9f1c0 100644 --- a/altoslib/AltosStateUpdate.java +++ b/altoslib/AltosStateUpdate.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public interface AltosStateUpdate { public void update_state(AltosState state) throws InterruptedException; diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index a123d752..449384d5 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; diff --git a/altoslib/AltosTelemetryConfiguration.java b/altoslib/AltosTelemetryConfiguration.java index f578e6ad..8c922b03 100644 --- a/altoslib/AltosTelemetryConfiguration.java +++ b/altoslib/AltosTelemetryConfiguration.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryConfiguration extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryFile.java b/altoslib/AltosTelemetryFile.java index 15344b8d..738e4dd7 100644 --- a/altoslib/AltosTelemetryFile.java +++ b/altoslib/AltosTelemetryFile.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryIterable.java b/altoslib/AltosTelemetryIterable.java index ac42597d..131389d5 100644 --- a/altoslib/AltosTelemetryIterable.java +++ b/altoslib/AltosTelemetryIterable.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.io.*; import java.util.*; diff --git a/altoslib/AltosTelemetryLegacy.java b/altoslib/AltosTelemetryLegacy.java index 72a8bc4a..923d139e 100644 --- a/altoslib/AltosTelemetryLegacy.java +++ b/altoslib/AltosTelemetryLegacy.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; diff --git a/altoslib/AltosTelemetryLocation.java b/altoslib/AltosTelemetryLocation.java index 427ae16e..85da27d5 100644 --- a/altoslib/AltosTelemetryLocation.java +++ b/altoslib/AltosTelemetryLocation.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryLocation extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMap.java b/altoslib/AltosTelemetryMap.java index 758311eb..e8c02e9b 100644 --- a/altoslib/AltosTelemetryMap.java +++ b/altoslib/AltosTelemetryMap.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; import java.util.HashMap; diff --git a/altoslib/AltosTelemetryMegaData.java b/altoslib/AltosTelemetryMegaData.java index d949c02f..2b80df4a 100644 --- a/altoslib/AltosTelemetryMegaData.java +++ b/altoslib/AltosTelemetryMegaData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryMegaData extends AltosTelemetryStandard { int state; diff --git a/altoslib/AltosTelemetryMegaSensor.java b/altoslib/AltosTelemetryMegaSensor.java index 1b568c88..a01c0826 100644 --- a/altoslib/AltosTelemetryMegaSensor.java +++ b/altoslib/AltosTelemetryMegaSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryMegaSensor extends AltosTelemetryStandard { int accel; @@ -66,24 +66,13 @@ public class AltosTelemetryMegaSensor extends AltosTelemetryStandard { state.set_orient(orient); - AltosIMU imu = new AltosIMU(); + state.set_imu(new AltosIMU(accel_y, /* along */ + accel_x, /* across */ + accel_z, /* through */ + gyro_y, /* along */ + gyro_x, /* across */ + gyro_z)); /* through */ - imu.accel_x = AltosIMU.convert_accel(accel_x); - imu.accel_y = AltosIMU.convert_accel(accel_y); - imu.accel_z = AltosIMU.convert_accel(accel_z); - - imu.gyro_x = AltosIMU.convert_gyro(gyro_x); - imu.gyro_y = AltosIMU.convert_gyro(gyro_y); - imu.gyro_z = AltosIMU.convert_gyro(gyro_z); - - state.imu = imu; - - AltosMag mag = new AltosMag(); - - mag.x = AltosMag.convert_gauss(mag_x); - mag.y = AltosMag.convert_gauss(mag_y); - mag.z = AltosMag.convert_gauss(mag_z); - - state.mag = mag; + state.set_mag(new AltosMag(mag_x, mag_y, mag_z)); } } diff --git a/altoslib/AltosTelemetryMetrumData.java b/altoslib/AltosTelemetryMetrumData.java index 3377d969..e53f1283 100644 --- a/altoslib/AltosTelemetryMetrumData.java +++ b/altoslib/AltosTelemetryMetrumData.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryMetrumData extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMetrumSensor.java b/altoslib/AltosTelemetryMetrumSensor.java index beab6da9..415b00a6 100644 --- a/altoslib/AltosTelemetryMetrumSensor.java +++ b/altoslib/AltosTelemetryMetrumSensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini.java index 221bb67c..02537c9c 100644 --- a/altoslib/AltosTelemetryMini.java +++ b/altoslib/AltosTelemetryMini.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryMini extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryRaw.java b/altoslib/AltosTelemetryRaw.java index 2a535e84..4254fc83 100644 --- a/altoslib/AltosTelemetryRaw.java +++ b/altoslib/AltosTelemetryRaw.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetryRaw extends AltosTelemetryStandard { public AltosTelemetryRaw(int[] bytes) { diff --git a/altoslib/AltosTelemetryReader.java b/altoslib/AltosTelemetryReader.java index 20526a2c..908fb5c7 100644 --- a/altoslib/AltosTelemetryReader.java +++ b/altoslib/AltosTelemetryReader.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; import java.text.*; import java.io.*; @@ -28,20 +28,16 @@ public class AltosTelemetryReader extends AltosFlightReader { int telemetry; int telemetry_rate; AltosState state = null; - AltosFlightReader stacked; LinkedBlockingQueue<AltosLine> telem; public AltosState read() throws InterruptedException, ParseException, AltosCRCException, IOException { - if (stacked != null) { - state = stacked.read(); - if (state != null) - return state; - stacked = null; - } - AltosLine l = telem.take(); - if (l.line == null) - throw new IOException("IO error"); + AltosLine l; + do { + l = telem.take(); + if (l.line == null) + throw new IOException("IO error"); + } while (!link.get_monitor()); AltosTelemetry telem = AltosTelemetry.parse(l.line); if (state == null) state = new AltosState(); @@ -57,15 +53,11 @@ public class AltosTelemetryReader extends AltosFlightReader { public void reset() { flush(); + state = null; } public void close(boolean interrupted) { - if (stacked != null) { - stacked.close(interrupted); - stacked = null; - } - link.remove_monitor(telem); log.close(); try { @@ -161,10 +153,9 @@ public class AltosTelemetryReader extends AltosFlightReader { return link.monitor_battery(); } - public AltosTelemetryReader (AltosLink in_link, AltosFlightReader in_stacked) + public AltosTelemetryReader (AltosLink in_link) throws IOException, InterruptedException, TimeoutException { link = in_link; - stacked = in_stacked; boolean success = false; try { log = new AltosLog(link); @@ -183,22 +174,4 @@ public class AltosTelemetryReader extends AltosFlightReader { close(true); } } - - private static AltosFlightReader existing_data(AltosLink link) { - if (link == null) - return null; - - File file = AltosPreferences.logfile(link.serial); - if (file != null) { - AltosStateIterable iterable = AltosStateIterable.iterable(file); - if (iterable != null) - return new AltosReplayReader(iterable.iterator(), file, false); - } - return null; - } - - public AltosTelemetryReader(AltosLink link) - throws IOException, InterruptedException, TimeoutException { - this(link, null); - } } diff --git a/altoslib/AltosTelemetrySatellite.java b/altoslib/AltosTelemetrySatellite.java index d1cdaf6d..474789ba 100644 --- a/altoslib/AltosTelemetrySatellite.java +++ b/altoslib/AltosTelemetrySatellite.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetrySatellite extends AltosTelemetryStandard { int channels; diff --git a/altoslib/AltosTelemetrySensor.java b/altoslib/AltosTelemetrySensor.java index fc3fe858..b0c84fd3 100644 --- a/altoslib/AltosTelemetrySensor.java +++ b/altoslib/AltosTelemetrySensor.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTelemetrySensor extends AltosTelemetryStandard { diff --git a/altoslib/AltosTelemetryStandard.java b/altoslib/AltosTelemetryStandard.java index f4dfd8e9..fb8a162e 100644 --- a/altoslib/AltosTelemetryStandard.java +++ b/altoslib/AltosTelemetryStandard.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public abstract class AltosTelemetryStandard extends AltosTelemetry { int[] bytes; diff --git a/altoslib/AltosTemperature.java b/altoslib/AltosTemperature.java index e654fada..494f4e3e 100644 --- a/altoslib/AltosTemperature.java +++ b/altoslib/AltosTemperature.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosTemperature extends AltosUnits { diff --git a/altoslib/AltosUnits.java b/altoslib/AltosUnits.java index dbdb7882..f6e34e77 100644 --- a/altoslib/AltosUnits.java +++ b/altoslib/AltosUnits.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public abstract class AltosUnits { diff --git a/altoslib/AltosUnitsListener.java b/altoslib/AltosUnitsListener.java index 664aed67..1b66eb45 100644 --- a/altoslib/AltosUnitsListener.java +++ b/altoslib/AltosUnitsListener.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public interface AltosUnitsListener { public void units_changed(boolean imperial_units); diff --git a/altoslib/AltosVoltage.java b/altoslib/AltosVoltage.java index 22bd1aee..986d74b4 100644 --- a/altoslib/AltosVoltage.java +++ b/altoslib/AltosVoltage.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public class AltosVoltage extends AltosUnits { diff --git a/altoslib/AltosWriter.java b/altoslib/AltosWriter.java index fb208b02..b125bd87 100644 --- a/altoslib/AltosWriter.java +++ b/altoslib/AltosWriter.java @@ -15,7 +15,7 @@ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. */ -package org.altusmetrum.altoslib_5; +package org.altusmetrum.altoslib_6; public interface AltosWriter { diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 0ad9b7da..c640c69c 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -82,6 +82,7 @@ altoslib_JAVA = \ AltosProgrammer.java \ AltosReplayReader.java \ AltosRomconfig.java \ + AltosSavedState.java \ AltosSelfFlash.java \ AltosSensorMM.java \ AltosSensorEMini.java \ @@ -89,6 +90,7 @@ altoslib_JAVA = \ AltosSensorTMini.java \ AltosSensorMega.java \ AltosSensorMetrum.java \ + AltosSensorTGPS.java \ AltosState.java \ AltosStateIterable.java \ AltosStateUpdate.java \ @@ -124,7 +126,9 @@ altoslib_JAVA = \ AltosLatitude.java \ AltosLongitude.java \ AltosPyro.java \ - AltosWriter.java + AltosWriter.java \ + AltosQuaternion.java \ + AltosRotation.java JAR=altoslib_$(ALTOSLIB_VERSION).jar |