1 package edu.berkeley.slipway;
3 import edu.berkeley.obits.*;
4 import org.ibex.util.Log;
9 public class SerialBoard extends Board {
11 private final SerialPort sp;
12 private final DataInputStream in;
13 private final DataOutputStream out;
15 public SerialBoard(SerialPort sp) throws IOException, UnsupportedCommOperationException, InterruptedException {
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();
29 Log.info(this, "resetting device");
33 Log.info(this, "deasserting reset signal");
37 } catch (InterruptedException e) { throw new RuntimeException(e); }
40 public void boot(Reader r) throws Exception {
41 throw new Error("not implemented");
44 public InputStream getInputStream() { return in; }
45 public OutputStream getOutputStream() { return out; }