X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=src%2Fedu%2Fberkeley%2Fobits%2FAtmelSerial.java;h=a7a4decef021bbdb85f279d241c2949c73fb6517;hb=f4da556e7246275d49adf8bb7b4c5b0192bc7b87;hp=2a9f352fd46182ece228e6df8d7e394841efd2d1;hpb=206063cc6a3b82e133b897ff688d2ae8c32b1868;p=slipway.git diff --git a/src/edu/berkeley/obits/AtmelSerial.java b/src/edu/berkeley/obits/AtmelSerial.java index 2a9f352..a7a4dec 100644 --- a/src/edu/berkeley/obits/AtmelSerial.java +++ b/src/edu/berkeley/obits/AtmelSerial.java @@ -13,14 +13,16 @@ public class AtmelSerial { while(e.hasMoreElements()) { CommPortIdentifier cpi = (CommPortIdentifier)e.nextElement(); Log.info(AtmelSerial.class, "trying " + cpi.getName()); + if (cpi.getName().startsWith("/dev/cu.usbserial-")) return new RXTXPort(cpi.getName()); + if (cpi.getName().startsWith("/dev/ttyS0")) return new RXTXPort(cpi.getName()); } - SerialPort ret = new RXTXPort("/dev/ttyS0"); - Log.info(AtmelSerial.class, "returning " + ret); - return ret; + Log.info(AtmelSerial.class, "returning null..."); + return null; } public static void main(String[] s) throws Exception { AvrDrone device = new AvrDrone(detectObitsPort()); + At40k at40k = new At40k.At40k10(device); int count = 0; try { long begin = System.currentTimeMillis(); @@ -34,6 +36,65 @@ public class AtmelSerial { device.flush(); long end = System.currentTimeMillis(); Log.info(AtmelSerial.class, "finished in " + ((end-begin)/1000) + "s"); + Thread.sleep(3000); + Log.info(AtmelSerial.class, "issuing command"); + + //at40k.iob_top(2, true).oe(false); + //at40k.iob_top(2, false).oe(false); + //at40k.iob_top(1, true).oe(false); + + // this command confirmed to turn *on* led0 + //at40k.iob_top(1, false).output(0); + /* + for(int i=0; i<20; i++) { + at40k.iob_bot(i, false).output(0); + at40k.iob_bot(i, true).output(0); + } + */ + + //System.out.println("tick"); + //Thread.sleep(3000); + //System.out.println("tick"); + //at40k.cell(0x01, 0x17).xlut((byte)0x); + + at40k.cell(0x04, 0x17).xlut((byte)~0x10); + at40k.cell(0x04, 0x17).ylut((byte)0x10); + at40k.cell(0x04, 0x17).xo(true); + + + /* + at40k.cell(0x01, 0x17).xin(4); + at40k.cell(0x01, 0x17).yin(4); + at40k.cell(0x01, 0x16).ylut((byte)0x00); + device.mode4(2, 0x17, 0x01, 0); + + for(int i=0; i<10; i++) { + Thread.sleep(3000); + System.out.println("tick"); + //at40k.cell(0x01, 0x17).xlut((byte)0xFF); + at40k.cell(0x00, 0x17).ylut((byte)0x00); + device.flush(); + Thread.sleep(3000); + System.out.println("tick"); + //at40k.cell(0x01, 0x17).xlut((byte)0x00); + at40k.cell(0x00, 0x17).ylut((byte)0xFF); + device.flush(); + } + */ + + + /* + at40k.iob_top(0, true).output(0); + at40k.iob_top(0, true).oe(false); + at40k.iob_top(0, true).pullup(); + device.flush(); + Thread.sleep(3000); + + Log.info(AtmelSerial.class, "issuing command"); + at40k.iob_top(1, true).pulldown(); + device.flush(); + */ + Log.info(AtmelSerial.class, "done"); System.exit(0); } catch (Exception e) { e.printStackTrace(); } }