package edu.berkeley.obits.device.atmel;
+import edu.berkeley.slipway.*;
import edu.berkeley.obits.*;
import org.ibex.util.Log;
import java.io.*;
init();
}
- public void reset() { board.reset(); }
+ public void reset() throws DeviceException {
+ try {
+ board.reset();
+ } catch (IOException e) {
+ throw new DeviceException(e);
+ }
+ }
private void init() throws IOException {
- Log.debug(this, "waiting for device to identify itself");
+ //Log.debug(this, "waiting for device to identify itself");
/*
if (in.readByte() != (byte)'O') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'B') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'S') throw new RuntimeException("didn't get the proper signature");
if (in.readByte() != (byte)'\n') throw new RuntimeException("didn't get the proper signature");
*/
- out.write(0);
byte[] bytes = new byte[6];
- for(int i=0; i<6; i++) {
- bytes[i] = in.readByte();
- System.out.println("got " + (i+1) + " header bytes: " + (bytes[i] & 0xff) + " '" + ((char)bytes[i]) + "'");
- // FIXME
+ int i=0;
+
+ out.write(0);
+ out.flush();
+
+ // read any crap that might be left in the buffer
+ while(true) {
+ System.arraycopy(bytes, 1, bytes, 0, 5);
+ bytes[5] = in.readByte();
+ i++;
+ System.out.println("got " + new String(bytes));
+ if (bytes[0] == (byte)'O' &&
+ bytes[1] == (byte)'B' &&
+ bytes[2] == (byte)'I' &&
+ bytes[3] == (byte)'T' &&
+ bytes[4] == (byte)'S' &&
+ bytes[5] == (byte)'\n') {
+ System.out.println("got proper signature");
+ break;
+ }
}
- Log.info(this, "device correctly identified itself; ready for operation");
+ //Log.info(this, "device correctly identified itself; ready for operation");
}
public synchronized void scanFPGA(boolean on) throws DeviceException {