- }
-
- public void open(File name) throws FileNotFoundException {
- close();
- serial_in = new FileInputStream(name);
- input_thread = new Thread(this);
- input_thread.start();
- }
- public void open(CommPort c) throws IOException {
- close();
- serial_in = c.getInputStream();
- input_thread = new Thread(this);
- input_thread.start();
- }
- public AltosSerialReader () {
- serial_in = null;
- input_thread = null;
- line = "";
- monitor_queue = new LinkedBlockingQueue<String> ();
- reply_queue = new LinkedBlockingQueue<String> ();
- }
-
-}
-
-public class AltosSerial implements Runnable {
- OutputStream serial_out = null;
- Thread monitor_thread = null;
- AltosSerialReader reader = null;
- LinkedList<AltosSerialMonitor> callbacks;
-
- public void run() {
- try {
- for (;;) {
- String s = reader.get_telem();
- synchronized(callbacks) {
- Iterator<AltosSerialMonitor> i = callbacks.iterator();
- while (i.hasNext()) {
- i.next().data(s);
- }
- }
- }
- } catch (InterruptedException e) {