package org.altusmetrum.AltosLib;
-import java.io.*;
import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-import org.altusmetrum.AltosLib.*;
public class AltosConfigData implements Iterable<String> {
package org.altusmetrum.AltosLib;
-import java.io.*;
-import java.util.*;
import java.text.*;
import java.util.concurrent.*;
import java.io.*;
import java.util.*;
import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/*
- * AltosRecords with an index field so they can be sorted by tick while preserving
- * the original ordering for elements with matching ticks
- */
-class AltosOrderedRecord extends AltosEepromRecord implements Comparable<AltosOrderedRecord> {
-
- public int index;
-
- public AltosOrderedRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
- throws ParseException {
- super(line);
- if (prev_tick_valid) {
- tick |= (prev_tick & ~0xffff);
- if (tick < prev_tick) {
- if (prev_tick - tick > 0x8000)
- tick += 0x10000;
- } else {
- if (tick - prev_tick > 0x8000)
- tick -= 0x10000;
- }
- }
- index = in_index;
- }
-
- public AltosOrderedRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
- super(in_cmd, in_tick, in_a, in_b);
- index = in_index;
- }
-
- public String toString() {
- return String.format("%d.%d %04x %04x %04x",
- cmd, index, tick, a, b);
- }
-
- public int compareTo(AltosOrderedRecord o) {
- int tick_diff = tick - o.tick;
- if (tick_diff != 0)
- return tick_diff;
- return index - o.index;
- }
-}
public class AltosEepromIterable extends AltosRecordIterable {
Iterator<AltosOrderedRecord> iterator = records.iterator();
AltosOrderedRecord record = null;
AltosRecordTM state = new AltosRecordTM();
- boolean last_reported = false;
+ //boolean last_reported = false;
EepromState eeprom = new EepromState();
state.state = AltosLib.ao_flight_pad;
if (line == null)
break;
AltosOrderedRecord record = new AltosOrderedRecord(line, index++, prev_tick, prev_tick_valid);
- if (record == null)
- break;
if (record.cmd == AltosLib.AO_LOG_INVALID)
continue;
prev_tick = record.tick;
package org.altusmetrum.AltosLib;
-import java.io.*;
-import java.util.*;
import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
/*
for (block = in_start_block; block < in_end_block; block++) {
AltosEepromChunk eechunk = new AltosEepromChunk(link, block, block == in_start_block);
- for (int i = 0; i < eechunk.chunk_size; i += AltosEepromRecord.record_length) {
+ for (int i = 0; i < AltosEepromChunk.chunk_size; i += AltosEepromRecord.record_length) {
try {
AltosEepromRecord r = new AltosEepromRecord(eechunk, i);
package org.altusmetrum.AltosLib;
-import java.io.*;
-import java.util.*;
import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
public class AltosEepromMega {
public int cmd;
import java.io.*;
import java.util.*;
import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-
-/*
- * AltosRecords with an index field so they can be sorted by tick while preserving
- * the original ordering for elements with matching ticks
- */
-class AltosOrderedMegaRecord extends AltosEepromMega implements Comparable<AltosOrderedMegaRecord> {
-
- public int index;
-
- public AltosOrderedMegaRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
- throws ParseException {
- super(line);
- if (prev_tick_valid) {
- tick |= (prev_tick & ~0xffff);
- if (tick < prev_tick) {
- if (prev_tick - tick > 0x8000)
- tick += 0x10000;
- } else {
- if (tick - prev_tick > 0x8000)
- tick -= 0x10000;
- }
- }
- index = in_index;
- }
-
- public AltosOrderedMegaRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
- super(in_cmd, in_tick);
- a = in_a;
- b = in_b;
- index = in_index;
- }
-
- public String toString() {
- return String.format("%d.%d %04x %04x %04x",
- cmd, index, tick, a, b);
- }
-
- public int compareTo(AltosOrderedMegaRecord o) {
- int tick_diff = tick - o.tick;
- if (tick_diff != 0)
- return tick_diff;
- return index - o.index;
- }
-}
public class AltosEepromMegaIterable extends AltosRecordIterable {
Iterator<AltosOrderedMegaRecord> iterator = records.iterator();
AltosOrderedMegaRecord record = null;
AltosRecordMM state = new AltosRecordMM();
- boolean last_reported = false;
+ //boolean last_reported = false;
EepromState eeprom = new EepromState();
state.state = AltosLib.ao_flight_pad;
if (line == null)
break;
AltosOrderedMegaRecord record = new AltosOrderedMegaRecord(line, index++, prev_tick, prev_tick_valid);
- if (record == null)
- break;
if (record.cmd == AltosLib.AO_LOG_INVALID)
continue;
prev_tick = record.tick;
package org.altusmetrum.AltosLib;
-import java.io.*;
-import java.util.*;
import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
public class AltosEepromRecord {
public int cmd;
package org.altusmetrum.AltosLib;
-import java.io.*;
-import java.util.*;
import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
public class AltosEepromTeleScience {
public int type;
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.io.File;
import java.util.*;
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.text.*;
import java.io.*;
import java.util.concurrent.*;
package org.altusmetrum.AltosLib;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-
public class AltosFrequency {
public double frequency;
public String description;
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.text.*;
public class AltosGPS {
lon = in_lon / 10.0e7;
}
- public void set_time(int hour, int minute, int second) {
- hour = hour;
- minute = minute;
- second = second;
+ public void set_time(int in_hour, int in_minute, int in_second) {
+ hour = in_hour;
+ minute = in_minute;
+ second = in_second;
}
- public void set_date(int year, int month, int day) {
- year = year;
- month = month;
- day = day;
+ public void set_date(int in_year, int in_month, int in_day) {
+ year = in_year;
+ month = in_month;
+ day = in_day;
}
- public void set_flags(int flags) {
- flags = flags;
+ /*
+ public void set_flags(int in_flags) {
+ flags = in_flags;
}
+ */
- public void set_altitude(int altitude) {
- altitude = altitude;
+ public void set_altitude(int in_altitude) {
+ alt = in_altitude;
}
public void add_sat(int svid, int c_n0) {
--- /dev/null
+/*
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.*;
+
+class AltosGPSQuery extends AltosGPS {
+ public AltosGPSQuery (AltosLink link, AltosConfigData config_data)
+ throws TimeoutException, InterruptedException {
+ boolean says_done = config_data.compare_version("1.0") >= 0;
+ link.printf("g\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null)
+ throw new TimeoutException();
+ String[] bits = line.split("\\s+");
+ if (bits.length == 0)
+ continue;
+ if (line.startsWith("Date:")) {
+ if (bits.length < 2)
+ continue;
+ String[] d = bits[1].split(":");
+ if (d.length < 3)
+ continue;
+ year = Integer.parseInt(d[0]) + 2000;
+ month = Integer.parseInt(d[1]);
+ day = Integer.parseInt(d[2]);
+ continue;
+ }
+ if (line.startsWith("Time:")) {
+ if (bits.length < 2)
+ continue;
+ String[] d = bits[1].split("/");
+ if (d.length < 3)
+ continue;
+ hour = Integer.parseInt(d[0]);
+ minute = Integer.parseInt(d[1]);
+ second = Integer.parseInt(d[2]);
+ continue;
+ }
+ if (line.startsWith("Lat/Lon:")) {
+ if (bits.length < 3)
+ continue;
+ lat = Integer.parseInt(bits[1]) * 1.0e-7;
+ lon = Integer.parseInt(bits[2]) * 1.0e-7;
+ continue;
+ }
+ if (line.startsWith("Alt:")) {
+ if (bits.length < 2)
+ continue;
+ alt = Integer.parseInt(bits[1]);
+ continue;
+ }
+ if (line.startsWith("Flags:")) {
+ if (bits.length < 2)
+ continue;
+ int status = Integer.decode(bits[1]);
+ connected = (status & AltosLib.AO_GPS_RUNNING) != 0;
+ locked = (status & AltosLib.AO_GPS_VALID) != 0;
+ if (!says_done)
+ break;
+ continue;
+ }
+ if (line.startsWith("Sats:")) {
+ if (bits.length < 2)
+ continue;
+ nsat = Integer.parseInt(bits[1]);
+ cc_gps_sat = new AltosGPSSat[nsat];
+ for (int i = 0; i < nsat; i++) {
+ int svid = Integer.parseInt(bits[2+i*2]);
+ int cc_n0 = Integer.parseInt(bits[3+i*2]);
+ cc_gps_sat[i] = new AltosGPSSat(svid, cc_n0);
+ }
+ }
+ if (line.startsWith("done"))
+ break;
+ if (line.startsWith("Syntax error"))
+ break;
+ }
+ }
+}
+
--- /dev/null
+/*
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosIMUQuery extends AltosIMU {
+
+ public AltosIMUQuery (AltosLink link) throws InterruptedException, TimeoutException {
+ link.printf("I\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null) {
+ throw new TimeoutException();
+ }
+ if (!line.startsWith("Accel:"))
+ continue;
+ String[] items = line.split("\\s+");
+ if (items.length >= 8) {
+ accel_x = Integer.parseInt(items[1]);
+ accel_y = Integer.parseInt(items[2]);
+ accel_z = Integer.parseInt(items[3]);
+ gyro_x = Integer.parseInt(items[5]);
+ gyro_y = Integer.parseInt(items[6]);
+ gyro_z = Integer.parseInt(items[7]);
+ }
+ break;
+ }
+ }
+}
+
package org.altusmetrum.AltosLib;
import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
import java.util.concurrent.*;
-class AltosSensorTM extends AltosRecordTM {
-
- public AltosSensorTM(AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
- super();
- link.printf("a\n");
- for (;;) {
- String line = link.get_reply_no_dialog(5000);
- if (line == null) {
- throw new TimeoutException();
- }
- if (!line.startsWith("tick:"))
- continue;
- String[] items = line.split("\\s+");
- 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("accel:")) {
- accel = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("pres:")) {
- pres = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("temp:")) {
- temp = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("batt:")) {
- batt = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("drogue:")) {
- drogue = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("main:")) {
- main = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- i++;
- }
- break;
- }
- ground_accel = config_data.accel_cal_plus;
- ground_pres = pres;
- accel_plus_g = config_data.accel_cal_plus;
- accel_minus_g = config_data.accel_cal_minus;
- }
-}
-
-class AltosSensorMM {
- int tick;
- int sense[];
- int v_batt;
- int v_pyro;
- int accel;
- int accel_ref;
-
- public AltosSensorMM(AltosLink link) throws InterruptedException, TimeoutException {
- link.printf("a\n");
- for (;;) {
- String line = link.get_reply_no_dialog(5000);
- if (line == null) {
- throw new TimeoutException();
- }
- if (!line.startsWith("tick:"))
- continue;
- String[] items = line.split("\\s+");
- sense = new int[6];
- 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("0:")) {
- sense[0] = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("1:")) {
- sense[1] = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("2:")) {
- sense[2] = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("3:")) {
- sense[3] = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("4:")) {
- sense[4] = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("5:")) {
- sense[5] = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("6:")) {
- v_batt = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("7:")) {
- v_pyro = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("8:")) {
- accel = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("9:")) {
- accel_ref = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- i++;
- }
- break;
- }
- }
-}
-
-class AltosIMUQuery extends AltosIMU {
-
- public AltosIMUQuery (AltosLink link) throws InterruptedException, TimeoutException {
- link.printf("I\n");
- for (;;) {
- String line = link.get_reply_no_dialog(5000);
- if (line == null) {
- throw new TimeoutException();
- }
- if (!line.startsWith("Accel:"))
- continue;
- String[] items = line.split("\\s+");
- if (items.length >= 8) {
- accel_x = Integer.parseInt(items[1]);
- accel_y = Integer.parseInt(items[2]);
- accel_z = Integer.parseInt(items[3]);
- gyro_x = Integer.parseInt(items[5]);
- gyro_y = Integer.parseInt(items[6]);
- gyro_z = Integer.parseInt(items[7]);
- }
- break;
- }
- }
-}
-
-class AltosMs5607Query extends AltosMs5607 {
- public AltosMs5607Query (AltosLink link) throws InterruptedException, TimeoutException {
- link.printf("v\nB\n");
- for (;;) {
- String line = link.get_reply_no_dialog(5000);
- if (line == null) {
- throw new TimeoutException();
- }
- String[] items = line.split("\\s+");
- if (line.startsWith("Pressure:")) {
- if (items.length >= 2)
- raw_pres = Integer.parseInt(items[1]);
- } else if (line.startsWith("Temperature:")) {
- if (items.length >= 2)
- raw_temp = Integer.parseInt(items[1]);
- } else if (line.startsWith("ms5607 reserved:")) {
- if (items.length >= 3)
- reserved = Integer.parseInt(items[2]);
- } else if (line.startsWith("ms5607 sens:")) {
- if (items.length >= 3)
- sens = Integer.parseInt(items[2]);
- } else if (line.startsWith("ms5607 off:")) {
- if (items.length >= 3)
- off = Integer.parseInt(items[2]);
- } else if (line.startsWith("ms5607 tcs:")) {
- if (items.length >= 3)
- tcs = Integer.parseInt(items[2]);
- } else if (line.startsWith("ms5607 tco:")) {
- if (items.length >= 3)
- tco = Integer.parseInt(items[2]);
- } else if (line.startsWith("ms5607 tref:")) {
- if (items.length >= 3)
- tref = Integer.parseInt(items[2]);
- } else if (line.startsWith("ms5607 tempsens:")) {
- if (items.length >= 3)
- tempsens = Integer.parseInt(items[2]);
- } else if (line.startsWith("ms5607 crc:")) {
- if (items.length >= 3)
- crc = Integer.parseInt(items[2]);
- } else if (line.startsWith("Altitude"))
- break;
- }
- convert();
- }
-}
-
-class AltosGPSQuery extends AltosGPS {
- public AltosGPSQuery (AltosLink link, AltosConfigData config_data)
- throws TimeoutException, InterruptedException {
- boolean says_done = config_data.compare_version("1.0") >= 0;
- link.printf("g\n");
- for (;;) {
- String line = link.get_reply_no_dialog(5000);
- if (line == null)
- throw new TimeoutException();
- String[] bits = line.split("\\s+");
- if (bits.length == 0)
- continue;
- if (line.startsWith("Date:")) {
- if (bits.length < 2)
- continue;
- String[] d = bits[1].split("/");
- if (d.length < 3)
- continue;
- year = Integer.parseInt(d[0]) + 2000;
- month = Integer.parseInt(d[1]);
- day = Integer.parseInt(d[2]);
- continue;
- }
- if (line.startsWith("Time:")) {
- if (bits.length < 2)
- continue;
- String[] d = bits[1].split(":");
- if (d.length < 3)
- continue;
- hour = Integer.parseInt(d[0]);
- minute = Integer.parseInt(d[1]);
- second = Integer.parseInt(d[2]);
- continue;
- }
- if (line.startsWith("Lat/Lon:")) {
- if (bits.length < 3)
- continue;
- lat = Integer.parseInt(bits[1]) * 1.0e-7;
- lon = Integer.parseInt(bits[2]) * 1.0e-7;
- continue;
- }
- if (line.startsWith("Alt:")) {
- if (bits.length < 2)
- continue;
- alt = Integer.parseInt(bits[1]);
- continue;
- }
- if (line.startsWith("Flags:")) {
- if (bits.length < 2)
- continue;
- int status = Integer.decode(bits[1]);
- connected = (status & AltosLib.AO_GPS_RUNNING) != 0;
- locked = (status & AltosLib.AO_GPS_VALID) != 0;
- if (!says_done)
- break;
- continue;
- }
- if (line.startsWith("Sats:")) {
- if (bits.length < 2)
- continue;
- nsat = Integer.parseInt(bits[1]);
- cc_gps_sat = new AltosGPSSat[nsat];
- for (int i = 0; i < nsat; i++) {
- int svid = Integer.parseInt(bits[2+i*2]);
- int cc_n0 = Integer.parseInt(bits[3+i*2]);
- cc_gps_sat[i] = new AltosGPSSat(svid, cc_n0);
- }
- }
- if (line.startsWith("done"))
- break;
- if (line.startsWith("Syntax error"))
- break;
- }
- }
-}
public class AltosIdleMonitor extends Thread {
AltosLink link;
package org.altusmetrum.AltosLib;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-
public interface AltosIdleMonitorListener {
public void update(AltosState state);
}
\ No newline at end of file
+++ /dev/null
-/*
- * 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; version 2 of the License.
- *
- * This program is distributed in the hope that it will be useful, but
- * WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with this program; if not, write to the Free Software Foundation, Inc.,
- * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.altusmetrum.AltosLib;
-
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.*;
-
-class AltosADCTM {
- int tick;
- int accel;
- int pres;
- int temp;
- int batt;
- int drogue;
- int main;
-
- public AltosADCTM(AltosLink link) throws InterruptedException, TimeoutException {
- link.printf("a\n");
- for (;;) {
- String line = link.get_reply_no_dialog(5000);
- if (line == null) {
- throw new TimeoutException();
- }
- if (!line.startsWith("tick:"))
- continue;
- String[] items = line.split("\\s+");
- 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("accel:")) {
- accel = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("pres:")) {
- pres = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("temp:")) {
- temp = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("batt:")) {
- batt = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("drogue:")) {
- drogue = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- if (items[i].equals("main:")) {
- main = Integer.parseInt(items[i+1]);
- i += 2;
- continue;
- }
- i++;
- }
- break;
- }
- }
-}
-
-class AltosGPSQuery extends AltosGPS {
- public AltosGPSQuery (AltosLink link, AltosConfigData config_data)
- throws TimeoutException, InterruptedException {
- boolean says_done = config_data.compare_version("1.0") >= 0;
- link.printf("g\n");
- for (;;) {
- String line = link.get_reply_no_dialog(5000);
- if (line == null)
- throw new TimeoutException();
- String[] bits = line.split("\\s+");
- if (bits.length == 0)
- continue;
- if (line.startsWith("Date:")) {
- if (bits.length < 2)
- continue;
- String[] d = bits[1].split(":");
- if (d.length < 3)
- continue;
- year = Integer.parseInt(d[0]) + 2000;
- month = Integer.parseInt(d[1]);
- day = Integer.parseInt(d[2]);
- continue;
- }
- if (line.startsWith("Time:")) {
- if (bits.length < 2)
- continue;
- String[] d = bits[1].split("/");
- if (d.length < 3)
- continue;
- hour = Integer.parseInt(d[0]);
- minute = Integer.parseInt(d[1]);
- second = Integer.parseInt(d[2]);
- continue;
- }
- if (line.startsWith("Lat/Lon:")) {
- if (bits.length < 3)
- continue;
- lat = Integer.parseInt(bits[1]) * 1.0e-7;
- lon = Integer.parseInt(bits[2]) * 1.0e-7;
- continue;
- }
- if (line.startsWith("Alt:")) {
- if (bits.length < 2)
- continue;
- alt = Integer.parseInt(bits[1]);
- continue;
- }
- if (line.startsWith("Flags:")) {
- if (bits.length < 2)
- continue;
- int status = Integer.decode(bits[1]);
- connected = (status & AltosLib.AO_GPS_RUNNING) != 0;
- locked = (status & AltosLib.AO_GPS_VALID) != 0;
- if (!says_done)
- break;
- continue;
- }
- if (line.startsWith("Sats:")) {
- if (bits.length < 2)
- continue;
- nsat = Integer.parseInt(bits[1]);
- cc_gps_sat = new AltosGPSSat[nsat];
- for (int i = 0; i < nsat; i++) {
- int svid = Integer.parseInt(bits[2+i*2]);
- int cc_n0 = Integer.parseInt(bits[3+i*2]);
- cc_gps_sat[i] = new AltosGPSSat(svid, cc_n0);
- }
- }
- if (line.startsWith("done"))
- break;
- if (line.startsWith("Syntax error"))
- break;
- }
- }
-}
-
-public class AltosIdleMonitor extends Thread {
- AltosLink link;
- AltosIdleMonitorListener listener;
- AltosState state;
- boolean remote;
- double frequency;
- AltosState previous_state;
- AltosConfigData config_data;
- AltosADC adc;
- 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 update_state() throws InterruptedException, TimeoutException {
- AltosRecordTM record = new AltosRecordTM();
- int rssi;
-
- try {
- if (remote) {
- link.set_radio_frequency(frequency);
- link.start_remote();
- } else
- link.flush_input();
- config_data = new AltosConfigData(link);
- adc = new AltosADC(link);
- gps = new AltosGPSQuery(link, config_data);
- } finally {
- if (remote) {
- link.stop_remote();
- rssi = AltosRSSI();
- } else
- rssi = 0;
- }
-
- record.version = 0;
- record.callsign = config_data.callsign;
- record.serial = config_data.serial;
- record.flight = config_data.log_available() > 0 ? 255 : 0;
- record.rssi = rssi;
- record.status = 0;
- record.state = AltosLib.ao_flight_idle;
-
- record.tick = adc.tick;
-
- record.accel = adc.accel;
- record.pres = adc.pres;
- record.batt = adc.batt;
- record.temp = adc.temp;
- record.drogue = adc.drogue;
- record.main = adc.main;
-
- record.ground_accel = record.accel;
- record.ground_pres = record.pres;
- record.accel_plus_g = config_data.accel_cal_plus;
- record.accel_minus_g = config_data.accel_cal_minus;
- record.acceleration = 0;
- record.speed = 0;
- record.height = 0;
- record.gps = gps;
- state = new AltosState (record, state);
- }
-
- public void set_frequency(double in_frequency) {
- frequency = in_frequency;
- }
-
- public void post_state() {
- listener.update(state);
- }
-
- public void run() {
- try {
- for (;;) {
- try {
- update_state();
- post_state();
- } catch (TimeoutException te) {
- }
- Thread.sleep(1000);
- }
- } catch (InterruptedException ie) {
- link.close();
- }
- }
-
- public AltosIdleMonitor(AltosIdleMonitorListener in_listener, AltosLink in_link, boolean in_remote)
- throws FileNotFoundException, InterruptedException, TimeoutException {
- listener = in_listener;
- link = in_link;
- remote = in_remote;
- state = null;
- }
-}
}
}
+ /*
private boolean get_string(String line, String label, string_ref s) {
if (line.startsWith(label)) {
String quoted = line.substring(label.length()).trim();
return false;
}
}
+ */
private int status(String status_name) {
if (status_name.equals("unknown"))
int status = Unknown;
if (link == null)
return status;
- string_ref status_name = new string_ref();
+ //string_ref status_name = new string_ref();
try {
start_link();
link.printf("t\n");
package org.altusmetrum.AltosLib;
-import java.awt.*;
import java.util.*;
-import java.text.*;
import java.io.*;
import java.nio.charset.Charset;
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.io.*;
import java.util.concurrent.*;
import java.util.*;
-import java.text.*;
public abstract class AltosLink implements Runnable {
package org.altusmetrum.AltosLib;
import java.io.*;
-import java.lang.*;
-import java.util.*;
import java.text.ParseException;
import java.util.concurrent.LinkedBlockingQueue;
int TEMP;
long OFF;
long SENS;
- int P;
+ //int P;
dT = raw_temp - ((int) tref << 8);
--- /dev/null
+/*
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosMs5607Query extends AltosMs5607 {
+ public AltosMs5607Query (AltosLink link) throws InterruptedException, TimeoutException {
+ link.printf("v\nB\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null) {
+ throw new TimeoutException();
+ }
+ String[] items = line.split("\\s+");
+ if (line.startsWith("Pressure:")) {
+ if (items.length >= 2)
+ raw_pres = Integer.parseInt(items[1]);
+ } else if (line.startsWith("Temperature:")) {
+ if (items.length >= 2)
+ raw_temp = Integer.parseInt(items[1]);
+ } else if (line.startsWith("ms5607 reserved:")) {
+ if (items.length >= 3)
+ reserved = Integer.parseInt(items[2]);
+ } else if (line.startsWith("ms5607 sens:")) {
+ if (items.length >= 3)
+ sens = Integer.parseInt(items[2]);
+ } else if (line.startsWith("ms5607 off:")) {
+ if (items.length >= 3)
+ off = Integer.parseInt(items[2]);
+ } else if (line.startsWith("ms5607 tcs:")) {
+ if (items.length >= 3)
+ tcs = Integer.parseInt(items[2]);
+ } else if (line.startsWith("ms5607 tco:")) {
+ if (items.length >= 3)
+ tco = Integer.parseInt(items[2]);
+ } else if (line.startsWith("ms5607 tref:")) {
+ if (items.length >= 3)
+ tref = Integer.parseInt(items[2]);
+ } else if (line.startsWith("ms5607 tempsens:")) {
+ if (items.length >= 3)
+ tempsens = Integer.parseInt(items[2]);
+ } else if (line.startsWith("ms5607 crc:")) {
+ if (items.length >= 3)
+ crc = Integer.parseInt(items[2]);
+ } else if (line.startsWith("Altitude"))
+ break;
+ }
+ convert();
+ }
+}
+
--- /dev/null
+/*
+ * Copyright © 2010 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;
+
+import java.text.ParseException;
+
+/*
+ * AltosRecords with an index field so they can be sorted by tick while preserving
+ * the original ordering for elements with matching ticks
+ */
+class AltosOrderedMegaRecord extends AltosEepromMega implements Comparable<AltosOrderedMegaRecord> {
+
+ public int index;
+
+ public AltosOrderedMegaRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
+ throws ParseException {
+ super(line);
+ if (prev_tick_valid) {
+ tick |= (prev_tick & ~0xffff);
+ if (tick < prev_tick) {
+ if (prev_tick - tick > 0x8000)
+ tick += 0x10000;
+ } else {
+ if (tick - prev_tick > 0x8000)
+ tick -= 0x10000;
+ }
+ }
+ index = in_index;
+ }
+
+ public AltosOrderedMegaRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
+ super(in_cmd, in_tick);
+ a = in_a;
+ b = in_b;
+ index = in_index;
+ }
+
+ public String toString() {
+ return String.format("%d.%d %04x %04x %04x",
+ cmd, index, tick, a, b);
+ }
+
+ public int compareTo(AltosOrderedMegaRecord o) {
+ int tick_diff = tick - o.tick;
+ if (tick_diff != 0)
+ return tick_diff;
+ return index - o.index;
+ }
+}
--- /dev/null
+/*
+ * Copyright © 2010 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;
+
+import java.text.ParseException;
+
+/*
+ * AltosRecords with an index field so they can be sorted by tick while preserving
+ * the original ordering for elements with matching ticks
+ */
+class AltosOrderedRecord extends AltosEepromRecord implements Comparable<AltosOrderedRecord> {
+
+ public int index;
+
+ public AltosOrderedRecord(String line, int in_index, int prev_tick, boolean prev_tick_valid)
+ throws ParseException {
+ super(line);
+ if (prev_tick_valid) {
+ tick |= (prev_tick & ~0xffff);
+ if (tick < prev_tick) {
+ if (prev_tick - tick > 0x8000)
+ tick += 0x10000;
+ } else {
+ if (tick - prev_tick > 0x8000)
+ tick -= 0x10000;
+ }
+ }
+ index = in_index;
+ }
+
+ public AltosOrderedRecord(int in_cmd, int in_tick, int in_a, int in_b, int in_index) {
+ super(in_cmd, in_tick, in_a, in_b);
+ index = in_index;
+ }
+
+ public String toString() {
+ return String.format("%d.%d %04x %04x %04x",
+ cmd, index, tick, a, b);
+ }
+
+ public int compareTo(AltosOrderedRecord o) {
+ int tick_diff = tick - o.tick;
+ if (tick_diff != 0)
+ return tick_diff;
+ return index - o.index;
+ }
+}
+
package org.altusmetrum.AltosLib;
import java.text.*;
-import java.lang.*;
public class AltosParse {
public static boolean isdigit(char c) {
import java.io.*;
import java.util.*;
-import java.text.*;
import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
-import java.awt.Component;
-import javax.swing.*;
import javax.swing.filechooser.FileSystemView;
public class AltosPreferences {
package org.altusmetrum.AltosLib;
-import java.lang.*;
-import java.text.*;
-import java.util.HashMap;
-import java.io.*;
-
public class AltosRecord implements Comparable <AltosRecord>, Cloneable {
public static final int seen_flight = 1;
import java.io.*;
import java.util.*;
-import java.text.*;
-import java.util.prefs.*;
-import java.util.concurrent.LinkedBlockingQueue;
/*
* Open an existing telemetry file and replay it in realtime
--- /dev/null
+/*
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosSensorMM {
+ int tick;
+ int sense[];
+ int v_batt;
+ int v_pyro;
+ int accel;
+ int accel_ref;
+
+ public AltosSensorMM(AltosLink link) throws InterruptedException, TimeoutException {
+ link.printf("a\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null) {
+ throw new TimeoutException();
+ }
+ if (!line.startsWith("tick:"))
+ continue;
+ String[] items = line.split("\\s+");
+ sense = new int[6];
+ 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("0:")) {
+ sense[0] = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("1:")) {
+ sense[1] = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("2:")) {
+ sense[2] = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("3:")) {
+ sense[3] = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("4:")) {
+ sense[4] = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("5:")) {
+ sense[5] = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("6:")) {
+ v_batt = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("7:")) {
+ v_pyro = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("8:")) {
+ accel = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("9:")) {
+ accel_ref = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ i++;
+ }
+ break;
+ }
+ }
+}
+
--- /dev/null
+/*
+ * 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; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+ */
+
+package org.altusmetrum.AltosLib;
+
+import java.util.concurrent.TimeoutException;
+
+class AltosSensorTM extends AltosRecordTM {
+
+ public AltosSensorTM(AltosLink link, AltosConfigData config_data) throws InterruptedException, TimeoutException {
+ super();
+ link.printf("a\n");
+ for (;;) {
+ String line = link.get_reply_no_dialog(5000);
+ if (line == null) {
+ throw new TimeoutException();
+ }
+ if (!line.startsWith("tick:"))
+ continue;
+ String[] items = line.split("\\s+");
+ 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("accel:")) {
+ accel = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("pres:")) {
+ pres = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("temp:")) {
+ temp = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("batt:")) {
+ batt = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("drogue:")) {
+ drogue = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ if (items[i].equals("main:")) {
+ main = Integer.parseInt(items[i+1]);
+ i += 2;
+ continue;
+ }
+ i++;
+ }
+ break;
+ }
+ ground_accel = config_data.accel_cal_plus;
+ ground_pres = pres;
+ accel_plus_g = config_data.accel_cal_plus;
+ accel_minus_g = config_data.accel_cal_minus;
+ }
+}
+
public double speak_altitude;
public void init (AltosRecord cur, AltosState prev_state) {
- int i;
- AltosRecord prev;
+ //int i;
+ //AltosRecord prev;
data = cur;
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.text.*;
-import java.util.HashMap;
/*
* Telemetry data contents
*/
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.text.*;
import java.util.HashMap;
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.text.*;
import java.io.*;
import java.util.concurrent.*;
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.text.*;
-import java.util.HashMap;
public class AltosTelemetryRecordGeneral {
package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.text.*;
-import java.util.HashMap;
/*
* Telemetry data contents
int[] bytes;
int adjust;
+ /*
private int int8(int i) {
return AltosLib.int8(bytes, i + 1 + adjust);
}
+ */
private int uint8(int i) {
return AltosLib.uint8(bytes, i + 1 + adjust);
}
record.gps = new AltosGPS();
record.new_gps = true;
- record.seen |= record.seen_gps_time | record.seen_gps_lat | record.seen_gps_lon;
+ record.seen |= AltosRecord.seen_gps_time | AltosRecord.seen_gps_lat | AltosRecord.seen_gps_lon;
record.gps.nsat = (gps_flags & AO_GPS_NUM_SAT_MASK);
record.gps.locked = (gps_flags & AO_GPS_VALID) != 0;
record.gps.connected = true;
package org.altusmetrum.AltosLib;
-import java.lang.*;
-import java.text.*;
-import java.util.HashMap;
-
public class AltosTelemetryRecordRaw extends AltosTelemetryRecord {
int[] bytes;
int serial;