From: adam Date: Wed, 19 Oct 2005 20:16:33 +0000 (-0700) Subject: checkpoint X-Git-Url: http://git.megacz.com/?p=eltron.git;a=commitdiff_plain;h=3e692ec1369ed1ffae3df009d5efb8001fc1b52e checkpoint darcs-hash:20051019201633-5007d-ba643b591c4ce204712d7b0f59a73e581f938c4c.gz --- diff --git a/src/edu/berkeley/cs/obits/AtmelSerial.java b/src/edu/berkeley/cs/obits/AtmelSerial.java index 5550225..693ae8b 100644 --- a/src/edu/berkeley/cs/obits/AtmelSerial.java +++ b/src/edu/berkeley/cs/obits/AtmelSerial.java @@ -1,7 +1,7 @@ package edu.berkeley.cs.obits; import edu.berkeley.cs.obits.device.atmel.*; -import org.ibex.util.Log; +import org.ibex.util.*; import java.io.*; import java.util.*; import gnu.io.*; @@ -18,6 +18,59 @@ public class AtmelSerial { } public static void main(String[] s) throws Exception { + SerialPort sp = detectObitsPort(); + sp.setSerialPortParams(9600, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); + sp.setFlowControlMode(sp.FLOWCONTROL_NONE); + OutputStream out = sp.getOutputStream(); + InputStream in = sp.getInputStream(); + int count = 0; + byte[] b = InputStreamToByteArray.convert(System.in); + PrintWriter pw = new PrintWriter(new OutputStreamWriter(out)); + /* + pw.println("Y38,N,8,1"); + pw.flush(); + sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE); + + pw.println("GI"); + pw.flush(); + */ + pw.println("OD"); + pw.println("N"); + pw.println("D14"); + pw.println("S1"); + pw.println("Q609,24"); + pw.println("q754"); + //pw.println("R0,0"); + + int len = 228; + pw.println("GK\"IMG\""); + pw.println("GM\"IMG\""+len); + System.out.println("flushing"); + pw.flush(); + System.out.println("flushed"); + DataOutputStream dos = new DataOutputStream(out); + + dos.flush(); + + /* + pw.println("A170,5,0,1,5,5,N,\"WORLDWIDE\""); + pw.println("LO5,230,765,10"); + pw.println("A10,265,0,1,3,3,R,\"MODEL:\""); + pw.println("A280,265,0,1,3,3,N,\"Bar Code Printer\""); + pw.println("A10,340,0,1,3,3,R,\" CODE: \""); + pw.println("B280,340,0,3C,2,6,120,B,\"BCP-1234\""); + pw.println("LO5,520,765,10"); + pw.println("A100,550,0,1,2,2,N,\"ISO9000 Made In USA\""); + pw.println("GG650,535,\"CE_5M\""); + */ + pw.println("GG0,0,\"IMG\""); + pw.println("P1"); + pw.flush(); + /* + */ + //Log.debug(this, "consuming any leftover data on the serial port"); + + /* AvrDrone device = new AvrDrone(detectObitsPort()); int count = 0; try { @@ -34,6 +87,8 @@ public class AtmelSerial { Log.info(AtmelSerial.class, "finished in " + ((end-begin)/1000) + "s"); System.exit(0); } catch (Exception e) { e.printStackTrace(); } + */ + System.exit(0); } } diff --git a/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java b/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java index 7e3c7fd..42425cf 100644 --- a/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java +++ b/src/edu/berkeley/cs/obits/device/atmel/AtmelDevice.java @@ -1,12 +1,14 @@ package edu.berkeley.cs.obits.device.atmel; import edu.berkeley.cs.obits.*; +//import static edu.berkeley.cs.obits.device.atmel.Wires.*; +import java.util.*; -public abstract class AtmelDevice extends Device { +public abstract class AtmelDevice extends Bits implements Device { /** issue a command to the device in Mode4 format; see Gosset's documentation for further details */ - public void mode4(int z, int y, int x, int d) throws DeviceException; - + public abstract void mode4(int z, int y, int x, int d) throws DeviceException; + /* public Sector sector(int col, int row) { return new Sector(col, row); } public final class Sector { public final int col; @@ -18,16 +20,228 @@ public abstract class AtmelDevice extends Device { this.col = col; } } + + public static interface Driver { } + + public static interface HasPlane { public int getPlane(); } + + public static interface XI extends Driver { } + public static interface YI extends Driver { } + */ + /* + public static void foo(Direction f) { } + public static enum Direction implements Drives { N, S, E, W; } + public static enum Bar { A, B, C; } + public static Object B = new Object(); + public static Direction foo = null; + static { + switch(foo) { + case N: + case S: + case W: + } + } + + public class Drives> { } + public class EPR> { + public abstract Drives driver(); + public abstract void driver(Drives); + } + + public class Joins> { } + public abstract class Bus> { + public Set> drivers(); + } + public interface Drives { } + + + public static interface EPR { + } + public static interface Drives { } + public static interface Bus extends EPR { } + public static interface Joins> extends Bus { } + //public static interface Joins extends Bus { } + public static interface Has { + public Drives getDriver(E e); + public void setDriver(E e, Drives driver); + } + //public static interface HasBus { public Set> on(B b); } + public interface Input { } + public interface Output { } + public interface InOut { } + + public static abstract class LUT implements EPR { } + public static abstract class And implements EPR { } + public static abstract class Reg { } + public static abstract class Mux { } + public static abstract class Buf { } + + public enum DiagonalInputs implements Input, Drives { NW, SW, NE, SE; } + public enum OrthogonalInputs implements Input, Drives { N, S, E, W; } + + public , Y extends EPR> void connect(X x, Y y) { } + + public static enum Plane { P0, P1, P2, P3, P4; } + public static class L

implements Bus, Drives, Drives, Drives, Drives { } + + public final class Cell { + public class X implements EPR, Drives, Drives { } + public class Y implements EPR, Drives, Drives { } + public class Z implements EPR, Drives, Drives { } + public class F implements EPR, Drives, Drives, Drives { } + public class W implements EPR, Drives, Drives, Drives { } + public class A implements EPR { } + public class WZ extends And implements EPR, Drives, Drives { } + public class WF extends And implements EPR, Drives, Drives { } + public class CM extends Mux implements EPR, Drives { } + public class XLUT extends LUT implements EPR, Drives, Drives { } + public class YLUT extends LUT implements EPR, Drives, Drives { } + public class C implements EPR, Drives, Drives { } + public class R extends Reg implements EPR, Drives, Drives, Drives{ } + public class XO implements EPR, Output { } + public class YO implements EPR, Output { } + public static class OB extends Buf> implements EPR, Drives, Drives, Drives, Drives, Drives { } + + */ + //public static L1 L1 = new L1(); + /* + public static class CellImpl implements + Has, + Has { + public void setDriver(X x, Drives d) { } + public void setDriver(Y y, Drives d) { } + public void setDriver(Z z, Drives d) { } + public void setDriver(W w, Drives d) { } + public Drives getDriver(X x) { return null; } + public Drives getDriver(Y y) { return null; } + public Drives getDriver(Z z) { return null; } + public Drives getDriver(W w) { return null; } + + public Set> on(L1 l1) { return null; } + public Drives getDriver(Y y) { return null; } + public void setDriver(Y y, Drives d) { } + } + */ + /* + public static abstract class L implements HasPlane, EPR { + private final int plane; + L(int plane) { this.plane = plane; } + public int getPlane() { return plane; } + public boolean h(); + public void h(boolean connected); + public boolean v(); + public void v(boolean connected); + public boolean f(); + public void f(boolean connected); + } + + L0 = new L(0); + L1 = new L(1); + L2 = new L(2); + L3 = new L(3); + L4 = new L(4); + + + public static enum L implements XI, YI { + L0(0), L1(1), L2(2), L3(3) { public int foo() { return 2; } }, L4(4); + + public final int plane; + public L(int plane) { this.plane = plane; } + + } + */ + + //public static interface L0 extends XI, YI { } public static L0 L0 = new L0() { }; + + /* + + public static enum Xi { NONE, L0, L1, L2, L3, NW, SW, NE, SE, L4; } + public static enum Yi { NONE, L0, L1, L2, L3, E, W, S, N, L4; } + public static enum Wi { NONE, L0, L1, L4, L3, L2; } + public static enum Zi { NONE, L0, L1, L2, L3, L4; } + public static enum Ti { W, Z, F, WZ, WF, ONE; } + public static enum Ci { X, Y, CMux; } + public static enum Fi { R, C; } + public static enum Bi { R, C; } + public static enum Xo { X, B; } + public static enum Yo { Y, B; } + public static enum Oe { ONE, H4, V4; } + public Cell cell(int col, int row) { return new Cell(col, row); } public final class Cell { public final int col; public final int row; + */ + /** assumes LITTLE endian */ + /* + protected int onehot(int val) { + int ret = -1; + for(int i=0; i<32; i++) { + if ((val & (1 << i)) != 0) { + if (ret != -1) throw new Error("two bits set in a one-hot encoded value"); + ret = i; + } + } + return ret+1; + } + protected int bits(int octet, int bit, int count) { + return AtmelDevice.this.bits.get(offset, count); + } + + public void set(Xi xi) { } + public void set(Yi xi) { } + public void set(Ti xi) { } + public void set(Ci xi) { } + public void set(Fi xi) { } + public void set(Bi xi) { } + public void set(Xo xo) { } + public void set(Yo yo) { } + public void set(Oe oe) { } + + public Xi xi() { return Xi.values()[onehot((bits(3,3,1)<<8)|bits(5,0,8))]; } + public Yi yi() { return Yi.values()[onehot((bits(2,1,1)<<8)|bits(4,0,8))]; } + public Wi wi() { return Wi.values()[onehot((bits(3,0,3)<<2)|bits(3,4,2))]; } + public Zi zi() { return Zi.values()[onehot((bits(2,0,1)<<4)|bits(2,2,4))]; } + public Ti ti() { return null; } + public Ci ci() { return null; } + public Fi fi() { return null; } + public Bi bi() { return null; } + public Xo xo() { return Xo.values()[onehot(bits(1,6,1))]; } + public Yo yo() { return Yo.values()[onehot(bits(1,7,1))]; } + public Oe oe() { return Oe.values()[onehot(bits(3,6,2))]; } + public Sector getSector() { return sector(col - (col % 4), row - (row % 4)); } public Cell(int col, int row) { this.row = row; this.col = col; } - } + + + + public static enum EPR { L0, L1, L2, L3, L4 } + public static enum XInputDriver extends InputDriver { + public static enum YInputDriver extends InputDriver { N, S, E, W } + public XInputDriver xi() { } + public void xi(XInputDriver) { } + public YInputDriver yi() { } + public void yi(YInputDriver) { } + public InputDriver zi() { } + public void zi(InputDriver) { } + public InputDriver wi() { } + public void wi(InputDriver) { } + + public byte xlut() { } + public xlut(byte) { } + public byte ylut() { } + public ylut(byte) { } + + public static enum CInputDriver { XL, YL, C } + public static enum FDriver { R, C } + + public boolean cRegistered() { } + + } + */ } diff --git a/src/edu/berkeley/cs/obits/device/atmel/AvrDrone.c b/src/edu/berkeley/cs/obits/device/atmel/AvrDrone.c index 2b4fa74..0878b4f 100644 --- a/src/edu/berkeley/cs/obits/device/atmel/AvrDrone.c +++ b/src/edu/berkeley/cs/obits/device/atmel/AvrDrone.c @@ -3,6 +3,7 @@ // #define F_CPU 3960000 +#define __AVR_AT94K__ #include #include #include