- }
-
- public void open(File name) throws FileNotFoundException {
- close();
- serial_in = new FileInputStream(name);
- input_thread = new Thread(this);
- input_thread.start();
- }
- public void open(CommPort c) throws IOException {
- close();
- try {
- c.enableReceiveTimeout(1000); /* icky. the read method cannot be interrupted */
- } catch (UnsupportedCommOperationException ee) {
- }
- serial_in = c.getInputStream();
- input_thread = new Thread(this);
- input_thread.start();
- }
- public AltosSerialReader () {
- serial_in = null;
- input_thread = null;
- line = "";
- monitors = new LinkedList<LinkedBlockingQueue<String>> ();
- reply_queue = new LinkedBlockingQueue<String> ();
- }
-
-}
-
-public class AltosSerial {
- OutputStream serial_out = null;
- AltosSerialReader reader = null;
-
- CommPort comm_port = null;
-
- public void close() {
- try {
- serial_out.close();
- } catch (IOException ee) {
- }
- reader.close();
- if (comm_port != null) {
- comm_port.close();