Add appropriate Java build deps as given from autoconf
[fw/altos] / altosui / AltosSerial.java
index c4e9c69720339e0d0a4b474f87319986fc4dd33b..61865bbdf46a00f45d53f74534099ec96eaabfe4 100644 (file)
@@ -19,7 +19,7 @@
  * Deal with TeleDongle on a serial port
  */
 
-package altosui;
+package AltosUI;
 
 import java.lang.*;
 import java.io.*;
@@ -41,7 +41,7 @@ import libaltosJNI.*;
  * threads.
  */
 
-public class AltosSerial extends AltosLink implements Runnable {
+public class AltosSerial extends AltosLink  {
 
        static java.util.List<String> devices_opened = Collections.synchronizedList(new LinkedList<String>());
 
@@ -54,13 +54,19 @@ public class AltosSerial extends AltosLink implements Runnable {
        Frame frame;
 
        public int getchar() {
+               if (altos == null)
+                       return ERROR;
                return libaltos.altos_getchar(altos, 0);
        }
 
        public void flush_output() {
                super.flush_output();
                if (altos != null) {
-                       libaltos.altos_flush(altos);
+                       if (libaltos.altos_flush(altos) != 0) {
+                               libaltos.altos_close(altos);
+                               altos = null;
+                               abort_reply();
+                       }
                }
        }
 
@@ -155,7 +161,11 @@ public class AltosSerial extends AltosLink implements Runnable {
 
        private void putc(char c) {
                if (altos != null)
-                       libaltos.altos_putchar(altos, c);
+                       if (libaltos.altos_putchar(altos, c) != 0) {
+                               libaltos.altos_close(altos);
+                               altos = null;
+                               abort_reply();
+                       }
        }
 
        public void print(String data) {