+ class DisplayThread extends Thread {
+ String read() throws InterruptedException { return null; }
+
+ void close() { }
+
+ void update(AltosState state) throws InterruptedException { }
+
+ public void run() {
+ String line;
+ AltosState state = null;
+
+ info_reset();
+ info_finish();
+ try {
+ while ((line = read()) != null) {
+ try {
+ AltosTelemetry t = new AltosTelemetry(line);
+ state = new AltosState(t, state);
+ update(state);
+ show(state);
+ } catch (ParseException pp) {
+ System.out.printf("Parse error on %s\n", line);
+ System.out.println("exception " + pp);
+ }
+ }
+ } catch (InterruptedException ee) {
+ } finally {
+ close();
+ }
+ }
+ }
+
+ class DeviceThread extends DisplayThread {
+ AltosSerial serial;
+
+ String read() throws InterruptedException {
+ System.out.println("Waiting for telemetry");
+ String s = serial.get_telem();
+ System.out.println("Got telemetry " + s);
+ return s;
+ }
+
+ void close() {
+ serial.close();
+ System.out.println("DisplayThread done");
+ }
+
+ public DeviceThread(AltosSerial s) {
+ serial = s;
+ }
+ }
+