X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=altosui%2FAltosTelemetryRecordRaw.java;h=39b2ba0772a2d3efdf56d897023ce5bd3718402c;hp=35796a22fd5a9606a7958af266e2c7b86ceb4e1d;hb=c3314dae2d3df82e188daf6ba8520cce833592c6;hpb=7fd9b8f720add559b262e81d61ededc9df16ca94 diff --git a/altosui/AltosTelemetryRecordRaw.java b/altosui/AltosTelemetryRecordRaw.java index 35796a22..39b2ba07 100644 --- a/altosui/AltosTelemetryRecordRaw.java +++ b/altosui/AltosTelemetryRecordRaw.java @@ -30,9 +30,10 @@ public class AltosTelemetryRecordRaw implements AltosTelemetryRecord { final static int packet_type_TM_sensor = 0x01; final static int packet_type_Tm_sensor = 0x02; final static int packet_type_Tn_sensor = 0x03; - final static int packet_type_config = 0x04; - final static int packet_type_GPS_location = 0x05; - final static int packet_type_GPS_satellites = 0x06; + final static int packet_type_configuration = 0x04; + final static int packet_type_location = 0x05; + final static int packet_type_satellite = 0x06; + final static int packet_type_companion = 0x07; final static int PKT_APPEND_STATUS_1_CRC_OK = (1 << 7); final static int PKT_APPEND_STATUS_1_LQI_MASK = (0x7f); @@ -43,8 +44,6 @@ public class AltosTelemetryRecordRaw implements AltosTelemetryRecord { for (int i = 1; i < bytes.length - 1; i++) sum += bytes[i]; sum &= 0xff; - System.out.printf("%d bytes sum 0x%x last byte 0x%x\n", - bytes.length, sum, bytes[bytes.length - 1]); return sum == bytes[bytes.length - 1]; } @@ -69,28 +68,40 @@ public class AltosTelemetryRecordRaw implements AltosTelemetryRecord { int rssi = Altos.int8(bytes, bytes.length - 3) / 2 - 74; int status = Altos.uint8(bytes, bytes.length - 2); - System.out.printf ("rssi 0x%x = %d status 0x%x\n", - Altos.uint8(bytes, bytes.length - 3), - rssi, status); - if ((status & PKT_APPEND_STATUS_1_CRC_OK) == 0) throw new AltosCRCException(rssi); /* length, data ..., rssi, status, checksum -- 4 bytes extra */ switch (bytes.length) { - case Altos.ao_telemetry_split_len + 4: + case Altos.ao_telemetry_standard_len + 4: int type = Altos.uint8(bytes, 4 + 1); switch (type) { case packet_type_TM_sensor: case packet_type_Tm_sensor: case packet_type_Tn_sensor: - r = new AltosTelemetryRecordSensor(bytes); + r = new AltosTelemetryRecordSensor(bytes, rssi); + break; + case packet_type_configuration: + r = new AltosTelemetryRecordConfiguration(bytes); + break; + case packet_type_location: + r = new AltosTelemetryRecordLocation(bytes); + break; + case packet_type_satellite: + r = new AltosTelemetryRecordSatellite(bytes); + break; + case packet_type_companion: + r = new AltosTelemetryRecordCompanion(bytes); break; default: r = new AltosTelemetryRecordRaw(bytes); break; } - case Altos.ao_telemetry_legacy_len + 4: + break; + case Altos.ao_telemetry_0_9_len + 4: + r = new AltosTelemetryRecordLegacy(bytes, rssi, status); + break; + case Altos.ao_telemetry_0_8_len + 4: r = new AltosTelemetryRecordLegacy(bytes, rssi, status); break; default: @@ -119,6 +130,10 @@ public class AltosTelemetryRecordRaw implements AltosTelemetryRecord { return Altos.uint32(bytes, off + 1); } + public String string(int off, int l) { + return Altos.string(bytes, off + 1, l); + } + public AltosTelemetryRecordRaw(int[] in_bytes) { bytes = in_bytes; serial = uint16(0); @@ -127,9 +142,15 @@ public class AltosTelemetryRecordRaw implements AltosTelemetryRecord { } public AltosRecord update_state(AltosRecord previous) { - if (previous != null) - return new AltosRecord(previous); - else - return new AltosRecord(); + AltosRecord next; + if (previous != null) { + next = new AltosRecord(previous); + while (tick < previous.tick) + tick += 65536; + } else + next = new AltosRecord(); + next.serial = serial; + next.tick = tick; + return next; } }