diff options
Diffstat (limited to 'altoslib')
-rw-r--r-- | altoslib/AltosConvert.java | 22 | ||||
-rw-r--r-- | altoslib/AltosEepromChunk.java | 6 | ||||
-rw-r--r-- | altoslib/AltosEepromFile.java | 6 | ||||
-rw-r--r-- | altoslib/AltosEepromFireTwo.java | 118 | ||||
-rw-r--r-- | altoslib/AltosEepromMini.java | 25 | ||||
-rw-r--r-- | altoslib/AltosIdleFetch.java | 16 | ||||
-rw-r--r-- | altoslib/AltosLib.java | 5 | ||||
-rw-r--r-- | altoslib/AltosSensorTMini2.java (renamed from altoslib/AltosSensorTMini.java) | 12 | ||||
-rw-r--r-- | altoslib/AltosSensorTMini3.java | 70 | ||||
-rw-r--r-- | altoslib/AltosTelemetry.java | 3 | ||||
-rw-r--r-- | altoslib/AltosTelemetryMini2.java (renamed from altoslib/AltosTelemetryMini.java) | 10 | ||||
-rw-r--r-- | altoslib/AltosTelemetryMini3.java | 76 | ||||
-rw-r--r-- | altoslib/AltosTelemetryStandard.java | 7 | ||||
-rw-r--r-- | altoslib/Makefile.am | 7 |
14 files changed, 353 insertions, 30 deletions
diff --git a/altoslib/AltosConvert.java b/altoslib/AltosConvert.java index 288f43ce..8617a12c 100644 --- a/altoslib/AltosConvert.java +++ b/altoslib/AltosConvert.java @@ -219,7 +219,23 @@ public class AltosConvert { return AltosLib.MISSING; } - static double tele_mini_voltage(int sensor) { + static double tele_mini_3_adc(int raw) { + return raw / 4095.0; + } + + static public double tele_mini_3_battery_voltage(int v_batt) { + if (v_batt != AltosLib.MISSING) + return 3.3 * tele_mini_3_adc(v_batt) * (5.6 + 10.0) / 10.0; + return AltosLib.MISSING; + } + + static double tele_mini_3_pyro_voltage(int raw) { + if (raw != AltosLib.MISSING) + return 3.3 * tele_mini_3_adc(raw) * (100.0 + 27.0) / 27.0; + return AltosLib.MISSING; + } + + static double tele_mini_2_voltage(int sensor) { double supply = 3.3; return sensor / 32767.0 * supply * 127/27; @@ -350,6 +366,10 @@ public class AltosConvert { return (c - 32) * 5/9; } + public static double psi_to_pa(double psi) { + return psi * 6894.76; + } + public static boolean imperial_units = false; public static AltosDistance distance = new AltosDistance(); diff --git a/altoslib/AltosEepromChunk.java b/altoslib/AltosEepromChunk.java index c9598254..32d9f8ea 100644 --- a/altoslib/AltosEepromChunk.java +++ b/altoslib/AltosEepromChunk.java @@ -82,13 +82,17 @@ public class AltosEepromChunk { case AltosLib.AO_LOG_FORMAT_TELEMETRUM: eeprom = new AltosEepromMetrum2(this, offset); break; - case AltosLib.AO_LOG_FORMAT_TELEMINI: + case AltosLib.AO_LOG_FORMAT_TELEMINI2: + case AltosLib.AO_LOG_FORMAT_TELEMINI3: case AltosLib.AO_LOG_FORMAT_EASYMINI: eeprom = new AltosEepromMini(this, offset); break; case AltosLib.AO_LOG_FORMAT_TELEGPS: eeprom = new AltosEepromGPS(this, offset); break; + case AltosLib.AO_LOG_FORMAT_TELEFIRETWO: + eeprom = new AltosEepromFireTwo(this, offset); + break; default: throw new ParseException("unknown eeprom format " + log_format, 0); } diff --git a/altoslib/AltosEepromFile.java b/altoslib/AltosEepromFile.java index 957c826a..5544ec37 100644 --- a/altoslib/AltosEepromFile.java +++ b/altoslib/AltosEepromFile.java @@ -101,13 +101,17 @@ public class AltosEepromFile extends AltosStateIterable { case AltosLib.AO_LOG_FORMAT_TELEMETRUM: body = new AltosEepromIterable(AltosEepromMetrum2.read(input)); break; - case AltosLib.AO_LOG_FORMAT_TELEMINI: + case AltosLib.AO_LOG_FORMAT_TELEMINI2: + case AltosLib.AO_LOG_FORMAT_TELEMINI3: case AltosLib.AO_LOG_FORMAT_EASYMINI: body = new AltosEepromIterable(AltosEepromMini.read(input)); break; case AltosLib.AO_LOG_FORMAT_TELEGPS: body = new AltosEepromIterable(AltosEepromGPS.read(input)); break; + case AltosLib.AO_LOG_FORMAT_TELEFIRETWO: + body = new AltosEepromIterable(AltosEepromFireTwo.read(input)); + break; default: body = new AltosEepromIterable(new LinkedList<AltosEeprom>()); break; diff --git a/altoslib/AltosEepromFireTwo.java b/altoslib/AltosEepromFireTwo.java new file mode 100644 index 00000000..dd510280 --- /dev/null +++ b/altoslib/AltosEepromFireTwo.java @@ -0,0 +1,118 @@ +/* + * Copyright © 2017 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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_11; + +import java.io.*; +import java.util.*; +import java.text.*; + +public class AltosEepromFireTwo extends AltosEeprom { + public static final int record_length = 32; + + public int record_length() { return record_length; } + + /* AO_LOG_FLIGHT elements */ + public int flight() { return data16(0); } + public int idle_pres() { return data16(2); } + public int idle_thrust() { return data16(4); } + + /* AO_LOG_STATE elements */ + public int state() { return data16(0); } + public int reason() { return data16(2); } + + /* AO_LOG_SENSOR elements */ + public int pres() { return data16(0); } + public int thrust() { return data16(2); } + public int temp(int i) { return data16(4+i*2); } + + public AltosEepromFireTwo (AltosEepromChunk chunk, int start) throws ParseException { + parse_chunk(chunk, start); + } + + private static final double r_above = 5600.0; + private static final double r_below = 10000.0; + private static final double v_adc = 3.3; + + private static double + firetwo_adc(int raw) { + return raw / 4095.0; + } + + private static double + adc_to_pa(int adc) { + + /* raw adc to processor voltage, then back through the + * voltage divider to the sensor voltage + */ + + double v = firetwo_adc(adc) * v_adc * (r_above + r_below) / r_below; + + /* Bound to ranges provided in sensor */ + if (v < 0.5) v = 0.5; + if (v > 4.5) v = 4.5; + + double psi = (v - 0.5) / 4.0 * 1600.0; + return AltosConvert.psi_to_pa(psi); + } + + public void update_state(AltosState state) { + super.update_state(state); + + switch (cmd) { + case AltosLib.AO_LOG_FLIGHT: + state.set_flight(flight()); + state.set_ground_pressure(adc_to_pa(idle_pres())); + break; + case AltosLib.AO_LOG_STATE: + state.set_state(state()); + break; + case AltosLib.AO_LOG_SENSOR: + state.set_pressure(adc_to_pa(pres())); + break; + } + } + + public AltosEepromFireTwo (String line) { + parse_string(line); + } + + static public LinkedList<AltosEeprom> read(FileInputStream input) { + LinkedList<AltosEeprom> firetwos = new LinkedList<AltosEeprom>(); + + for (;;) { + try { + String line = AltosLib.gets(input); + if (line == null) + break; + try { + AltosEepromFireTwo firetwo = new AltosEepromFireTwo(line); + + if (firetwo.cmd != AltosLib.AO_LOG_INVALID) + firetwos.add(firetwo); + } catch (Exception e) { + System.out.printf ("exception\n"); + } + } catch (IOException ie) { + break; + } + } + + return firetwos; + } +} diff --git a/altoslib/AltosEepromMini.java b/altoslib/AltosEepromMini.java index dc51e591..04155071 100644 --- a/altoslib/AltosEepromMini.java +++ b/altoslib/AltosEepromMini.java @@ -42,11 +42,24 @@ public class AltosEepromMini extends AltosEeprom { public int sense_m() { return data16(8); } public int v_batt() { return data16(10); } - double voltage(AltosState state, int sensor) { + private double battery_voltage(AltosState state, int sensor) { if (state.log_format == AltosLib.AO_LOG_FORMAT_EASYMINI) return AltosConvert.easy_mini_voltage(sensor, state.serial); - else - return AltosConvert.tele_mini_voltage(sensor); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI2) + return AltosConvert.tele_mini_2_voltage(sensor); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI3) + return AltosConvert.tele_mini_3_battery_voltage(sensor); + return -1; + } + + private double pyro_voltage(AltosState state, int sensor) { + if (state.log_format == AltosLib.AO_LOG_FORMAT_EASYMINI) + return AltosConvert.easy_mini_voltage(sensor, state.serial); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI2) + return AltosConvert.tele_mini_2_voltage(sensor); + if (state.log_format == AltosLib.AO_LOG_FORMAT_TELEMINI3) + return AltosConvert.tele_mini_3_pyro_voltage(sensor); + return -1; } public void update_state(AltosState state) { @@ -62,9 +75,9 @@ public class AltosEepromMini extends AltosEeprom { break; case AltosLib.AO_LOG_SENSOR: state.set_ms5607(pres(), temp()); - state.set_apogee_voltage(voltage(state, sense_a())); - state.set_main_voltage(voltage(state, sense_m())); - state.set_battery_voltage(voltage(state, v_batt())); + state.set_apogee_voltage(pyro_voltage(state, sense_a())); + state.set_main_voltage(pyro_voltage(state, sense_m())); + state.set_battery_voltage(battery_voltage(state, v_batt())); break; } } diff --git a/altoslib/AltosIdleFetch.java b/altoslib/AltosIdleFetch.java index 8871e9cc..73717e17 100644 --- a/altoslib/AltosIdleFetch.java +++ b/altoslib/AltosIdleFetch.java @@ -38,8 +38,9 @@ class AltosIdler { static final int idle_sensor_metrum = 11; 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_tmini2 = 14; static final int idle_sensor_tgps = 15; + static final int idle_sensor_tmini3 = 16; public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException, AltosUnknownProduct { for (int idler : idlers) { @@ -72,12 +73,15 @@ class AltosIdler { case idle_sensor_emini: AltosSensorEMini.update_state(state, link, config_data); break; - case idle_sensor_tmini: - AltosSensorTMini.update_state(state, link, config_data); + case idle_sensor_tmini2: + AltosSensorTMini2.update_state(state, link, config_data); break; case idle_sensor_tgps: AltosSensorTGPS.update_state(state, link, config_data); break; + case idle_sensor_tmini3: + AltosSensorTMini3.update_state(state, link, config_data); + break; } if (idle != null) idle.update_state(state); @@ -108,7 +112,11 @@ public class AltosIdleFetch implements AltosStateUpdate { new AltosIdler("TeleMini-v2", AltosIdler.idle_ms5607, - AltosIdler.idle_sensor_tmini), + AltosIdler.idle_sensor_tmini2), + + new AltosIdler("TeleMini-v3", + AltosIdler.idle_ms5607, + AltosIdler.idle_sensor_tmini3), new AltosIdler("TeleMetrum-v1", AltosIdler.idle_gps, diff --git a/altoslib/AltosLib.java b/altoslib/AltosLib.java index cfa1fa27..a3f164d4 100644 --- a/altoslib/AltosLib.java +++ b/altoslib/AltosLib.java @@ -332,9 +332,12 @@ public class AltosLib { 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_TELEMINI2 = 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_DETHERM = 11; + public static final int AO_LOG_FORMAT_TELEMINI3 = 12; + public static final int AO_LOG_FORMAT_TELEFIRETWO = 13; public static final int AO_LOG_FORMAT_NONE = 127; public static boolean isspace(int c) { diff --git a/altoslib/AltosSensorTMini.java b/altoslib/AltosSensorTMini2.java index 073144d4..7e00abd0 100644 --- a/altoslib/AltosSensorTMini.java +++ b/altoslib/AltosSensorTMini2.java @@ -20,7 +20,7 @@ package org.altusmetrum.altoslib_11; import java.util.concurrent.TimeoutException; -public class AltosSensorTMini { +public class AltosSensorTMini2 { public int tick; public int apogee; public int main; @@ -28,19 +28,19 @@ public class AltosSensorTMini { static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { try { - AltosSensorTMini sensor_tmini = new AltosSensorTMini(link); + AltosSensorTMini2 sensor_tmini = new AltosSensorTMini2(link); if (sensor_tmini == null) return; - state.set_battery_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.batt)); - state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.apogee)); - state.set_main_voltage(AltosConvert.tele_mini_voltage(sensor_tmini.main)); + state.set_battery_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.batt)); + state.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.apogee)); + state.set_main_voltage(AltosConvert.tele_mini_2_voltage(sensor_tmini.main)); } catch (TimeoutException te) { } } - public AltosSensorTMini(AltosLink link) throws InterruptedException, TimeoutException { + public AltosSensorTMini2(AltosLink link) throws InterruptedException, TimeoutException { String[] items = link.adc(); for (int i = 0; i < items.length;) { if (items[i].equals("tick:")) { diff --git a/altoslib/AltosSensorTMini3.java b/altoslib/AltosSensorTMini3.java new file mode 100644 index 00000000..19d514d7 --- /dev/null +++ b/altoslib/AltosSensorTMini3.java @@ -0,0 +1,70 @@ +/* + * Copyright © 2012 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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_11; + +import java.util.concurrent.TimeoutException; + +public class AltosSensorTMini3 { + public int tick; + public int apogee; + public int main; + public int batt; + + static public void update_state(AltosState state, AltosLink link, AltosConfigData config_data) throws InterruptedException { + try { + AltosSensorTMini3 sensor_tmini = new AltosSensorTMini3(link); + + if (sensor_tmini == null) + return; + state.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(sensor_tmini.batt)); + state.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.apogee)); + state.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sensor_tmini.main)); + + } catch (TimeoutException te) { + } + } + + public AltosSensorTMini3(AltosLink link) throws InterruptedException, TimeoutException { + String[] items = link.adc(); + for (int i = 0; i < items.length;) { + if (items[i].equals("tick:")) { + tick = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("apogee:")) { + apogee = Integer.parseInt(items[i+1]); + i += 2; + continue; + } + if (items[i].equals("main:")) { + main = 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/AltosTelemetry.java b/altoslib/AltosTelemetry.java index 0caefcd6..f830bf35 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -67,7 +67,8 @@ public abstract class AltosTelemetry implements AltosStateUpdate { final static int packet_type_mega_data = 0x09; final static int packet_type_metrum_sensor = 0x0a; final static int packet_type_metrum_data = 0x0b; - final static int packet_type_mini = 0x10; + final static int packet_type_mini2 = 0x10; + final static int packet_type_mini3 = 0x11; static AltosTelemetry parse_hex(String hex) throws ParseException, AltosCRCException { AltosTelemetry telem = null; diff --git a/altoslib/AltosTelemetryMini.java b/altoslib/AltosTelemetryMini2.java index 74adb052..50ec504d 100644 --- a/altoslib/AltosTelemetryMini.java +++ b/altoslib/AltosTelemetryMini2.java @@ -19,7 +19,7 @@ package org.altusmetrum.altoslib_11; -public class AltosTelemetryMini extends AltosTelemetryStandard { +public class AltosTelemetryMini2 extends AltosTelemetryStandard { int state; int v_batt; @@ -35,7 +35,7 @@ public class AltosTelemetryMini extends AltosTelemetryStandard { int ground_pres; - public AltosTelemetryMini(int[] bytes) { + public AltosTelemetryMini2(int[] bytes) { super(bytes); state = int8(5); @@ -59,9 +59,9 @@ public class AltosTelemetryMini extends AltosTelemetryStandard { state.set_state(this.state); - state.set_battery_voltage(AltosConvert.tele_mini_voltage(v_batt)); - state.set_apogee_voltage(AltosConvert.tele_mini_voltage(sense_a)); - state.set_main_voltage(AltosConvert.tele_mini_voltage(sense_m)); + state.set_battery_voltage(AltosConvert.tele_mini_2_voltage(v_batt)); + state.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sense_a)); + state.set_main_voltage(AltosConvert.tele_mini_2_voltage(sense_m)); state.set_ground_pressure(ground_pres); diff --git a/altoslib/AltosTelemetryMini3.java b/altoslib/AltosTelemetryMini3.java new file mode 100644 index 00000000..21f8c485 --- /dev/null +++ b/altoslib/AltosTelemetryMini3.java @@ -0,0 +1,76 @@ +/* + * Copyright © 2017 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; either version 2 of the License, or + * (at your option) any later version. + * + * 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_11; + + +public class AltosTelemetryMini3 extends AltosTelemetryStandard { + + int state; + + int v_batt; + int sense_a; + int sense_m; + + int pres; + int temp; + + int acceleration; + int speed; + int height_16; + + int ground_pres; + + public AltosTelemetryMini3(int[] bytes) { + super(bytes); + + state = int8(5); + + v_batt = int16(6); + sense_a = int16(8); + sense_m = int16(10); + + pres = int32(12); + temp = int16(16); + + acceleration = int16(18); + speed = int16(20); + height_16 = int16(22); + + ground_pres = int32(24); + } + + public void update_state(AltosState state) { + super.update_state(state); + + state.set_state(this.state); + + state.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(v_batt)); + + state.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_a)); + state.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_m)); + + state.set_pressure(pres); + state.set_temperature(temp/100.0); + + state.set_kalman(extend_height(state, height_16), + speed/16.0, acceleration/16.0); + + state.set_ground_pressure(ground_pres); + } +} diff --git a/altoslib/AltosTelemetryStandard.java b/altoslib/AltosTelemetryStandard.java index 4f0d7130..35d315c7 100644 --- a/altoslib/AltosTelemetryStandard.java +++ b/altoslib/AltosTelemetryStandard.java @@ -84,8 +84,11 @@ public abstract class AltosTelemetryStandard extends AltosTelemetry { case packet_type_metrum_data: telem = new AltosTelemetryMetrumData(bytes); break; - case packet_type_mini: - telem = new AltosTelemetryMini(bytes); + case packet_type_mini2: + telem = new AltosTelemetryMini2(bytes); + break; + case packet_type_mini3: + telem = new AltosTelemetryMini3(bytes); break; default: telem = new AltosTelemetryRaw(bytes); diff --git a/altoslib/Makefile.am b/altoslib/Makefile.am index 2a9eb9c9..26159421 100644 --- a/altoslib/Makefile.am +++ b/altoslib/Makefile.am @@ -49,6 +49,7 @@ altoslib_JAVA = \ AltosEepromMini.java \ AltosEepromGPS.java \ AltosEepromMonitor.java \ + AltosEepromFireTwo.java \ AltosFile.java \ AltosFlash.java \ AltosFlashListener.java \ @@ -88,7 +89,8 @@ altoslib_JAVA = \ AltosSensorMM.java \ AltosSensorEMini.java \ AltosSensorTM.java \ - AltosSensorTMini.java \ + AltosSensorTMini2.java \ + AltosSensorTMini3.java \ AltosSensorMega.java \ AltosSensorMetrum.java \ AltosSensorTGPS.java \ @@ -105,7 +107,8 @@ altoslib_JAVA = \ AltosTelemetryMap.java \ AltosTelemetryMegaSensor.java \ AltosTelemetryMegaData.java \ - AltosTelemetryMini.java \ + AltosTelemetryMini2.java \ + AltosTelemetryMini3.java \ AltosTelemetryMetrumSensor.java \ AltosTelemetryMetrumData.java \ AltosTelemetryReader.java \ |