--- /dev/null
+/*
+ * Copyright © 2010 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 AltosCRCException extends Exception {
+ public int rssi;
+
+ public AltosCRCException (int in_rssi) {
+ rssi = in_rssi;
+ }
+}
import altosui.AltosConvert;
import altosui.AltosRecord;
import altosui.AltosGPS;
+import altosui.AltosCRCException;
/*
* Telemetry data contents
*/
public class AltosTelemetry extends AltosRecord {
- public AltosTelemetry(String line) throws ParseException {
+ public AltosTelemetry(String line) throws ParseException, AltosCRCException {
String[] words = line.split("\\s+");
int i = 0;
+ if (words[i].equals("CRC") && words[i+1].equals("INVALID")) {
+ i += 2;
+ AltosParse.word(words[i++], "RSSI");
+ rssi = AltosParse.parse_int(words[i++]);
+ throw new AltosCRCException(rssi);
+ }
if (words[i].equals("CALL")) {
version = 0;
} else {
flightInfoModel[i].finish();
}
- public void show(AltosState state) {
+ public void show(AltosState state, int crc_errors) {
flightStatusModel.set(state);
info_reset();
- if (state.gps_ready)
- info_add_row(0, "Ground state", "%s", "ready");
- else
- info_add_row(0, "Ground state", "wait (%d)",
- state.gps_waiting);
info_add_row(0, "Rocket state", "%s", state.data.state());
info_add_row(0, "Callsign", "%s", state.data.callsign);
info_add_row(0, "Rocket serial", "%6d", state.data.serial);
info_add_row(0, "Rocket flight", "%6d", state.data.flight);
info_add_row(0, "RSSI", "%6d dBm", state.data.rssi);
+ info_add_row(0, "CRC Errors", "%6d", crc_errors);
info_add_row(0, "Height", "%6.0f m", state.height);
info_add_row(0, "Max height", "%6.0f m", state.max_height);
info_add_row(0, "Acceleration", "%8.1f m/s²", state.acceleration);
if (state.gps == null) {
info_add_row(1, "GPS", "not available");
} else {
+ if (state.gps_ready)
+ info_add_row(1, "GPS state", "%s", "ready");
+ else
+ info_add_row(1, "GPS state", "wait (%d)",
+ state.gps_waiting);
if (state.data.gps.locked)
info_add_row(1, "GPS", " locked");
else if (state.data.gps.connected)
String name;
- AltosRecord read() throws InterruptedException, ParseException { return null; }
+ int crc_errors;
+
+ void init() { }
+
+ AltosRecord read() throws InterruptedException, ParseException, AltosCRCException { return null; }
void close() { }
old_state = state;
state = new AltosState(record, state);
update(state);
- show(state);
+ show(state, crc_errors);
tell(state, old_state);
idle_thread.notice(state);
} catch (ParseException pp) {
System.out.printf("Parse error: %d \"%s\"\n", pp.getErrorOffset(), pp.getMessage());
+ } catch (AltosCRCException ce) {
+ ++crc_errors;
+ show(state, crc_errors);
}
}
} catch (InterruptedException ee) {
AltosSerial serial;
LinkedBlockingQueue<String> telem;
- AltosRecord read() throws InterruptedException, ParseException {
+ AltosRecord read() throws InterruptedException, ParseException, AltosCRCException {
return new AltosTelemetry(telem.take());
}