package altosui;
-import java.lang.*;
import java.io.*;
-import java.util.concurrent.*;
import java.util.*;
-import java.text.*;
import java.awt.*;
-import java.awt.event.*;
import javax.swing.*;
-import javax.swing.filechooser.FileNameExtensionFilter;
-import javax.swing.table.*;
import org.altusmetrum.AltosLib.*;
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>());
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();
+ }
}
}
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) {