add comment to SerialBoard.java
[slipway.git] / src / edu / berkeley / slipway / SerialBoard.java
1 package edu.berkeley.slipway;
2
3 import edu.berkeley.abits.*;
4 import org.ibex.util.Log;
5 import java.io.*;
6 import java.util.*;
7
8 /**
9  *  This class is obsolete; it used to be an implementation intended
10  *  for an RS-232 interface to Atmel's development kit board.
11  */
12 public abstract class SerialBoard implements Board {
13
14     /*
15     private final SerialPort sp;
16     private final DataInputStream in;
17     private final DataOutputStream out;
18
19     public SerialBoard(SerialPort sp) throws IOException, UnsupportedCommOperationException, InterruptedException {
20         this.sp = sp;
21         sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
22         sp.setFlowControlMode(sp.FLOWCONTROL_RTSCTS_OUT);
23         sp.setInputBufferSize(1024);
24         this.out = new DataOutputStream(sp.getOutputStream());
25         this.in = new DataInputStream(sp.getInputStream());
26         Log.debug(this, "consuming any leftover data on the serial port");
27         while(in.available() > 0) in.read();
28         reset();
29     }
30
31     public void reset() {
32         try {
33             Log.info(this, "resetting device");
34             sp.setDTR(true);
35             sp.setRTS(true);
36             Thread.sleep(500);
37             Log.info(this, "deasserting reset signal");
38             sp.setDTR(false);
39             sp.setRTS(false);
40             Thread.sleep(100);
41         } catch (InterruptedException e) { throw new RuntimeException(e); }
42     }
43
44     public void boot(Reader r) throws Exception {
45         throw new Error("not implemented");
46     }
47
48     public InputStream getInputStream() { return in; }
49     public OutputStream getOutputStream() { return out; }
50     */
51     /*
52     public static SerialPort detectObitsPort() throws Exception {
53         Enumeration e = CommPortIdentifier.getPortIdentifiers();
54         while(e.hasMoreElements()) {
55             CommPortIdentifier cpi = (CommPortIdentifier)e.nextElement();
56             Log.info(Demo.class, "trying " + cpi.getName());
57             if (cpi.getName().startsWith("/dev/cu.usbserial-"))
58                 return new RXTXPort(cpi.getName());
59             if (cpi.getName().startsWith("/dev/ttyS0"))
60                 return new RXTXPort(cpi.getName());
61         }
62         Log.info(Demo.class, "returning null...");
63         return null;
64     }
65     */
66 }