From de2b6ec1cdfd48c948bff7edbfe2540440429b1b Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Oct 2017 16:55:18 -0700 Subject: altoslib,altosuilib,altosui: log_format/device_type TeleGPS selects stateless When the device being analyzed has no flight state, we want to use the 'stateless' state so that the UI can display reasonable information. This bit was lost in the recent AltosState shuffle and this patch brings it back. Signed-off-by: Keith Packard --- altoslib/AltosTelemetry.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'altoslib/AltosTelemetry.java') diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index f17e1171..fe536c6a 100644 --- a/altoslib/AltosTelemetry.java +++ b/altoslib/AltosTelemetry.java @@ -51,7 +51,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); -- cgit v1.2.3 From c6be13e8ef80e5afc836e04cbfe4cb17631540e4 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Mon, 2 Oct 2017 16:58:53 -0700 Subject: altoslib: Allow early bail-out on bad telemetry CRC Check the CRC status in the packet before creating a new telemetry object. Signed-off-by: Keith Packard --- altoslib/AltosTelemetry.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'altoslib/AltosTelemetry.java') diff --git a/altoslib/AltosTelemetry.java b/altoslib/AltosTelemetry.java index fe536c6a..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(); @@ -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: -- cgit v1.2.3