- }
-
- public void open(File name) throws FileNotFoundException {
- close();
- serial_in = new FileInputStream(name);
- 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 {
- FileOutputStream 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) {
+ if (altos != null) {
+ libaltos.altos_free(altos);
+ altos = null;
+ }
+ synchronized (devices_opened) {
+ devices_opened.remove(device.getPath());