Make voice and channel menus work.
[fw/altos] / ao-tools / altosui / AltosSerial.java
index e84f5b63e4e21c7ca5cdd0cbb0cb90c863383ced..f12b31b3187e9b253b4a3560080db9d8e2966d7e 100644 (file)
@@ -119,7 +119,8 @@ public class AltosSerial implements Runnable {
        }
 
        public void putc(char c) {
-               libaltos.altos_putchar(altos, c);
+               if (altos != null)
+                       libaltos.altos_putchar(altos, c);
        }
 
        public void print(String data) {
@@ -134,8 +135,21 @@ public class AltosSerial implements Runnable {
        public void open(altos_device device) throws FileNotFoundException {
                close();
                altos = libaltos.altos_open(device);
+               if (altos == null)
+                       throw new FileNotFoundException(device.getPath());
                input_thread = new Thread(this);
                input_thread.start();
+               print("\nE 0\nm 1\n");
+               try {
+                       Thread.sleep(200);
+               } catch (InterruptedException e) {
+               }
+               flush();
+       }
+
+       public void set_channel(int channel) {
+               if (altos != null)
+                       printf("m 0\nc r %d\nm 1\n", channel);
        }
 
        public AltosSerial() {