static final Charset unicode_set = Charset.forName("UTF-8");
static String string(int[] bytes, int s, int l) {
- byte[] b = new byte[bytes.length];
+ if (s + l > bytes.length) {
+ if (s > bytes.length) {
+ s = bytes.length;
+ l = 0;
+ } else {
+ l = bytes.length - s;
+ }
+ }
+
+ byte[] b = new byte[l];
+
for (int i = 0; i < l; i++)
b[i] = (byte) bytes[s+i];
- return new String(b, unicode_set);
+ String n = new String(b, unicode_set);
+ return n;
}
static int hexbyte(String s, int i) {
continue;
try {
AltosRecord telem = AltosTelemetry.parse(line.line, previous);
- if (telem.serial != serial || telem.flight != flight || log_file == null) {
+ if (telem.serial != 0 && telem.flight != 0 &&
+ (telem.serial != serial || telem.flight != flight || log_file == null))
+ {
close_log_file();
serial = telem.serial;
flight = telem.flight;
double time; /* seconds since boost */
+ int device_type;
+ int config_major;
+ int config_minor;
+ int apogee_delay;
+ int main_deploy;
+ int flight_log_max;
+ String firmware_version;
/*
* Values for our MP3H6115A pressure sensor
*
--- /dev/null
+/*
+ * Copyright © 2011 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 AltosTelemetryRecordConfiguration extends AltosTelemetryRecordRaw {
+ int device_type;
+ int flight;
+ int config_major;
+ int config_minor;
+ int apogee_delay;
+ int main_deploy;
+ int flight_log_max;
+ String callsign;
+ String version;
+
+ public AltosTelemetryRecordConfiguration(int[] in_bytes) {
+ super(in_bytes);
+
+ device_type = uint8(5);
+ flight = uint16(6);
+ config_major = uint8(8);
+ config_minor = uint8(9);
+ apogee_delay = uint16(10);
+ main_deploy = uint16(12);
+ flight_log_max = uint16(14);
+ callsign = string(16, 8);
+ version = string(24, 8);
+ }
+
+ public AltosRecord update_state(AltosRecord previous) {
+ AltosRecord next = super.update_state(previous);
+
+ next.device_type = device_type;
+ next.flight = flight;
+ next.config_major = config_major;
+ next.config_minor = config_minor;
+ next.apogee_delay = apogee_delay;
+ next.main_deploy = main_deploy;
+ next.flight_log_max = flight_log_max;
+
+ next.callsign = callsign;
+ next.firmware_version = version;
+
+ next.seen |= AltosRecord.seen_deploy;
+
+ return next;
+ }
+}
throw new AltosCRCException(AltosParse.parse_int(word[i++]));
}
- System.out.printf("First word \"%s\"\n", word[i]);
if (word[i].equals("TELEM"))
r = AltosTelemetryRecordRaw.parse(word[i+1]);
else
--- /dev/null
+/*
+ * Copyright © 2011 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 AltosTelemetryRecordLocation extends AltosTelemetryRecordRaw {
+ 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;
+
+ public AltosTelemetryRecordLocation(int[] in_bytes) {
+ super(in_bytes);
+
+ flags = uint8(5);
+ altitude = int16(6);
+ 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);
+ }
+
+ public AltosRecord update_state(AltosRecord previous) {
+ AltosRecord next = super.update_state(previous);
+
+ if (next.gps == null)
+ next.gps = new AltosGPS();
+
+ next.gps.nsat = flags & 0xf;
+ next.gps.locked = (flags & (1 << 4)) != 0;
+ next.gps.connected = (flags & (1 << 5)) != 0;
+
+ if (next.gps.locked) {
+ next.gps.lat = latitude * 1.0e-7;
+ next.gps.lon = longitude * 1.0e-7;
+ next.gps.alt = altitude;
+ next.gps.year = 2000 + year;
+ next.gps.month = month;
+ next.gps.day = day;
+ next.gps.hour = hour;
+ next.gps.minute = minute;
+ next.gps.second = second;
+ next.gps.ground_speed = ground_speed * 1.0e-2;
+ next.gps.course = course * 2;
+ next.gps.climb_rate = climb_rate * 1.0e-2;
+ next.gps.hdop = hdop;
+ next.gps.vdop = vdop;
+ next.seen |= AltosRecord.seen_gps_time | AltosRecord.seen_gps_lat | AltosRecord.seen_gps_lon;
+ }
+
+ return next;
+ }
+}
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 PKT_APPEND_STATUS_1_CRC_OK = (1 << 7);
final static int PKT_APPEND_STATUS_1_LQI_MASK = (0x7f);
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];
}
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);
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;
default:
r = new AltosTelemetryRecordRaw(bytes);
break;
}
+ break;
case Altos.ao_telemetry_legacy_len + 4:
r = new AltosTelemetryRecordLegacy(bytes, rssi, status);
break;
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);
}
public AltosRecord update_state(AltosRecord previous) {
+ AltosRecord next;
if (previous != null)
- return new AltosRecord(previous);
+ next = new AltosRecord(previous);
else
- return new AltosRecord();
+ next = new AltosRecord();
+ next.serial = serial;
+ next.tick = tick;
+ return next;
}
}
--- /dev/null
+/*
+ * Copyright © 2011 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 AltosTelemetryRecordSatellite extends AltosTelemetryRecordRaw {
+ int channels;
+ AltosGPSSat[] sats;
+
+ public AltosTelemetryRecordSatellite(int[] in_bytes) {
+ super(in_bytes);
+
+ channels = uint8(5);
+ if (channels > 12)
+ channels = 12;
+ if (channels == 0)
+ sats = null;
+ else {
+ sats = new AltosGPSSat[channels];
+ for (int i = 0; i < channels; i++) {
+ int svid = uint8(6 + i * 2 + 0);
+ int c_n_1 = uint8(6 + i * 2 + 1);
+ sats[i] = new AltosGPSSat(svid, c_n_1);
+ }
+ }
+ }
+
+ public AltosRecord update_state(AltosRecord previous) {
+ AltosRecord next = super.update_state(previous);
+
+ if (next.gps == null)
+ next.gps = new AltosGPS();
+
+ next.gps.cc_gps_sat = sats;
+
+ return next;
+ }
+}
int accel_plus_g;
int accel_minus_g;
- public AltosTelemetryRecordSensor(int[] in_bytes) {
+ int rssi;
+
+ public AltosTelemetryRecordSensor(int[] in_bytes, int in_rssi) {
super(in_bytes);
state = uint8(5);
speed = int16(20);
height = int16(22);
- ground_accel = int16(24);
- ground_pres = int16(26);
+ ground_pres = int16(24);
+ ground_accel = int16(26);
accel_plus_g = int16(28);
accel_minus_g = int16(30);
+
+ rssi = in_rssi;
}
public AltosRecord update_state(AltosRecord previous) {
AltosRecord next = super.update_state(previous);
+
+ next.state = state;
+ if (type == packet_type_TM_sensor)
+ next.accel = accel;
+ else
+ next.accel = AltosRecord.MISSING;
+ next.pres = pres;
+ next.temp = temp;
+ next.batt = v_batt;
+ if (type == packet_type_TM_sensor || type == packet_type_Tm_sensor) {
+ next.drogue = sense_d;
+ next.main = sense_m;
+ } else {
+ next.drogue = AltosRecord.MISSING;
+ next.main = AltosRecord.MISSING;
+ }
+
+ next.acceleration = acceleration / 16.0;
+ next.speed = speed / 16.0;
+ next.height = height;
+
+ next.ground_pres = ground_pres;
+ if (type == packet_type_TM_sensor) {
+ next.ground_accel = ground_accel;
+ next.accel_plus_g = accel_plus_g;
+ next.accel_minus_g = accel_minus_g;
+ } else {
+ next.ground_accel = AltosRecord.MISSING;
+ next.accel_plus_g = AltosRecord.MISSING;
+ next.accel_minus_g = AltosRecord.MISSING;
+ }
+
+ next.rssi = rssi;
+
+ next.seen |= AltosRecord.seen_sensor | AltosRecord.seen_temp_volt;
+
+ System.out.printf("Sensor record update - rssi %d\n", rssi);
return next;
}
}
AltosTelemetryRecordGeneral.java \
AltosTelemetryRecordRaw.java \
AltosTelemetryRecordSensor.java \
+ AltosTelemetryRecordConfiguration.java \
+ AltosTelemetryRecordLocation.java \
+ AltosTelemetryRecordSatellite.java \
AltosTelemetryRecordLegacy.java \
AltosTelemetryMap.java \
AltosReplayReader.java \