X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=ao-tools%2Faltosui%2FAltosSerial.java;h=a5566ab898d4f3eb096f2d131e925e585bf8a499;hb=ce90f3fe2aa6e23695ccccb36a8e6e614a08ba31;hp=e84f5b63e4e21c7ca5cdd0cbb0cb90c863383ced;hpb=172a2817dde6718724f2b5fad5a7761801446fa0;p=fw%2Faltos diff --git a/ao-tools/altosui/AltosSerial.java b/ao-tools/altosui/AltosSerial.java index e84f5b63..a5566ab8 100644 --- a/ao-tools/altosui/AltosSerial.java +++ b/ao-tools/altosui/AltosSerial.java @@ -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\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() {