diff options
author | Mike Beattie <mike@ethernal.org> | 2012-08-08 06:46:56 +1200 |
---|---|---|
committer | Mike Beattie <mike@ethernal.org> | 2012-08-08 06:46:56 +1200 |
commit | bd02349111ae0f39b320e6a10a330051ddc39fdf (patch) | |
tree | ab7a29204eea195db77aa302fbe3e2012ef5049e /altosui/AltosSerial.java | |
parent | 8e4ebd1f6eb928b5cb7bcda4ed88851aa9e61bdf (diff) | |
parent | c7f228503870c44dfd278ede8b0980dbac73d3c7 (diff) |
Merge branch 'master' of git://git.gag.com/fw/altos
Diffstat (limited to 'altosui/AltosSerial.java')
-rw-r--r-- | altosui/AltosSerial.java | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/altosui/AltosSerial.java b/altosui/AltosSerial.java index c4e9c697..6cee1609 100644 --- a/altosui/AltosSerial.java +++ b/altosui/AltosSerial.java @@ -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) { |