summaryrefslogtreecommitdiff
path: root/altoslib/AltosTelemetry.java
diff options
context:
space:
mode:
authorBdale Garbee <bdale@gag.com>2017-12-11 21:37:48 -0700
committerBdale Garbee <bdale@gag.com>2017-12-11 21:37:48 -0700
commitea0aa97fb93e669868a6f2c49c5d4b46e7615b1f (patch)
treef16b9a9ccd8b4a7bcde7d5cc64e6f0a52c4f3436 /altoslib/AltosTelemetry.java
parent216ea6388a75c46891dc4687a2eb0c97dc63b136 (diff)
parent9adf8b23aac8256f230b10adcab9dd323266caaa (diff)
Merge branch 'master' into branch-1.8
Diffstat (limited to 'altoslib/AltosTelemetry.java')
-rw-r--r--altoslib/AltosTelemetry.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java
index f17e1171..a374519d 100644
--- a/altoslib/AltosTelemetry.java
+++ b/altoslib/AltosTelemetry.java
@@ -28,8 +28,11 @@ public abstract class AltosTelemetry implements AltosDataProvider {
int[] bytes;
/* All telemetry packets have these fields */
- public int rssi() { return AltosConvert.telem_to_rssi(AltosLib.int8(bytes, bytes.length - 3)); }
- public int status() { return AltosLib.uint8(bytes, bytes.length - 2); }
+ static public int rssi(int[] bytes) { return AltosConvert.telem_to_rssi(AltosLib.int8(bytes, bytes.length - 3)); }
+ static public int status(int[] bytes) { return AltosLib.uint8(bytes, bytes.length - 2); }
+
+ public int rssi() { return rssi(bytes); }
+ public int status() { return status(bytes); }
/* All telemetry packets report these fields in some form */
public abstract int serial();
@@ -51,7 +54,7 @@ public abstract class AltosTelemetry implements AltosDataProvider {
public void provide_data(AltosDataListener listener) {
listener.set_serial(serial());
- if (listener.state == AltosLib.ao_flight_invalid)
+ if (listener.state() == AltosLib.ao_flight_invalid)
listener.set_state(AltosLib.ao_flight_startup);
if (frequency != AltosLib.MISSING)
listener.set_frequency(frequency);
@@ -96,6 +99,9 @@ public abstract class AltosTelemetry implements AltosDataProvider {
if (!cksum(bytes))
throw new ParseException(String.format("invalid line \"%s\"", hex), 0);
+ if ((status(bytes) & PKT_APPEND_STATUS_1_CRC_OK) == 0)
+ throw new AltosCRCException(rssi(bytes));
+
/* length, data ..., rssi, status, checksum -- 4 bytes extra */
switch (bytes.length) {
case AltosLib.ao_telemetry_standard_len + 4: