These values are only needed once, so there's no reason to save them.
Signed-off-by: Keith Packard <keithp@keithp.com>
*/
public abstract class AltosTelemetry implements AltosStateUpdate {
+ int[] bytes;
/* All telemetry packets have these fields */
- public int tick;
- public int serial;
- public int rssi;
- public int status;
+ public int rssi() { return AltosConvert.telem_to_rssi(AltosLib.int8(bytes, bytes.length - 3)); }
+ public int status() { return AltosLib.uint8(bytes, bytes.length - 2); }
+
+ /* All telemetry packets report these fields in some form */
+ public abstract int serial();
+ public abstract int tick();
/* Mark when we received the packet */
long received_time;
}
public void update_state(AltosState state) {
- state.set_serial(serial);
+ state.set_serial(serial());
if (state.state() == AltosLib.ao_flight_invalid)
state.set_state(AltosLib.ao_flight_startup);
- state.set_tick(tick);
- state.set_rssi(rssi, status);
+ state.set_tick(tick());
+ state.set_rssi(rssi(), status());
state.set_received_time(received_time);
}
if (!cksum(bytes))
throw new ParseException(String.format("invalid line \"%s\"", hex), 0);
- int rssi = AltosLib.int8(bytes, bytes.length - 3) / 2 - 74;
- int status = AltosLib.uint8(bytes, bytes.length - 2);
-
- 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 AltosLib.ao_telemetry_standard_len + 4:
default:
throw new ParseException(String.format("Invalid packet length %d", bytes.length), 0);
}
- if (telem != null) {
- telem.received_time = System.currentTimeMillis();
- telem.rssi = rssi;
- telem.status = status;
- }
return telem;
}
return height;
}
+ public AltosTelemetry() {
+ this.received_time = System.currentTimeMillis();
+ }
+
+ public AltosTelemetry(int[] bytes) throws AltosCRCException {
+ this();
+ this.bytes = bytes;
+ if ((status() & PKT_APPEND_STATUS_1_CRC_OK) == 0)
+ throw new AltosCRCException(rssi());
+ }
+
public static AltosTelemetry parse(String line) throws ParseException, AltosCRCException {
String[] word = line.split("\\s+");
int i =0;
throw new AltosCRCException(AltosParse.parse_int(word[i++]));
}
- AltosTelemetry telem;
+ AltosTelemetry telem = null;
if (word[i].equals("TELEM")) {
telem = parse_hex(word[i+1]);
package org.altusmetrum.altoslib_11;
public class AltosTelemetryCompanion extends AltosTelemetryStandard {
- AltosCompanion companion;
-
- static final public int max_channels = 12;
-
- public AltosTelemetryCompanion(int[] bytes) {
- super(bytes);
+ AltosCompanion companion() {
int channels = uint8(7);
if (channels > max_channels)
channels = max_channels;
- companion = new AltosCompanion(channels);
+ AltosCompanion companion = new AltosCompanion(channels);
- companion.tick = tick;
+ companion.tick = tick();
companion.board_id = uint8(5);
companion.update_period = uint8(6);
for (int i = 0; i < channels; i++)
companion.companion_data[i] = uint16(8 + i * 2);
}
+ return companion;
+ }
+
+ static final public int max_channels = 12;
+
+ public AltosTelemetryCompanion(int[] bytes) throws AltosCRCException {
+ super(bytes);
}
public void update_state(AltosState state) {
super.update_state(state);
-
- state.set_companion(companion);
+ state.set_companion(companion());
}
}
public class AltosTelemetryConfiguration extends AltosTelemetryStandard {
- int device_type;
- int flight;
- int config_major;
- int config_minor;
- int apogee_delay;
- int main_deploy;
- int v_batt;
- int flight_log_max;
- String callsign;
- String version;
+ int device_type() { return uint8(5); }
+ int flight() { return uint16(6); }
+ int config_major() { return uint8(8); }
+ int config_minor() { return uint8(9); }
+ int apogee_delay() { return uint16(10); }
+ int main_deploy() { return uint16(12); }
+ int v_batt() { return uint16(10); }
+ int flight_log_max() { return uint16(14); }
+ String callsign() { return string(16, 8); }
+ String version() { return string(24, 8); }
- public AltosTelemetryConfiguration(int[] bytes) {
+ public AltosTelemetryConfiguration(int[] bytes) throws AltosCRCException {
super(bytes);
-
- device_type = uint8(5);
- flight = uint16(6);
- config_major = uint8(8);
- config_minor = uint8(9);
- v_batt = uint16(10);
- apogee_delay = uint16(10);
- main_deploy = uint16(12);
- flight_log_max = uint16(14);
- callsign = string(16, 8);
- version = string(24, 8);
}
public void update_state(AltosState state) {
super.update_state(state);
- state.set_device_type(device_type);
- state.set_flight(flight);
- state.set_config(config_major, config_minor, flight_log_max);
- if (device_type == AltosLib.product_telegps)
- state.set_battery_voltage(AltosConvert.tele_gps_voltage(v_batt));
+ state.set_device_type(device_type());
+ state.set_flight(flight());
+ state.set_config(config_major(), config_minor(), flight_log_max());
+ if (device_type() == AltosLib.product_telegps)
+ state.set_battery_voltage(AltosConvert.tele_gps_voltage(v_batt()));
else
- state.set_flight_params(apogee_delay, main_deploy);
+ state.set_flight_params(apogee_delay(), main_deploy());
- state.set_callsign(callsign);
- state.set_firmware_version(version);
+ state.set_callsign(callsign());
+ state.set_firmware_version(version());
}
}
int index;
public void add (AltosTelemetry telem) {
- int t = telem.tick;
+ int t = telem.tick();
if (!telems.isEmpty()) {
while (t < tick - 1000)
t += 65536;
final static String AO_TELEM_SAT_SVID = "s_v";
final static String AO_TELEM_SAT_C_N_0 = "s_c";
+ public int tick;
+ public int serial;
+ public int rssi;
+ public int status;
+
+ public int tick() { return tick; }
+ public int serial() { return serial; }
+
+ public int rssi() { return rssi; }
+ public int status() { return status; }
+
public int version;
public String callsign;
public int flight;
flight = map.get_int(AO_TELEM_FLIGHT, AltosLib.MISSING);
rssi = map.get_int(AO_TELEM_RSSI, AltosLib.MISSING);
state = AltosLib.state(map.get_string(AO_TELEM_STATE, "invalid"));
- tick = map.get_int(AO_TELEM_TICK, 0);
/* raw sensor values */
accel = map.get_int(AO_TELEM_RAW_ACCEL, AltosLib.MISSING);
* Given a hex dump of a legacy telemetry line, construct an AltosRecordTM from that
*/
- int[] bytes;
int adjust;
/*
static final int AO_GPS_DATE_VALID = (1 << 6);
static final int AO_GPS_COURSE_VALID = (1 << 7);
- public AltosTelemetryLegacy(int[] in_bytes) {
- bytes = in_bytes;
+ public AltosTelemetryLegacy(int[] in_bytes) throws AltosCRCException {
+ super(in_bytes);
+
version = 4;
adjust = 0;
} else
serial = uint16(0);
+ rssi = super.rssi();
callsign = string(62, 8);
flight = uint16(2);
state = uint8(4);
public class AltosTelemetryLocation extends AltosTelemetryStandard {
- int flags;
- int altitude;
- int latitude;
- int longitude;
- int year;
- int month;
- int day;
- int hour;
- int minute;
- int second;
- int pdop;
- int hdop;
- int vdop;
- int mode;
- int ground_speed;
- int climb_rate;
- int course;
+ int flags() { return uint8(5); }
+ int altitude() {
+ if ((mode() & AO_GPS_MODE_ALTITUDE_24) != 0)
+ return (int8(31) << 16) | uint16(6);
+ else
+ return int16(6);
+ }
+ int latitude() { return uint32(8); }
+ int longitude() { return uint32(12); }
+ int year() { return uint8(16); }
+ int month() { return uint8(17); }
+ int day() { return uint8(18); }
+ int hour() { return uint8(19); }
+ int minute() { return uint8(20); }
+ int second() { return uint8(21); }
+ int pdop() { return uint8(22); }
+ int hdop() { return uint8(23); }
+ int vdop() { return uint8(24); }
+ int mode() { return uint8(25); }
+ int ground_speed() { return uint16(26); }
+ int climb_rate() { return int16(28); }
+ int course() { return uint8(30); }
public static final int AO_GPS_MODE_ALTITUDE_24 = (1 << 0); /* Reports 24-bits of altitude */
- public AltosTelemetryLocation(int[] bytes) {
+ public AltosTelemetryLocation(int[] bytes) throws AltosCRCException {
super(bytes);
-
- flags = uint8(5);
- latitude = uint32(8);
- longitude = uint32(12);
- year = uint8(16);
- month = uint8(17);
- day = uint8(18);
- hour = uint8(19);
- minute = uint8(20);
- second = uint8(21);
- pdop = uint8(22);
- hdop = uint8(23);
- vdop = uint8(24);
- mode = uint8(25);
- ground_speed = uint16(26);
- climb_rate = int16(28);
- course = uint8(30);
-
- if ((mode & AO_GPS_MODE_ALTITUDE_24) != 0) {
- altitude = (int8(31) << 16) | uint16(6);
- } else
- altitude = int16(6);
}
public void update_state(AltosState state) {
super.update_state(state);
AltosGPS gps = state.make_temp_gps(false);
+ int flags = flags();
gps.nsat = flags & 0xf;
gps.locked = (flags & (1 << 4)) != 0;
gps.connected = (flags & (1 << 5)) != 0;
if (gps.locked) {
- gps.lat = latitude * 1.0e-7;
- gps.lon = longitude * 1.0e-7;
- gps.alt = altitude;
- gps.year = 2000 + year;
- gps.month = month;
- gps.day = day;
- gps.hour = hour;
- gps.minute = minute;
- gps.second = second;
- gps.ground_speed = ground_speed * 1.0e-2;
- gps.course = course * 2;
- gps.climb_rate = climb_rate * 1.0e-2;
- gps.pdop = pdop / 10.0;
- gps.hdop = hdop / 10.0;
- gps.vdop = vdop / 10.0;
+ gps.lat = latitude() * 1.0e-7;
+ gps.lon = longitude() * 1.0e-7;
+ gps.alt = altitude();
+ gps.year = 2000 + year();
+ gps.month = month();
+ gps.day = day();
+ gps.hour = hour();
+ gps.minute = minute();
+ gps.second = second();
+ gps.ground_speed = ground_speed() * 1.0e-2;
+ gps.course = course() * 2;
+ gps.climb_rate = climb_rate() * 1.0e-2;
+ gps.pdop = pdop() / 10.0;
+ gps.hdop = hdop() / 10.0;
+ gps.vdop = vdop() / 10.0;
}
state.set_temp_gps();
}
package org.altusmetrum.altoslib_11;
public class AltosTelemetryMegaData extends AltosTelemetryStandard {
- int state;
- int v_batt;
- int v_pyro;
- int sense[];
+ int state() { return uint8(5); }
- int ground_pres;
- int ground_accel;
- int accel_plus_g;
- int accel_minus_g;
+ int v_batt() { return int16(6); }
+ int v_pyro() { return int16(8); }
+ int sense(int i) { int v = uint8(10+i); return v << 4 | v >> 8; }
- int acceleration;
- int speed;
- int height_16;
+ int ground_pres() { return int32(16); }
+ int ground_accel() { return int16(20); }
+ int accel_plus_g() { return int16(22); }
+ int accel_minus_g() { return int16(24);}
- public AltosTelemetryMegaData(int[] bytes) {
- super(bytes);
-
- state = uint8(5);
-
- v_batt = int16(6);
- v_pyro = int16(8);
-
- sense = new int[6];
+ int acceleration() { return int16(26); }
+ int speed() { return int16(28); }
+ int height_16() { return int16(30); }
- for (int i = 0; i < 6; i++) {
- sense[i] = uint8(10 + i) << 4;
- sense[i] |= sense[i] >> 8;
- }
-
- ground_pres = int32(16);
- ground_accel = int16(20);
- accel_plus_g = int16(22);
- accel_minus_g = int16(24);
-
- acceleration = int16(26);
- speed = int16(28);
-
- height_16 = int16(30);
+ public AltosTelemetryMegaData(int[] bytes) throws AltosCRCException {
+ super(bytes);
}
public void update_state(AltosState state) {
super.update_state(state);
- state.set_state(this.state);
+ state.set_state(state());
- state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt));
- state.set_pyro_voltage(AltosConvert.mega_pyro_voltage(v_pyro));
+ state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt()));
+ state.set_pyro_voltage(AltosConvert.mega_pyro_voltage(v_pyro()));
- state.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sense[4]));
- state.set_main_voltage(AltosConvert.mega_pyro_voltage(sense[5]));
+ state.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sense(4)));
+ state.set_main_voltage(AltosConvert.mega_pyro_voltage(sense(5)));
double voltages[] = new double[4];
for (int i = 0; i < 4; i++)
- voltages[i] = AltosConvert.mega_pyro_voltage(sense[i]);
+ voltages[i] = AltosConvert.mega_pyro_voltage(sense(i));
state.set_ignitor_voltage(voltages);
- state.set_ground_accel(ground_accel);
- state.set_ground_pressure(ground_pres);
- state.set_accel_g(accel_plus_g, accel_minus_g);
+ state.set_ground_accel(ground_accel());
+ state.set_ground_pressure(ground_pres());
+ state.set_accel_g(accel_plus_g(), accel_minus_g());
/* Fill in the high bits of height from recent GPS
* data if available, otherwise guess using the
* previous kalman height
*/
- state.set_kalman(extend_height(state, height_16),
- speed/16.0, acceleration / 16.0);
+ state.set_kalman(extend_height(state, height_16()),
+ speed()/16.0, acceleration() / 16.0);
}
}
package org.altusmetrum.altoslib_11;
public class AltosTelemetryMegaSensor extends AltosTelemetryStandard {
- int accel;
- int pres;
- int temp;
+ int orient() { return int8(5); }
- int accel_x;
- int accel_y;
- int accel_z;
+ int accel() { return int16(6); }
+ int pres() { return int32(8); }
+ int temp() { return int16(12); }
- int gyro_x;
- int gyro_y;
- int gyro_z;
+ int accel_x() { return int16(14); }
+ int accel_y() { return int16(16); }
+ int accel_z() { return int16(18); }
- int mag_x;
- int mag_y;
- int mag_z;
+ int gyro_x() { return int16(20); }
+ int gyro_y() { return int16(22); }
+ int gyro_z() { return int16(24); }
- int orient;
+ int mag_x() { return int16(26); }
+ int mag_y() { return int16(28); }
+ int mag_z() { return int16(30); }
- public AltosTelemetryMegaSensor(int[] bytes) {
+ public AltosTelemetryMegaSensor(int[] bytes) throws AltosCRCException {
super(bytes);
-
- orient = int8(5);
- accel = int16(6);
- pres = int32(8);
- temp = int16(12);
-
- accel_x = int16(14);
- accel_y = int16(16);
- accel_z = int16(18);
-
- gyro_x = int16(20);
- gyro_y = int16(22);
- gyro_z = int16(24);
-
- mag_x = int16(26);
- mag_y = int16(28);
- mag_z = int16(30);
}
public void update_state(AltosState state) {
super.update_state(state);
- state.set_accel(accel);
- state.set_pressure(pres);
- state.set_temperature(temp / 100.0);
+ state.set_accel(accel());
+ state.set_pressure(pres());
+ state.set_temperature(temp() / 100.0);
- state.set_orient(orient);
+ state.set_orient(orient());
- state.set_imu(new AltosIMU(accel_y, /* along */
- accel_x, /* across */
- accel_z, /* through */
- gyro_y, /* along */
- gyro_x, /* across */
- gyro_z)); /* through */
+ state.set_imu(new AltosIMU(accel_y(), /* along */
+ accel_x(), /* across */
+ accel_z(), /* through */
+ gyro_y(), /* along */
+ gyro_x(), /* across */
+ gyro_z())); /* through */
- state.set_mag(new AltosMag(mag_x, mag_y, mag_z));
+ state.set_mag(new AltosMag(mag_x(), mag_y(), mag_z()));
}
}
public class AltosTelemetryMetrumData extends AltosTelemetryStandard {
- int ground_pres;
- int ground_accel;
- int accel_plus_g;
- int accel_minus_g;
+ int ground_pres() { return int32(8); }
+ int ground_accel() { return int16(12); }
+ int accel_plus_g() { return int16(14); }
+ int accel_minus_g() { return int16(16); }
- public AltosTelemetryMetrumData(int[] bytes) {
+ public AltosTelemetryMetrumData(int[] bytes) throws AltosCRCException {
super(bytes);
-
- ground_pres = int32(8);
- ground_accel = int16(12);
- accel_plus_g = int16(14);
- accel_minus_g = int16(16);
}
public void update_state(AltosState state) {
- state.set_ground_accel(ground_accel);
- state.set_accel_g(accel_plus_g, accel_minus_g);
- state.set_ground_pressure(ground_pres);
+ state.set_ground_accel(ground_accel());
+ state.set_accel_g(accel_plus_g(), accel_minus_g());
+ state.set_ground_pressure(ground_pres());
}
}
public class AltosTelemetryMetrumSensor extends AltosTelemetryStandard {
- int state;
+ int state() { return uint8(5); }
- int accel;
- int pres;
- int temp;
+ int accel() { return int16(6); }
+ int pres() { return int32(8); }
+ int temp() { return int16(12); }
- int acceleration;
- int speed;
- int height_16;
+ int acceleration() { return int16(14); }
+ int speed() { return int16(16); }
+ int height_16() { return int16(18); }
- int v_batt;
- int sense_a;
- int sense_m;
+ int v_batt() { return int16(20); }
+ int sense_a() { return int16(22); }
+ int sense_m() { return int16(24); }
- public AltosTelemetryMetrumSensor(int[] bytes) {
+ public AltosTelemetryMetrumSensor(int[] bytes) throws AltosCRCException {
super(bytes);
-
- state = int8(5);
- accel = int16(6);
- pres = int32(8);
- temp = int16(12);
-
- acceleration = int16(14);
- speed = int16(16);
- height_16 = int16(18);
-
- v_batt = int16(20);
- sense_a = int16(22);
- sense_m = int16(24);
}
public void update_state(AltosState state) {
super.update_state(state);
- state.set_state(this.state);
+ state.set_state(state());
- state.set_accel(accel);
- state.set_pressure(pres);
- state.set_temperature(temp/100.0);
+ state.set_accel(accel());
+ state.set_pressure(pres());
+ state.set_temperature(temp()/100.0);
- state.set_kalman(extend_height(state, height_16),
- speed/16.0, acceleration/16.0);
+ state.set_kalman(extend_height(state, height_16()),
+ speed()/16.0, acceleration()/16.0);
- state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt));
+ state.set_battery_voltage(AltosConvert.mega_battery_voltage(v_batt()));
- state.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sense_a));
- state.set_main_voltage(AltosConvert.mega_pyro_voltage(sense_m));
+ state.set_apogee_voltage(AltosConvert.mega_pyro_voltage(sense_a()));
+ state.set_main_voltage(AltosConvert.mega_pyro_voltage(sense_m()));
}
}
public class AltosTelemetryMini2 extends AltosTelemetryStandard {
- int state;
- int v_batt;
- int sense_a;
- int sense_m;
+ int state() { return uint8(5); }
- int pres;
- int temp;
+ int v_batt() { return int16(6); }
+ int sense_a() { return int16(8); }
+ int sense_m() { return int16(10); }
- int acceleration;
- int speed;
- int height;
+ int pres() { return int32(12); }
+ int temp() { return int16(16); }
- int ground_pres;
+ int acceleration() { return int16(18); }
+ int speed() { return int16(20); }
+ int height() { return int16(22); }
- public AltosTelemetryMini2(int[] bytes) {
- super(bytes);
-
- state = int8(5);
-
- v_batt = int16(6);
- sense_a = int16(8);
- sense_m = int16(10);
+ int ground_pres() { return int32(24); }
- pres = int32(12);
- temp = int16(16);
-
- acceleration = int16(18);
- speed = int16(20);
- height = int16(22);
-
- ground_pres = int32(24);
+ public AltosTelemetryMini2(int[] bytes) throws AltosCRCException {
+ super(bytes);
}
public void update_state(AltosState state) {
super.update_state(state);
- state.set_state(this.state);
+ state.set_state(state());
- state.set_battery_voltage(AltosConvert.tele_mini_2_voltage(v_batt));
- state.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sense_a));
- state.set_main_voltage(AltosConvert.tele_mini_2_voltage(sense_m));
+ state.set_battery_voltage(AltosConvert.tele_mini_2_voltage(v_batt()));
+ state.set_apogee_voltage(AltosConvert.tele_mini_2_voltage(sense_a()));
+ state.set_main_voltage(AltosConvert.tele_mini_2_voltage(sense_m()));
- state.set_ground_pressure(ground_pres);
+ state.set_ground_pressure(ground_pres());
- state.set_pressure(pres);
- state.set_temperature(temp/100.0);
+ state.set_pressure(pres());
+ state.set_temperature(temp()/100.0);
- state.set_kalman(height, speed/16.0, acceleration/16.0);
+ state.set_kalman(height(), speed()/16.0, acceleration()/16.0);
}
}
public class AltosTelemetryMini3 extends AltosTelemetryStandard {
- int state;
+ int state() { return uint8(5); }
- int v_batt;
- int sense_a;
- int sense_m;
+ int v_batt() { return int16(6); }
+ int sense_a() { return int16(8); }
+ int sense_m() { return int16(10); }
- int pres;
- int temp;
+ int pres() { return int32(12); }
+ int temp() { return int16(16); }
- int acceleration;
- int speed;
- int height_16;
+ int acceleration() { return int16(18); }
+ int speed() { return int16(20); }
+ int height_16() { return int16(22); }
- int ground_pres;
+ int ground_pres() { return int32(24); }
- public AltosTelemetryMini3(int[] bytes) {
+ public AltosTelemetryMini3(int[] bytes) throws AltosCRCException {
super(bytes);
-
- state = int8(5);
-
- v_batt = int16(6);
- sense_a = int16(8);
- sense_m = int16(10);
-
- pres = int32(12);
- temp = int16(16);
-
- acceleration = int16(18);
- speed = int16(20);
- height_16 = int16(22);
-
- ground_pres = int32(24);
}
public void update_state(AltosState state) {
super.update_state(state);
- state.set_state(this.state);
+ state.set_state(state());
- state.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(v_batt));
+ state.set_battery_voltage(AltosConvert.tele_mini_3_battery_voltage(v_batt()));
- state.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_a));
- state.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_m));
+ state.set_apogee_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_a()));
+ state.set_main_voltage(AltosConvert.tele_mini_3_pyro_voltage(sense_m()));
- state.set_pressure(pres);
- state.set_temperature(temp/100.0);
+ state.set_pressure(pres());
+ state.set_temperature(temp()/100.0);
- state.set_kalman(extend_height(state, height_16),
- speed/16.0, acceleration/16.0);
+ state.set_kalman(extend_height(state, height_16()),
+ speed()/16.0, acceleration()/16.0);
- state.set_ground_pressure(ground_pres);
+ state.set_ground_pressure(ground_pres());
}
}
package org.altusmetrum.altoslib_11;
public class AltosTelemetryRaw extends AltosTelemetryStandard {
- public AltosTelemetryRaw(int[] bytes) {
+ public AltosTelemetryRaw(int[] bytes) throws AltosCRCException {
super(bytes);
}
package org.altusmetrum.altoslib_11;
public class AltosTelemetrySatellite extends AltosTelemetryStandard {
- int channels;
- AltosGPSSat[] sats;
+ int channels() { return uint8(5); }
- public AltosTelemetrySatellite(int[] bytes) {
- super(bytes);
+ AltosGPSSat[] sats() {
+ int channels = channels();
+ AltosGPSSat[] sats = null;
- channels = uint8(5);
if (channels > 12)
channels = 12;
if (channels == 0)
sats[i] = new AltosGPSSat(svid, c_n_1);
}
}
+ return sats;
+ }
+
+ public AltosTelemetrySatellite(int[] bytes) throws AltosCRCException {
+ super(bytes);
}
public void update_state(AltosState state) {
AltosGPS gps = state.make_temp_gps(true);
- gps.cc_gps_sat = sats;
+ gps.cc_gps_sat = sats();
state.set_temp_gps();
}
}
public class AltosTelemetrySensor extends AltosTelemetryStandard {
- int state;
- int accel;
- int pres;
- int temp;
- int v_batt;
- int sense_d;
- int sense_m;
+ int state() { return uint8(5); }
+ int accel() { return int16(6); }
+ int pres() { return int16(8); }
+ int temp() { return int16(10); }
+ int v_batt() { return int16(12); }
+ int sense_d() { return int16(14); }
+ int sense_m() { return int16(16); }
- int acceleration;
- int speed;
- int height;
+ int acceleration() { return int16(18); }
+ int speed() { return int16(20); }
+ int height_16() { return int16(22); }
- int ground_accel;
- int ground_pres;
- int accel_plus_g;
- int accel_minus_g;
+ int ground_accel() { return int16(24); }
+ int ground_pres() { return int16(26); }
+ int accel_plus_g() { return int16(28); }
+ int accel_minus_g() { return int16(30); }
- public AltosTelemetrySensor(int[] bytes) {
+ public AltosTelemetrySensor(int[] bytes) throws AltosCRCException {
super(bytes);
- state = uint8(5);
-
- accel = int16(6);
- pres = int16(8);
- temp = int16(10);
- v_batt = int16(12);
- sense_d = int16(14);
- sense_m = int16(16);
-
- acceleration = int16(18);
- speed = int16(20);
- height = int16(22);
-
- ground_pres = int16(24);
- ground_accel = int16(26);
- accel_plus_g = int16(28);
- accel_minus_g = int16(30);
}
public void update_state(AltosState state) {
super.update_state(state);
- state.set_state(this.state);
- if (type == packet_type_TM_sensor) {
- state.set_ground_accel(ground_accel);
- state.set_accel_g(accel_plus_g, accel_minus_g);
- state.set_accel(accel);
+ state.set_state(state());
+ if (type() == packet_type_TM_sensor) {
+ state.set_ground_accel(ground_accel());
+ state.set_accel_g(accel_plus_g(), accel_minus_g());
+ state.set_accel(accel());
}
- state.set_ground_pressure(AltosConvert.barometer_to_pressure(ground_pres));
- state.set_pressure(AltosConvert.barometer_to_pressure(pres));
- state.set_temperature(AltosConvert.thermometer_to_temperature(temp));
- state.set_battery_voltage(AltosConvert.cc_battery_to_voltage(v_batt));
- if (type == packet_type_TM_sensor || type == packet_type_Tm_sensor) {
- state.set_apogee_voltage(AltosConvert.cc_ignitor_to_voltage(sense_d));
- state.set_main_voltage(AltosConvert.cc_ignitor_to_voltage(sense_m));
+ state.set_ground_pressure(AltosConvert.barometer_to_pressure(ground_pres()));
+ state.set_pressure(AltosConvert.barometer_to_pressure(pres()));
+ state.set_temperature(AltosConvert.thermometer_to_temperature(temp()));
+ state.set_battery_voltage(AltosConvert.cc_battery_to_voltage(v_batt()));
+ if (type() == packet_type_TM_sensor || type() == packet_type_Tm_sensor) {
+ state.set_apogee_voltage(AltosConvert.cc_ignitor_to_voltage(sense_d()));
+ state.set_main_voltage(AltosConvert.cc_ignitor_to_voltage(sense_m()));
}
- state.set_kalman(height, speed/16.0, acceleration / 16.0);
+ state.set_kalman(height_16(), speed()/16.0, acceleration()/16.0);
}
}
package org.altusmetrum.altoslib_11;
public abstract class AltosTelemetryStandard extends AltosTelemetry {
- int[] bytes;
- int type;
-
public int int8(int off) {
return AltosLib.int8(bytes, off + 1);
}
return AltosLib.string(bytes, off + 1, l);
}
- public static AltosTelemetry parse_hex(int[] bytes) {
- int type = AltosLib.uint8(bytes, 4 + 1);
+ public int type() { return uint8(4); }
+
+ public int serial() { return uint16(0); }
+
+ public int tick() { return uint16(2); }
+ public static AltosTelemetry parse_hex(int[] bytes) throws AltosCRCException {
AltosTelemetry telem;
+
+ int type = AltosLib.uint8(bytes, 4+1);
switch (type) {
case packet_type_TM_sensor:
case packet_type_Tm_sensor:
return telem;
}
- public AltosTelemetryStandard(int[] bytes) {
- this.bytes = bytes;
-
- serial = uint16(0);
- tick = uint16(2);
- type = uint8(4);
+ public AltosTelemetryStandard(int[] bytes) throws AltosCRCException {
+ super(bytes);
}
public void update_state(AltosState state) {