1 package edu.berkeley.obits;
3 import edu.berkeley.obits.device.atmel.*;
4 import org.ibex.util.*;
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 SerialPort ret = new RXTXPort("/dev/cu.usbserial-FTCBWI2P");
18 Log.info(AtmelSerial.class, "returning " + ret);
22 public static void main(String[] s) throws Exception {
23 AvrDrone device = new AvrDrone(detectObitsPort());
26 long begin = System.currentTimeMillis();
27 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
28 for(String str = br.readLine(); str != null; str = br.readLine()) {
29 long foo = Long.parseLong(str, 16);
30 device.mode4((int)(foo >> 24), (int)(foo >> 16), (int)(foo >> 8), (int)(foo >> 0));
32 if (count % 100 == 0) Log.info(AtmelSerial.class, "wrote " + count + " configuration octets");
35 long end = System.currentTimeMillis();
36 Log.info(AtmelSerial.class, "finished in " + ((end-begin)/1000) + "s");
38 } catch (Exception e) { e.printStackTrace(); }