remove extraneous classes
[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 public abstract class SerialBoard implements Board {
9
10     /*
11     private final SerialPort sp;
12     private final DataInputStream in;
13     private final DataOutputStream out;
14
15     public SerialBoard(SerialPort sp) throws IOException, UnsupportedCommOperationException, InterruptedException {
16         this.sp = sp;
17         sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
18         sp.setFlowControlMode(sp.FLOWCONTROL_RTSCTS_OUT);
19         sp.setInputBufferSize(1024);
20         this.out = new DataOutputStream(sp.getOutputStream());
21         this.in = new DataInputStream(sp.getInputStream());
22         Log.debug(this, "consuming any leftover data on the serial port");
23         while(in.available() > 0) in.read();
24         reset();
25     }
26
27     public void reset() {
28         try {
29             Log.info(this, "resetting device");
30             sp.setDTR(true);
31             sp.setRTS(true);
32             Thread.sleep(500);
33             Log.info(this, "deasserting reset signal");
34             sp.setDTR(false);
35             sp.setRTS(false);
36             Thread.sleep(100);
37         } catch (InterruptedException e) { throw new RuntimeException(e); }
38     }
39
40     public void boot(Reader r) throws Exception {
41         throw new Error("not implemented");
42     }
43
44     public InputStream getInputStream() { return in; }
45     public OutputStream getOutputStream() { return out; }
46     */
47     /*
48     public static SerialPort detectObitsPort() throws Exception {
49         Enumeration e = CommPortIdentifier.getPortIdentifiers();
50         while(e.hasMoreElements()) {
51             CommPortIdentifier cpi = (CommPortIdentifier)e.nextElement();
52             Log.info(Demo.class, "trying " + cpi.getName());
53             if (cpi.getName().startsWith("/dev/cu.usbserial-"))
54                 return new RXTXPort(cpi.getName());
55             if (cpi.getName().startsWith("/dev/ttyS0"))
56                 return new RXTXPort(cpi.getName());
57         }
58         Log.info(Demo.class, "returning null...");
59         return null;
60     }
61     */
62 }