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