1 package edu.berkeley.cs.obits;
3 import edu.berkeley.cs.obits.device.atmel.*;
4 import org.ibex.util.Log;
9 public class AtmelSerial {
11 public static SerialPort detectObitsPort() throws Exception {
12 Enumeration e = CommPortIdentifier.getPortIdentifiers();
13 while(e.hasMoreElements()) {
14 CommPortIdentifier cpi = (CommPortIdentifier)e.nextElement();
15 Log.info(AtmelSerial.class, "trying " + cpi.getName());
17 return new RXTXPort("/dev/cu.usbserial-FTBUODP4");
20 public static void main(String[] s) throws Exception {
21 AvrDrone device = new AvrDrone(detectObitsPort());
24 long begin = System.currentTimeMillis();
25 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
26 for(String str = br.readLine(); str != null; str = br.readLine()) {
27 long foo = Long.parseLong(str, 16);
28 device.mode4((int)(foo >> 24), (int)(foo >> 16), (int)(foo >> 8), (int)(foo >> 0));
30 if (count % 100 == 0) Log.info(AtmelSerial.class, "wrote " + count + " configuration octets");
33 long end = System.currentTimeMillis();
34 Log.info(AtmelSerial.class, "finished in " + ((end-begin)/1000) + "s");
36 } catch (Exception e) { e.printStackTrace(); }