summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKeith Packard <keithp@keithp.com>2010-09-03 01:12:24 -0700
committerKeith Packard <keithp@keithp.com>2010-09-03 07:04:28 -0700
commite5ef42c2b22c6639d90631dbbb588f9fd2494385 (patch)
tree2ebe6d2a3a08cd7c27ad697675f68a0af2bc7c5f
parent3b3aa448f3a0f44137f7530b04b58967ba5f22f5 (diff)
altosui: Report telemetry CRC errors in UI
Telemetry CRC errors can signal problems with TeleMetrum or TeleDongle units, so report them in the UI. Signed-off-by: Keith Packard <keithp@keithp.com>
-rw-r--r--ao-tools/altosui/AltosCRCException.java26
-rw-r--r--ao-tools/altosui/AltosLog.java1
-rw-r--r--ao-tools/altosui/AltosSerial.java2
-rw-r--r--ao-tools/altosui/AltosTelemetry.java9
-rw-r--r--ao-tools/altosui/AltosTelemetryReader.java2
-rw-r--r--ao-tools/altosui/AltosUI.java26
-rw-r--r--ao-tools/altosui/Makefile1
7 files changed, 56 insertions, 11 deletions
diff --git a/ao-tools/altosui/AltosCRCException.java b/ao-tools/altosui/AltosCRCException.java
new file mode 100644
index 00000000..4a529bcf
--- /dev/null
+++ b/ao-tools/altosui/AltosCRCException.java
@@ -0,0 +1,26 @@
+/*
+ * 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 altosui;
+
+public class AltosCRCException extends Exception {
+ public int rssi;
+
+ public AltosCRCException (int in_rssi) {
+ rssi = in_rssi;
+ }
+}
diff --git a/ao-tools/altosui/AltosLog.java b/ao-tools/altosui/AltosLog.java
index ec868b9c..2c241771 100644
--- a/ao-tools/altosui/AltosLog.java
+++ b/ao-tools/altosui/AltosLog.java
@@ -74,6 +74,7 @@ class AltosLog implements Runnable {
open(telem);
}
} catch (ParseException pe) {
+ } catch (AltosCRCException ce) {
}
if (log_file != null) {
log_file.write(line);
diff --git a/ao-tools/altosui/AltosSerial.java b/ao-tools/altosui/AltosSerial.java
index 99ba3324..c3daf3b9 100644
--- a/ao-tools/altosui/AltosSerial.java
+++ b/ao-tools/altosui/AltosSerial.java
@@ -71,7 +71,7 @@ public class AltosSerial implements Runnable {
for (int i = 0; i < line_count; i++)
line = line + line_bytes[i];
}
- if (line.startsWith("VERSION")) {
+ if (line.startsWith("VERSION") || line.startsWith("CRC")) {
for (int e = 0; e < monitors.size(); e++) {
LinkedBlockingQueue<String> q = monitors.get(e);
q.put(line);
diff --git a/ao-tools/altosui/AltosTelemetry.java b/ao-tools/altosui/AltosTelemetry.java
index bc62690b..be22dac6 100644
--- a/ao-tools/altosui/AltosTelemetry.java
+++ b/ao-tools/altosui/AltosTelemetry.java
@@ -23,6 +23,7 @@ import java.util.HashMap;
import altosui.AltosConvert;
import altosui.AltosRecord;
import altosui.AltosGPS;
+import altosui.AltosCRCException;
/*
* Telemetry data contents
@@ -53,10 +54,16 @@ import altosui.AltosGPS;
*/
public class AltosTelemetry extends AltosRecord {
- public AltosTelemetry(String line) throws ParseException {
+ public AltosTelemetry(String line) throws ParseException, AltosCRCException {
String[] words = line.split("\\s+");
int i = 0;
+ if (words[i].equals("CRC") && words[i+1].equals("INVALID")) {
+ i += 2;
+ AltosParse.word(words[i++], "RSSI");
+ rssi = AltosParse.parse_int(words[i++]);
+ throw new AltosCRCException(rssi);
+ }
if (words[i].equals("CALL")) {
version = 0;
} else {
diff --git a/ao-tools/altosui/AltosTelemetryReader.java b/ao-tools/altosui/AltosTelemetryReader.java
index a3402f9c..fdedbde2 100644
--- a/ao-tools/altosui/AltosTelemetryReader.java
+++ b/ao-tools/altosui/AltosTelemetryReader.java
@@ -62,6 +62,8 @@ public class AltosTelemetryReader extends AltosReader {
records.add(record);
} catch (ParseException pe) {
System.out.printf("parse exception %s\n", pe.getMessage());
+ } catch (AltosCRCException ce) {
+ System.out.printf("crc error\n");
}
}
} catch (IOException io) {
diff --git a/ao-tools/altosui/AltosUI.java b/ao-tools/altosui/AltosUI.java
index 5b48e26f..e3f61303 100644
--- a/ao-tools/altosui/AltosUI.java
+++ b/ao-tools/altosui/AltosUI.java
@@ -168,21 +168,17 @@ public class AltosUI extends JFrame {
flightInfoModel[i].finish();
}
- public void show(AltosState state) {
+ public void show(AltosState state, int crc_errors) {
flightStatusModel.set(state);
info_reset();
- if (state.gps_ready)
- info_add_row(0, "Ground state", "%s", "ready");
- else
- info_add_row(0, "Ground state", "wait (%d)",
- state.gps_waiting);
info_add_row(0, "Rocket state", "%s", state.data.state());
info_add_row(0, "Callsign", "%s", state.data.callsign);
info_add_row(0, "Rocket serial", "%6d", state.data.serial);
info_add_row(0, "Rocket flight", "%6d", state.data.flight);
info_add_row(0, "RSSI", "%6d dBm", state.data.rssi);
+ info_add_row(0, "CRC Errors", "%6d", crc_errors);
info_add_row(0, "Height", "%6.0f m", state.height);
info_add_row(0, "Max height", "%6.0f m", state.max_height);
info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration);
@@ -197,6 +193,11 @@ public class AltosUI extends JFrame {
if (state.gps == null) {
info_add_row(1, "GPS", "not available");
} else {
+ if (state.gps_ready)
+ info_add_row(1, "GPS state", "%s", "ready");
+ else
+ info_add_row(1, "GPS state", "wait (%d)",
+ state.gps_waiting);
if (state.data.gps.locked)
info_add_row(1, "GPS", " locked");
else if (state.data.gps.connected)
@@ -362,7 +363,11 @@ public class AltosUI extends JFrame {
String name;
- AltosRecord read() throws InterruptedException, ParseException { return null; }
+ int crc_errors;
+
+ void init() { }
+
+ AltosRecord read() throws InterruptedException, ParseException, AltosCRCException { return null; }
void close() { }
@@ -387,11 +392,14 @@ public class AltosUI extends JFrame {
old_state = state;
state = new AltosState(record, state);
update(state);
- show(state);
+ show(state, crc_errors);
tell(state, old_state);
idle_thread.notice(state);
} catch (ParseException pp) {
System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage());
+ } catch (AltosCRCException ce) {
+ ++crc_errors;
+ show(state, crc_errors);
}
}
} catch (InterruptedException ee) {
@@ -411,7 +419,7 @@ public class AltosUI extends JFrame {
AltosSerial serial;
LinkedBlockingQueue<String> telem;
- AltosRecord read() throws InterruptedException, ParseException {
+ AltosRecord read() throws InterruptedException, ParseException, AltosCRCException {
return new AltosTelemetry(telem.take());
}
diff --git a/ao-tools/altosui/Makefile b/ao-tools/altosui/Makefile
index 0f5d05c8..8509391e 100644
--- a/ao-tools/altosui/Makefile
+++ b/ao-tools/altosui/Makefile
@@ -7,6 +7,7 @@ CLASSFILES=\
AltosConfig.class \
AltosConfigUI.class \
AltosConvert.class \
+ AltosCRCException.class \
AltosCSV.class \
AltosCSVUI.class \
AltosDebug.class \