package org.altusmetrum.AltosLib;
-import java.lang.*;
import java.io.*;
import java.util.concurrent.*;
import java.util.*;
-import java.text.*;
-public abstract class AltosLink {
+public abstract class AltosLink implements Runnable {
public final static int ERROR = -1;
public final static int TIMEOUT = -2;
try {
for (;;) {
c = getchar();
- if (Thread.interrupted())
+ if (Thread.interrupted()) {
+ if (debug)
+ System.out.printf("INTERRUPTED\n");
break;
+ }
if (c == ERROR) {
+ if (debug)
+ System.out.printf("ERROR\n");
add_telem (new AltosLine());
add_reply (new AltosLine());
break;
}
- if (c == TIMEOUT)
+ if (c == TIMEOUT) {
+ if (debug)
+ System.out.printf("TIMEOUT\n");
continue;
+ }
if (c == '\r')
continue;
synchronized(this) {
reply_queue.put (line);
}
+ public void abort_reply() {
+ try {
+ add_telem (new AltosLine());
+ add_reply (new AltosLine());
+ } catch (InterruptedException e) {
+ }
+ }
+
public void add_string(String line) throws InterruptedException {
if (line.startsWith("TELEM") || line.startsWith("VERSION") || line.startsWith("CRC")) {
add_telem(new AltosLine(line));