checkpoint
authoradam <adam@megacz.com>
Mon, 11 Sep 2006 11:34:21 +0000 (12:34 +0100)
committeradam <adam@megacz.com>
Mon, 11 Sep 2006 11:34:21 +0000 (12:34 +0100)
21 files changed:
src/com/ftdi/usb/SWIGTYPE_p_ftdi_context.java [new file with mode: 0644]
src/com/ftdi/usb/SWIGTYPE_p_ftdi_eeprom.java [new file with mode: 0644]
src/com/ftdi/usb/SWIGTYPE_p_p_ftdi_device_list.java [new file with mode: 0644]
src/com/ftdi/usb/SWIGTYPE_p_unsigned_char.java [new file with mode: 0644]
src/com/ftdi/usb/SWIGTYPE_p_unsigned_int.java [new file with mode: 0644]
src/com/ftdi/usb/SWIGTYPE_p_usb_dev_handle.java [new file with mode: 0644]
src/com/ftdi/usb/SWIGTYPE_p_usb_device.java [new file with mode: 0644]
src/com/ftdi/usb/example.java [new file with mode: 0644]
src/com/ftdi/usb/exampleJNI.java [new file with mode: 0644]
src/com/ftdi/usb/ftdi.i
src/edu/berkeley/obits/AtmelSerial.java
src/edu/berkeley/obits/device/atmel/AT94k.java [deleted file]
src/edu/berkeley/obits/device/atmel/AvrDrone.java
src/edu/berkeley/obits/device/atmel/Board.java [new file with mode: 0644]
src/edu/berkeley/obits/device/atmel/Chip.java
src/edu/berkeley/obits/device/atmel/ChipImpl.java
src/edu/berkeley/obits/device/atmel/FakeBoard.java [new file with mode: 0644]
src/edu/berkeley/obits/device/atmel/FtdiBoard.java [moved from src/edu/berkeley/obits/device/atmel/Demo.java with 53% similarity]
src/edu/berkeley/obits/device/atmel/SerialBoard.java [new file with mode: 0644]
src/edu/berkeley/obits/device/atmel/Wires.java [deleted file]
src/edu/berkeley/obits/gui/Gui.java

diff --git a/src/com/ftdi/usb/SWIGTYPE_p_ftdi_context.java b/src/com/ftdi/usb/SWIGTYPE_p_ftdi_context.java
new file mode 100644 (file)
index 0000000..ed8109f
--- /dev/null
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class SWIGTYPE_p_ftdi_context {
+  private long swigCPtr;
+
+  protected SWIGTYPE_p_ftdi_context(long cPtr, boolean futureUse) {
+    swigCPtr = cPtr;
+  }
+
+  protected SWIGTYPE_p_ftdi_context() {
+    swigCPtr = 0;
+  }
+
+  protected static long getCPtr(SWIGTYPE_p_ftdi_context obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+}
+
diff --git a/src/com/ftdi/usb/SWIGTYPE_p_ftdi_eeprom.java b/src/com/ftdi/usb/SWIGTYPE_p_ftdi_eeprom.java
new file mode 100644 (file)
index 0000000..95e0e2e
--- /dev/null
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class SWIGTYPE_p_ftdi_eeprom {
+  private long swigCPtr;
+
+  protected SWIGTYPE_p_ftdi_eeprom(long cPtr, boolean futureUse) {
+    swigCPtr = cPtr;
+  }
+
+  protected SWIGTYPE_p_ftdi_eeprom() {
+    swigCPtr = 0;
+  }
+
+  protected static long getCPtr(SWIGTYPE_p_ftdi_eeprom obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+}
+
diff --git a/src/com/ftdi/usb/SWIGTYPE_p_p_ftdi_device_list.java b/src/com/ftdi/usb/SWIGTYPE_p_p_ftdi_device_list.java
new file mode 100644 (file)
index 0000000..3cfe433
--- /dev/null
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class SWIGTYPE_p_p_ftdi_device_list {
+  private long swigCPtr;
+
+  protected SWIGTYPE_p_p_ftdi_device_list(long cPtr, boolean futureUse) {
+    swigCPtr = cPtr;
+  }
+
+  protected SWIGTYPE_p_p_ftdi_device_list() {
+    swigCPtr = 0;
+  }
+
+  protected static long getCPtr(SWIGTYPE_p_p_ftdi_device_list obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+}
+
diff --git a/src/com/ftdi/usb/SWIGTYPE_p_unsigned_char.java b/src/com/ftdi/usb/SWIGTYPE_p_unsigned_char.java
new file mode 100644 (file)
index 0000000..b790a60
--- /dev/null
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class SWIGTYPE_p_unsigned_char {
+  private long swigCPtr;
+
+  protected SWIGTYPE_p_unsigned_char(long cPtr, boolean futureUse) {
+    swigCPtr = cPtr;
+  }
+
+  protected SWIGTYPE_p_unsigned_char() {
+    swigCPtr = 0;
+  }
+
+  protected static long getCPtr(SWIGTYPE_p_unsigned_char obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+}
+
diff --git a/src/com/ftdi/usb/SWIGTYPE_p_unsigned_int.java b/src/com/ftdi/usb/SWIGTYPE_p_unsigned_int.java
new file mode 100644 (file)
index 0000000..ba0046a
--- /dev/null
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class SWIGTYPE_p_unsigned_int {
+  private long swigCPtr;
+
+  protected SWIGTYPE_p_unsigned_int(long cPtr, boolean futureUse) {
+    swigCPtr = cPtr;
+  }
+
+  protected SWIGTYPE_p_unsigned_int() {
+    swigCPtr = 0;
+  }
+
+  protected static long getCPtr(SWIGTYPE_p_unsigned_int obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+}
+
diff --git a/src/com/ftdi/usb/SWIGTYPE_p_usb_dev_handle.java b/src/com/ftdi/usb/SWIGTYPE_p_usb_dev_handle.java
new file mode 100644 (file)
index 0000000..29c05cf
--- /dev/null
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class SWIGTYPE_p_usb_dev_handle {
+  private long swigCPtr;
+
+  protected SWIGTYPE_p_usb_dev_handle(long cPtr, boolean futureUse) {
+    swigCPtr = cPtr;
+  }
+
+  protected SWIGTYPE_p_usb_dev_handle() {
+    swigCPtr = 0;
+  }
+
+  protected static long getCPtr(SWIGTYPE_p_usb_dev_handle obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+}
+
diff --git a/src/com/ftdi/usb/SWIGTYPE_p_usb_device.java b/src/com/ftdi/usb/SWIGTYPE_p_usb_device.java
new file mode 100644 (file)
index 0000000..a951d9b
--- /dev/null
@@ -0,0 +1,26 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class SWIGTYPE_p_usb_device {
+  private long swigCPtr;
+
+  protected SWIGTYPE_p_usb_device(long cPtr, boolean futureUse) {
+    swigCPtr = cPtr;
+  }
+
+  protected SWIGTYPE_p_usb_device() {
+    swigCPtr = 0;
+  }
+
+  protected static long getCPtr(SWIGTYPE_p_usb_device obj) {
+    return (obj == null) ? 0 : obj.swigCPtr;
+  }
+}
+
diff --git a/src/com/ftdi/usb/example.java b/src/com/ftdi/usb/example.java
new file mode 100644 (file)
index 0000000..066896c
--- /dev/null
@@ -0,0 +1,146 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+public class example {
+  public static SWIGTYPE_p_ftdi_context new_ftdi_context() {
+    long cPtr = exampleJNI.new_ftdi_context();
+    return (cPtr == 0) ? null : new SWIGTYPE_p_ftdi_context(cPtr, false);
+  }
+
+  public static SWIGTYPE_p_ftdi_eeprom new_ftdi_eeprom() {
+    long cPtr = exampleJNI.new_ftdi_eeprom();
+    return (cPtr == 0) ? null : new SWIGTYPE_p_ftdi_eeprom(cPtr, false);
+  }
+
+  public static int ftdi_init(SWIGTYPE_p_ftdi_context ftdi) {
+    return exampleJNI.ftdi_init(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+  }
+
+  public static void ftdi_deinit(SWIGTYPE_p_ftdi_context ftdi) {
+    exampleJNI.ftdi_deinit(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+  }
+
+  public static void ftdi_set_usbdev(SWIGTYPE_p_ftdi_context ftdi, SWIGTYPE_p_usb_dev_handle usbdev) {
+    exampleJNI.ftdi_set_usbdev(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), SWIGTYPE_p_usb_dev_handle.getCPtr(usbdev));
+  }
+
+  public static int ftdi_usb_find_all(SWIGTYPE_p_ftdi_context ftdi, SWIGTYPE_p_p_ftdi_device_list devlist, int vendor, int product) {
+    return exampleJNI.ftdi_usb_find_all(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), SWIGTYPE_p_p_ftdi_device_list.getCPtr(devlist), vendor, product);
+  }
+
+  public static void ftdi_list_free(SWIGTYPE_p_p_ftdi_device_list devlist) {
+    exampleJNI.ftdi_list_free(SWIGTYPE_p_p_ftdi_device_list.getCPtr(devlist));
+  }
+
+  public static int ftdi_usb_open(SWIGTYPE_p_ftdi_context ftdi, int vendor, int product) {
+    return exampleJNI.ftdi_usb_open(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), vendor, product);
+  }
+
+  public static int ftdi_usb_open_desc(SWIGTYPE_p_ftdi_context ftdi, int vendor, int product, String description, String serial) {
+    return exampleJNI.ftdi_usb_open_desc(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), vendor, product, description, serial);
+  }
+
+  public static int ftdi_usb_open_dev(SWIGTYPE_p_ftdi_context ftdi, SWIGTYPE_p_usb_device dev) {
+    return exampleJNI.ftdi_usb_open_dev(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), SWIGTYPE_p_usb_device.getCPtr(dev));
+  }
+
+  public static int ftdi_usb_close(SWIGTYPE_p_ftdi_context ftdi) {
+    return exampleJNI.ftdi_usb_close(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+  }
+
+  public static int ftdi_usb_reset(SWIGTYPE_p_ftdi_context ftdi) {
+    return exampleJNI.ftdi_usb_reset(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+  }
+
+  public static int ftdi_usb_purge_buffers(SWIGTYPE_p_ftdi_context ftdi) {
+    return exampleJNI.ftdi_usb_purge_buffers(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+  }
+
+  public static int ftdi_set_baudrate(SWIGTYPE_p_ftdi_context ftdi, int baudrate) {
+    return exampleJNI.ftdi_set_baudrate(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), baudrate);
+  }
+
+  public static int ftdi_set_line_property(SWIGTYPE_p_ftdi_context ftdi, int bits, int sbit, int parity) {
+    return exampleJNI.ftdi_set_line_property(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), bits, sbit, parity);
+  }
+
+  public static int ftdi_read_data(SWIGTYPE_p_ftdi_context ftdi, byte[] buf, int size) {
+    return exampleJNI.ftdi_read_data(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), buf, size);
+  }
+
+  public static int ftdi_read_data_set_chunksize(SWIGTYPE_p_ftdi_context ftdi, long chunksize) {
+    return exampleJNI.ftdi_read_data_set_chunksize(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), chunksize);
+  }
+
+  public static int ftdi_read_data_get_chunksize(SWIGTYPE_p_ftdi_context ftdi, SWIGTYPE_p_unsigned_int chunksize) {
+    return exampleJNI.ftdi_read_data_get_chunksize(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), SWIGTYPE_p_unsigned_int.getCPtr(chunksize));
+  }
+
+  public static int ftdi_write_data(SWIGTYPE_p_ftdi_context ftdi, byte[] buf, int size) {
+    return exampleJNI.ftdi_write_data(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), buf, size);
+  }
+
+  public static int ftdi_write_data_set_chunksize(SWIGTYPE_p_ftdi_context ftdi, long chunksize) {
+    return exampleJNI.ftdi_write_data_set_chunksize(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), chunksize);
+  }
+
+  public static int ftdi_write_data_get_chunksize(SWIGTYPE_p_ftdi_context ftdi, SWIGTYPE_p_unsigned_int chunksize) {
+    return exampleJNI.ftdi_write_data_get_chunksize(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), SWIGTYPE_p_unsigned_int.getCPtr(chunksize));
+  }
+
+  public static int ftdi_enable_bitbang(SWIGTYPE_p_ftdi_context ftdi, short bitmask) {
+    return exampleJNI.ftdi_enable_bitbang(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), bitmask);
+  }
+
+  public static int ftdi_disable_bitbang(SWIGTYPE_p_ftdi_context ftdi) {
+    return exampleJNI.ftdi_disable_bitbang(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+  }
+
+  public static int ftdi_set_bitmode(SWIGTYPE_p_ftdi_context ftdi, short bitmask, short mode) {
+    return exampleJNI.ftdi_set_bitmode(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), bitmask, mode);
+  }
+
+  public static int ftdi_read_pins(SWIGTYPE_p_ftdi_context ftdi, byte[] pins) {
+    return exampleJNI.ftdi_read_pins(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), pins);
+  }
+
+  public static int ftdi_setflowctrl(SWIGTYPE_p_ftdi_context ftdi, int flowctrl) {
+    return exampleJNI.ftdi_setflowctrl(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), flowctrl);
+  }
+
+  public static int ftdi_set_latency_timer(SWIGTYPE_p_ftdi_context ftdi, short latency) {
+    return exampleJNI.ftdi_set_latency_timer(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), latency);
+  }
+
+  public static int ftdi_get_latency_timer(SWIGTYPE_p_ftdi_context ftdi, SWIGTYPE_p_unsigned_char latency) {
+    return exampleJNI.ftdi_get_latency_timer(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), SWIGTYPE_p_unsigned_char.getCPtr(latency));
+  }
+
+  public static void ftdi_eeprom_initdefaults(SWIGTYPE_p_ftdi_eeprom eeprom) {
+    exampleJNI.ftdi_eeprom_initdefaults(SWIGTYPE_p_ftdi_eeprom.getCPtr(eeprom));
+  }
+
+  public static int ftdi_eeprom_build(SWIGTYPE_p_ftdi_eeprom eeprom, byte[] output) {
+    return exampleJNI.ftdi_eeprom_build(SWIGTYPE_p_ftdi_eeprom.getCPtr(eeprom), output);
+  }
+
+  public static int ftdi_read_eeprom(SWIGTYPE_p_ftdi_context ftdi, byte[] eeprom) {
+    return exampleJNI.ftdi_read_eeprom(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), eeprom);
+  }
+
+  public static int ftdi_write_eeprom(SWIGTYPE_p_ftdi_context ftdi, byte[] eeprom) {
+    return exampleJNI.ftdi_write_eeprom(SWIGTYPE_p_ftdi_context.getCPtr(ftdi), eeprom);
+  }
+
+  public static int ftdi_erase_eeprom(SWIGTYPE_p_ftdi_context ftdi) {
+    return exampleJNI.ftdi_erase_eeprom(SWIGTYPE_p_ftdi_context.getCPtr(ftdi));
+  }
+
+}
diff --git a/src/com/ftdi/usb/exampleJNI.java b/src/com/ftdi/usb/exampleJNI.java
new file mode 100644 (file)
index 0000000..ba07315
--- /dev/null
@@ -0,0 +1,45 @@
+/* ----------------------------------------------------------------------------
+ * This file was automatically generated by SWIG (http://www.swig.org).
+ * Version 1.3.29
+ *
+ * Do not make changes to this file unless you know what you are doing--modify
+ * the SWIG interface file instead.
+ * ----------------------------------------------------------------------------- */
+
+package com.ftdi.usb;
+
+class exampleJNI {
+  public final static native long new_ftdi_context();
+  public final static native long new_ftdi_eeprom();
+  public final static native int ftdi_init(long jarg1);
+  public final static native void ftdi_deinit(long jarg1);
+  public final static native void ftdi_set_usbdev(long jarg1, long jarg2);
+  public final static native int ftdi_usb_find_all(long jarg1, long jarg2, int jarg3, int jarg4);
+  public final static native void ftdi_list_free(long jarg1);
+  public final static native int ftdi_usb_open(long jarg1, int jarg2, int jarg3);
+  public final static native int ftdi_usb_open_desc(long jarg1, int jarg2, int jarg3, String jarg4, String jarg5);
+  public final static native int ftdi_usb_open_dev(long jarg1, long jarg2);
+  public final static native int ftdi_usb_close(long jarg1);
+  public final static native int ftdi_usb_reset(long jarg1);
+  public final static native int ftdi_usb_purge_buffers(long jarg1);
+  public final static native int ftdi_set_baudrate(long jarg1, int jarg2);
+  public final static native int ftdi_set_line_property(long jarg1, int jarg2, int jarg3, int jarg4);
+  public final static native int ftdi_read_data(long jarg1, byte[] jarg2, int jarg3);
+  public final static native int ftdi_read_data_set_chunksize(long jarg1, long jarg2);
+  public final static native int ftdi_read_data_get_chunksize(long jarg1, long jarg2);
+  public final static native int ftdi_write_data(long jarg1, byte[] jarg2, int jarg3);
+  public final static native int ftdi_write_data_set_chunksize(long jarg1, long jarg2);
+  public final static native int ftdi_write_data_get_chunksize(long jarg1, long jarg2);
+  public final static native int ftdi_enable_bitbang(long jarg1, short jarg2);
+  public final static native int ftdi_disable_bitbang(long jarg1);
+  public final static native int ftdi_set_bitmode(long jarg1, short jarg2, short jarg3);
+  public final static native int ftdi_read_pins(long jarg1, byte[] jarg2);
+  public final static native int ftdi_setflowctrl(long jarg1, int jarg2);
+  public final static native int ftdi_set_latency_timer(long jarg1, short jarg2);
+  public final static native int ftdi_get_latency_timer(long jarg1, long jarg2);
+  public final static native void ftdi_eeprom_initdefaults(long jarg1);
+  public final static native int ftdi_eeprom_build(long jarg1, byte[] jarg2);
+  public final static native int ftdi_read_eeprom(long jarg1, byte[] jarg2);
+  public final static native int ftdi_write_eeprom(long jarg1, byte[] jarg2);
+  public final static native int ftdi_erase_eeprom(long jarg1);
+}
index ea3401b..ae5efb6 100644 (file)
@@ -59,7 +59,6 @@ int ftdi_read_pins(struct ftdi_context *ftdi, signed char pins[]);
 
 int ftdi_setflowctrl(struct ftdi_context *ftdi, int flowctrl);
 
-
 int ftdi_set_latency_timer(struct ftdi_context *ftdi, unsigned char latency);
 int ftdi_get_latency_timer(struct ftdi_context *ftdi, unsigned char *latency);
 
index 6f2ff6d..24e2976 100644 (file)
@@ -34,7 +34,7 @@ public class AtmelSerial {
     public static void main(String[] s) throws Exception {
       //AvrDrone device = new AvrDrone(detectObitsPort());
         //AvrDrone device = new AvrDrone();
-        AvrDrone device = Demo.main2();
+        AvrDrone device = new AvrDrone(new FtdiBoard());
         At40k at40k = new At40k.At40k10(device);
         try {
             long begin = System.currentTimeMillis();
@@ -494,7 +494,15 @@ public class AtmelSerial {
             at40k.cell(6,13).yo(false);
             at40k.cell(7,12).xi(SE);
 
-            /*
+            for(int i=0; i<24; i++) {
+                at40k.iob_bot(i, true).enableOutput(NORTH);
+                at40k.iob_bot(i, false).enableOutput(NW);
+                at40k.cell(i, 0).xlut(0xff);
+                at40k.cell(i, 0).ylut(0xff);
+            }
+
+            device.flush();
+
             Gui vis = new Gui(at40k, device);
             Frame fr = new Frame();
             fr.addKeyListener(vis);
@@ -506,12 +514,14 @@ public class AtmelSerial {
             fr.repaint();
             fr.show();
             synchronized(AtmelSerial.class) { AtmelSerial.class.wait(); }
-            */
+
+
 
             Visualizer v = new Visualizer(at40k, device);
             v.show();
             v.setSize(1380, 1080);
             At40k.Cell cell = at40k.cell(4, 23);
+
             Image img = v.createImage(v.getWidth(), v.getHeight());
             /*
             int x = 1;
@@ -779,6 +789,7 @@ public class AtmelSerial {
                     cell.xlut(0xff);
                     cell.ylut(0xff);
                     drawCell(getGraphics(), selx, sely);
+                    drone.flush();
                     break;
                 }
                 case 'i': {
@@ -890,6 +901,7 @@ public class AtmelSerial {
                     cell.xlut(0x00);
                     cell.ylut(0x00);
                     drawCell(getGraphics(), selx, sely);
+                    drone.flush();
                     break;
                 }
             } 
diff --git a/src/edu/berkeley/obits/device/atmel/AT94k.java b/src/edu/berkeley/obits/device/atmel/AT94k.java
deleted file mode 100644 (file)
index e69de29..0000000
index cd50147..31f1e62 100644 (file)
@@ -9,40 +9,21 @@ import gnu.io.*;
 /** the "host" side of the AVR Drone; see AvrDrone.c for the other side */
 public class AvrDrone extends AtmelDevice {
 
-    final DataInputStream in;
-
-    final DataOutputStream out;
-
-    final SerialPort sp;
-    final boolean isFake;
-
-    public AvrDrone() { sp = null; in = null; out = null; isFake = true; } 
-
-    public AvrDrone(InputStream is, OutputStream os) throws IOException {
-        this.out = new DataOutputStream(os);
-        this.in = new DataInputStream(is);
-        this.sp = null;
-        isFake = false;
+    private final DataInputStream in;
+    private final DataOutputStream out;
+    private final Board board;
+
+    public AvrDrone(Board b) throws IOException {
+        this.board = b;
+        this.out = new DataOutputStream(b.getOutputStream());
+        this.in = new DataInputStream(b.getInputStream());
         init();
     } 
-    
-    public AvrDrone(SerialPort sp) throws IOException, UnsupportedCommOperationException, InterruptedException, DeviceException {
-        this.sp = sp;
-        //sp.setSerialPortParams(115200, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
-        sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
-        sp.setFlowControlMode(sp.FLOWCONTROL_RTSCTS_OUT);
-        sp.setInputBufferSize(1024);
-        //sp.setFlowControlMode(sp.FLOWCONTROL_NONE);
-        this.out = new DataOutputStream(sp.getOutputStream());
-        this.in = new DataInputStream(sp.getInputStream());
-        Log.debug(this, "consuming any leftover data on the serial port");
-        while(in.available() > 0) in.read();
-        reset();
-        isFake = false;
-        init();
-    }
+
+    public void reset() { board.reset(); }
 
     private void init() throws IOException {
+        //board.reset();
         Log.debug(this, "waiting for device to identify itself");
         if (in.readByte() != (byte)'O')  throw new RuntimeException("didn't get the proper signature");
         if (in.readByte() != (byte)'B')  throw new RuntimeException("didn't get the proper signature");
@@ -54,7 +35,6 @@ public class AvrDrone extends AtmelDevice {
     }
 
     public synchronized void scanFPGA(boolean on) throws DeviceException {
-        if (isFake) return;
         try {
             if (on) {
                 out.writeByte(3);
@@ -67,7 +47,6 @@ public class AvrDrone extends AtmelDevice {
     // fixme!
     public static int retval = 0;
     public synchronized int readCount() throws DeviceException {
-        if (isFake) return 0;
         try {
             if (reader != null) {
                 reader.start();
@@ -104,7 +83,7 @@ public class AvrDrone extends AtmelDevice {
                 System.out.println("*** reader thread begun");
                 while(true) {
                     try {
-                        byte b = isFake ? 0 : in.readByte();
+                        byte b = in.readByte();
                         ByteCallback bc = (ByteCallback)callbacks.remove(0);
                         bc.call(b);
                     } catch (Exception e) {
@@ -117,10 +96,8 @@ public class AvrDrone extends AtmelDevice {
     public synchronized void readBus(ByteCallback bc) throws DeviceException {
         try {
             callbacks.add(bc);
-            if (!isFake) {
-                out.writeByte(2);
-                out.flush();
-            }
+            out.writeByte(2);
+            out.flush();
             if (reader != null) {
                 reader.start();
                 reader = null;
@@ -131,10 +108,8 @@ public class AvrDrone extends AtmelDevice {
     public synchronized void readInterrupts(ByteCallback bc) throws DeviceException {
         try {
             callbacks.add(bc);
-            if (!isFake) {
-                out.writeByte(6);
-                out.flush();
-            }
+            out.writeByte(6);
+            out.flush();
             if (reader != null) {
                 reader.start();
                 reader = null;
@@ -142,22 +117,8 @@ public class AvrDrone extends AtmelDevice {
         } catch (IOException e) { throw new DeviceException(e); }
     }
 
-    public synchronized void reset() throws DeviceException {
-        if (sp==null) return;
-        try {
-            Log.info(this, "resetting device");
-            sp.setDTR(true);
-            sp.setRTS(true);
-            Thread.sleep(500);
-            Log.info(this, "deasserting reset signal");
-            sp.setDTR(false);
-            sp.setRTS(false);
-            Thread.sleep(100);
-        } catch (InterruptedException e) { throw new DeviceException(e); }
-    }
-
     private byte[][][] cache = new byte[24][][];
-    public synchronized byte mode4(int z, int y, int x) throws DeviceException {
+    public /*synchronized*/ byte mode4(int z, int y, int x) throws DeviceException {
         if (cache[x]==null) return 0;
         if (cache[x][y]==null) return 0;
         return cache[x][y][z];
@@ -168,7 +129,7 @@ public class AvrDrone extends AtmelDevice {
     int lasty = 0;
     public static int save = 0;
     public static int saveof = 0;
-    public synchronized void mode4(int z, int y, int x, int d) throws DeviceException {
+    public /*synchronized*/ void mode4(int z, int y, int x, int d) throws DeviceException {
         try {
             /*
             Log.info(this, "writing configuration frame [zyxd]: " +
@@ -188,35 +149,23 @@ public class AvrDrone extends AtmelDevice {
             boolean ydec    = y==lasty-1;
             boolean xdec    = x==lastx-1;
             
-            //System.out.println(zchange + " " + ychange + " " + xchange);
-            if (!isFake) {
-                /*
-                out.writeByte(0x80
-                              | (zinc?0x40:zdec?0x04:zchange?0x44:0x00)
-                              | (yinc?0x20:ydec?0x02:ychange?0x22:0x00)
-                              | (xinc?0x10:xdec?0x01:xchange?0x11:0x00));
-                if (!zinc && !zdec && zchange) out.writeByte(z); else save++;
-                if (!yinc && !ydec && ychange) out.writeByte(y); else save++;
-                if (!xinc && !xdec && xchange) out.writeByte(x); else save++;
-                */
-                out.writeByte(1);
-                out.writeByte(z);
-                out.writeByte(y);
-                out.writeByte(x);
-                saveof++;
-                lastz = z;
-                lastx = x;
-                lasty = y;
-                out.writeByte(d);
-            }
+            out.writeByte(1);
+            out.writeByte(z);
+            out.writeByte(y);
+            out.writeByte(x);
+            saveof++;
+            lastz = z;
+            lastx = x;
+            lasty = y;
+            out.writeByte(d);
+
             if (cache[x & 0xff]==null) cache[x & 0xff] = new byte[24][];
             if (cache[x & 0xff][y & 0xff]==null) cache[x & 0xff][y & 0xff] = new byte[256];
             cache[x & 0xff][y & 0xff][z & 0xff] = (byte)(d & 0xff);
         } catch (IOException e) { throw new DeviceException(e); }
     }
 
-    public synchronized void flush() throws DeviceException {
-        if (isFake) return;
+    public /*synchronized*/ void flush() throws DeviceException {
         try {
             out.flush();
         } catch (IOException e) { throw new DeviceException(e); }
diff --git a/src/edu/berkeley/obits/device/atmel/Board.java b/src/edu/berkeley/obits/device/atmel/Board.java
new file mode 100644 (file)
index 0000000..e4eb60b
--- /dev/null
@@ -0,0 +1,16 @@
+package edu.berkeley.obits.device.atmel;
+
+import edu.berkeley.obits.*;
+import org.ibex.util.Log;
+import java.io.*;
+import java.util.*;
+import gnu.io.*;
+
+public abstract class Board {
+
+    public abstract void reset();
+    public abstract void boot(Reader r) throws Exception;
+    public abstract InputStream getInputStream();
+    public abstract OutputStream getOutputStream();
+
+}
index d6db1c5..9a91137 100644 (file)
@@ -34,6 +34,6 @@ public abstract class Chip {
     //remove
     public abstract void buffered();
     public abstract void buffered(boolean buf);
-    public abstract void flush();
+    protected abstract void flush();
     public abstract int readPins();
 }
index bea2fc4..d86f73f 100644 (file)
@@ -41,8 +41,8 @@ public class ChipImpl extends Chip {
         if (result != 0)
             throw new RuntimeException("ftdi_usb_open() returned " + result);
 
-        //result = example.ftdi_set_baudrate(context, 750 * 1000);
         result = example.ftdi_set_baudrate(context, 750 * 1000);
+        //result = example.ftdi_set_baudrate(context, 1000 * 1000);
         if (result != 0)
             throw new RuntimeException("ftdi_set_baudrate() returned " + result);
         result = example.ftdi_set_line_property(context, 8, 0, 0);
@@ -52,7 +52,7 @@ public class ChipImpl extends Chip {
         doReset();
     }
 
-    public int readPins() {
+    public synchronized int readPins() {
         byte[] b = new byte[1];
         int result = example.ftdi_read_pins(context, b);
         if (result != 0)
@@ -60,27 +60,21 @@ public class ChipImpl extends Chip {
         return b[0];
     }
 
-    public void write(int out) {
-        byte[] b = new byte[1];
-        int result = 0;
-        b[0] = (byte)out;
-        while(result==0)
-            result = example.ftdi_write_data(context, b, 1);
-    }
-
     private OutputStream os = new ChipOutputStream();
     private InputStream  is = new ChipInputStream();
 
     public OutputStream getOutputStream() {
-        //example.ftdi_write_data_set_chunksize(context, 32);
         return os;
     }
-    public InputStream  getInputStream() { return is; }
+    public InputStream  getInputStream() {
+        //example.ftdi_read_data_set_chunksize(context, 32);
+        return is;
+    }
 
     public class ChipInputStream extends InputStream {
         public int available() throws IOException {
             // FIXME
-            return 1;
+            return 0;
         }
         public long skip(long l) throws IOException {
             throw new RuntimeException("not supported");
@@ -96,23 +90,21 @@ public class ChipImpl extends Chip {
             return b[0] & 0xff;
         }
         public int read(byte[] b, int off, int len) throws IOException {
-            System.out.println("read("+off+","+len+")");
             // FIXME: blocking reads?
             int result = 0;
             while(true) {
                 if (len==0) return 0;
-                synchronized(ChipImpl.this) {
                     byte[] b0 = new byte[len];
-                    result = example.ftdi_read_data(context, b0, len);
+                    synchronized(ChipImpl.this) {
+                        result = example.ftdi_read_data(context, b0, len);
+                    }
                     if (result == -1)
                         throw new IOException("ftdi_read_pins() returned " + result);
                     if (result>0) {
                         System.arraycopy(b0, 0, b, off, result);
-                        System.out.println("  return " + result);
                         return result;
                     }
-                }
-                Thread.yield();
+                try { Thread.sleep(50); } catch (Exception e) { e.printStackTrace(); } 
             }
         }
     }
@@ -138,18 +130,8 @@ public class ChipImpl extends Chip {
         }
     }
 
-    public int read() {
-        byte[] b = new byte[1];
-        int result = 0;
-        while(result==0)
-            result = example.ftdi_read_data(context, b, 1);
-        if (result != 1)
-            throw new RuntimeException("ftdi_read_pins() returned " + result);
-        return (b[0] & 0xff);
-    }
-
     ByteArrayOutputStream baos = new ByteArrayOutputStream();
-    public void flush() {
+    protected void flush() {
         byte[] bytes = baos.toByteArray();
         baos = new ByteArrayOutputStream();
         dbang(bytes, bytes.length);
@@ -230,34 +212,39 @@ public class ChipImpl extends Chip {
         (1<<6) |
         (1<<7);
 
-    public void purge() {
+    public synchronized void purge() {
         example.ftdi_usb_purge_buffers(context);
+
+        int result = example.ftdi_setflowctrl(context, (1 << 8));
+        if (result != 0)
+            throw new RuntimeException("ftdi_setflowcontrol() returned " +
+                                       result);
     }
-    public void uart() {
+    public synchronized void uart() {
         int result = example.ftdi_set_bitmode(context, (short)0, (short)0x00);
         if (result != 0)
             throw new RuntimeException("ftdi_set_bitmode() returned " + result);
 
-        result = example.ftdi_setflowctrl(context, 1 << 8);
+        result = example.ftdi_setflowctrl(context, (1 << 8));
         if (result != 0)
             throw new RuntimeException("ftdi_setflowcontrol() returned " +
                                        result);
 
     }
-    public void dbangmode() {
+    public synchronized void dbangmode() {
         int result = example.ftdi_set_bitmode(context, (short)dmask, (short)0x01);
         if (result != 0)
             throw new RuntimeException("ftdi_set_bitmode() returned " + result);
     }
 
-    private void cbangmode() {
+    private synchronized void cbangmode() {
         int result = example.ftdi_set_bitmode(context, (short)((mask << 4) | bits), (short)0x20);
         if (result != 0)
             throw new RuntimeException("ftdi_set_bitmode() returned " + result);
     }
 
     private int dbits = 0;
-    private void dbang(int bit, boolean val) {
+    private synchronized void dbang(int bit, boolean val) {
         dbits = val ? (dbits | (1 << bit)) : (dbits & (~(1 << bit)));
         if (buffered) {
             baos.write((byte)dbits);
@@ -266,7 +253,7 @@ public class ChipImpl extends Chip {
         }
     }
     int write = 0;
-    private void dbang(byte by) {
+    private synchronized void dbang(byte by) {
         byte[] b = new byte[1];
         b[0] = by;
         int result = example.ftdi_write_data(context, b, 1);
@@ -274,7 +261,7 @@ public class ChipImpl extends Chip {
             throw new RuntimeException("ftdi_write_data() returned " + result);
     }
     int queued = 0;
-    private void dbang(byte[] b, int len) {
+    private synchronized void dbang(byte[] b, int len) {
         example.ftdi_write_data(context, b, len);
     }
 }
diff --git a/src/edu/berkeley/obits/device/atmel/FakeBoard.java b/src/edu/berkeley/obits/device/atmel/FakeBoard.java
new file mode 100644 (file)
index 0000000..e29c5fb
--- /dev/null
@@ -0,0 +1,18 @@
+package edu.berkeley.obits.device.atmel;
+
+import edu.berkeley.obits.*;
+import org.ibex.util.Log;
+import java.io.*;
+import java.util.*;
+import gnu.io.*;
+
+public class FakeBoard extends Board {
+
+    public FakeBoard() { }
+
+    public void reset() { }
+    public void boot(Reader r) throws Exception { throw new Error(); }
+    public InputStream getInputStream() { throw new Error(); }
+    public OutputStream getOutputStream() { throw new Error(); }
+
+}
 package edu.berkeley.obits.device.atmel;
-import com.ftdi.usb.*;
+
+import edu.berkeley.obits.*;
+import org.ibex.util.Log;
 import java.io.*;
+import java.util.*;
+import gnu.io.*;
 
-public class Demo {
+public class FtdiBoard extends Board {
 
     static {
         System.load(new File("build/"+System.mapLibraryName("Ftdi")).getAbsolutePath());
     }
 
-    public static void main(String[] args) throws Exception {
-        main2();
-    }
+    private final ChipImpl chip;
+    private final InputStream in;
+    private final OutputStream out;
 
-    public static AvrDrone main2() throws Exception {
-        Chip d = new ChipImpl();
-        boolean pin;
-        /*
-        doConfig(d, new InputStreamReader(new FileInputStream("e6-off.bst")));
-        pin = (d.readPins() & 0x2) != 0;
-        System.out.println("e6-off => " + pin + " " + (pin ? red("BAD") : green("good")));
-
-        doConfig(d, new InputStreamReader(new FileInputStream("e6-on.bst")));
-        pin = (d.readPins() & 0x2) != 0;
-        System.out.println("e6-on  => " + pin + " " + (pin ? green("good") : red("BAD")));
-        */
-
-        d.porte(4, true);
-
-        doConfig(d, new InputStreamReader(new FileInputStream("bitstreams/usbdrone.bst")));
-        System.out.println("       pins: " + pad(Integer.toString(d.readPins()&0xff,2),8));
-
-        //try { Thread.sleep(1000); } catch (Exception e) { }        
-        //((ChipImpl)d).dbangmode();
-
-        ChipImpl ci = (ChipImpl)d;
-        final InputStream is = new BufferedInputStream(ci.getInputStream());
-        final OutputStream os = new BufferedOutputStream(ci.getOutputStream());
-        int oldre=-1;
-
-        /*
-        new Thread() {
-            public void run() {
-                try {
-                    while(true) {
-                        for(int i=0; i<256; i++) {
-                            os.write(i);
-                        }
-                        os.flush();
-                    }
-                } catch (Exception e) {
-                    e.printStackTrace();
-                }
-            }
-        }.start();
-        */
-        for(int i=0; i<255; i++) {
-            os.write(0);
-        }
-        os.flush();
+    public InputStream getInputStream() { return in; }
+    public OutputStream getOutputStream() { return out; }
 
-        return new AvrDrone(is, os);
-        /*
-        while(true) {
-            //d.porte(4, true);
-            //try { Thread.sleep(1000); } catch (Exception e) { }
-            //System.out.println("char: " + d.readChar());
-
-            //System.out.println("e4=on  pins: " + pad(Integer.toString(d.readPins()&0xff,2),8));
-
-
-            int inc = 256;
-            for(int k=0; k<256; k += inc) {
-
-            //for(int i=k; i<k+inc; i++) {
-            //os.write(i);
-            //}
-            //os.flush();
-
-                for(int i=0; i<inc; i++) {
-                    int re = -1;
-                    while(re == -1) {
-                        re = is.read();
-                        if (re != -1) {
-                            System.out.print(((oldre == -1) || (re==((oldre+1)%256))) ? "... " : "BAD ");
-                            System.out.println(" read " + re);
-                            oldre = re;
-                        }
-                    }
-                }
-            }
+    public FtdiBoard() throws Exception {
+        chip = new ChipImpl();
+        chip.porte(4, true);
 
-            
-            //System.out.println("e4=on  pins: " + ((ChipImpl)d).readChar());
+        boot(new InputStreamReader(new FileInputStream("bitstreams/usbdrone.bst")));
+        System.out.println("       pins: " + pad(Integer.toString(chip.readPins()&0xff,2),8));
 
+        in = new BufferedInputStream(chip.getInputStream());
+        out = new BufferedOutputStream(chip.getOutputStream());
+        for(int i=0; i<255; i++) out.write(0);
+        out.flush();
+    }
 
-            //d.porte(4, false);
-            //try { Thread.sleep(1000); } catch (Exception e) { }
-            //d.readPins();
-            //System.out.println("e4=off pins: " + pad(Integer.toString(d.readPins()&0xff,2),8));
-            */
+    public void reset() {
+        chip.doReset();
     }
 
-    public static void doConfig(Chip d, Reader r) throws Exception {
+    public void boot(Reader r) throws Exception {
         boolean pin;
-
+        Chip d = chip;
         d.doReset();
         d.config(0,10);
         d.con();
@@ -183,23 +118,18 @@ public class Demo {
         //((ChipImpl)d).avr();
 
         //System.out.println("avr reset => true");
-        ((ChipImpl)d).uart();
-        ((ChipImpl)d).purge();
-
+        chip.uart();
+        chip.purge();
+        
         //d.avrrst(true);
         //try { Thread.sleep(500); } catch (Exception e) { }
         //System.out.println("cts="+""+"  pins=" + pad(Integer.toString(d.readPins()&0xff,2),8));
-
-
     }
+
     public static String pad(String s, int i) {
         if (s.length() >= i) return s;
         return "0"+pad(s, i-1);
     }
-
-
-
     public static String red(Object o) { return "\033[31m"+o+"\033[0m"; }
     public static String green(Object o) { return "\033[32m"+o+"\033[0m"; }
 }
-
diff --git a/src/edu/berkeley/obits/device/atmel/SerialBoard.java b/src/edu/berkeley/obits/device/atmel/SerialBoard.java
new file mode 100644 (file)
index 0000000..608dcac
--- /dev/null
@@ -0,0 +1,46 @@
+package edu.berkeley.obits.device.atmel;
+
+import edu.berkeley.obits.*;
+import org.ibex.util.Log;
+import java.io.*;
+import java.util.*;
+import gnu.io.*;
+
+public class SerialBoard extends Board {
+
+    private final SerialPort sp;
+    private final DataInputStream in;
+    private final DataOutputStream out;
+
+    public SerialBoard(SerialPort sp) throws IOException, UnsupportedCommOperationException, InterruptedException {
+        this.sp = sp;
+        sp.setSerialPortParams(38400, SerialPort.DATABITS_8, SerialPort.STOPBITS_1, SerialPort.PARITY_NONE);
+        sp.setFlowControlMode(sp.FLOWCONTROL_RTSCTS_OUT);
+        sp.setInputBufferSize(1024);
+        this.out = new DataOutputStream(sp.getOutputStream());
+        this.in = new DataInputStream(sp.getInputStream());
+        Log.debug(this, "consuming any leftover data on the serial port");
+        while(in.available() > 0) in.read();
+        reset();
+    }
+
+    public void reset() {
+        try {
+            Log.info(this, "resetting device");
+            sp.setDTR(true);
+            sp.setRTS(true);
+            Thread.sleep(500);
+            Log.info(this, "deasserting reset signal");
+            sp.setDTR(false);
+            sp.setRTS(false);
+            Thread.sleep(100);
+        } catch (InterruptedException e) { throw new RuntimeException(e); }
+    }
+
+    public void boot(Reader r) throws Exception {
+        throw new Error("not implemented");
+    }
+
+    public InputStream getInputStream() { return in; }
+    public OutputStream getOutputStream() { return out; }
+}
diff --git a/src/edu/berkeley/obits/device/atmel/Wires.java b/src/edu/berkeley/obits/device/atmel/Wires.java
deleted file mode 100644 (file)
index 283d929..0000000
+++ /dev/null
@@ -1,24 +0,0 @@
-package edu.berkeley.obits.device.atmel;
-
-import edu.berkeley.obits.*;
-
-public enum Wires {
-
-    NW, SW, NE, SE,
-
-    N, S, E, W,
-
-    CM,
-
-    XL, YL,
-
-    C, R,
-
-    F,
-    BO,
-
-    XO, YO,
-
-    L0, L1, L2, L3, L4;
-
-}
index 374d54c..394ca7d 100644 (file)
@@ -62,6 +62,8 @@ public class Gui extends ZoomingPanel implements KeyListener, MouseMotionListene
         for(int x=7; x<17; x++)
             for(int y=7; y<17; y++)
                 new Cell(x-7,y-7, at40k.cell(x, y));
+
+        scan();
         /*
         At40k.Cell c = at40k.cell(0,0);
         for(int i=0; i<256; i++) {
@@ -704,16 +706,15 @@ public class Gui extends ZoomingPanel implements KeyListener, MouseMotionListene
     }
 
     public void mouseClicked(MouseEvent e) {
-        System.out.println("click");
         final Cell c = whichCell(e.getX(), e.getY());
         if (c==null) return;
-        System.out.println("click at " + c._x + "," + c._y);
         scan(c);
     }
 
     public void scan() {
-        for(int x=0; x<ca.length; x++)
-            for(int y=0; y<ca[x].length; y++)
+        System.out.println("scan");
+        for(int x=2; x<6; x++)
+            for(int y=2; y<6; y++)
                 if (ca[x][y] != null)
                     scan(ca[x][y]);
     }
@@ -747,10 +748,16 @@ public class Gui extends ZoomingPanel implements KeyListener, MouseMotionListene
         AtmelSerial.scan(at40k, cell, NONE, false);
     }
 
+
+    int made = 0;
     private class BCB implements AvrDrone.ByteCallback {
         Gui.Cell c;
         int who;
-        public BCB(Gui.Cell c, int who) { this.who = who; this.c = c; }
+        public BCB(Gui.Cell c, int who) {
+            this.who = who; this.c = c;
+            made++;
+            System.out.println("made="+made);
+        }
         public void call(byte b) throws Exception {
             System.out.println("callback: " + b);
             boolean on = (b & 0x80) != 0;
@@ -768,6 +775,9 @@ public class Gui extends ZoomingPanel implements KeyListener, MouseMotionListene
                     repaint();
                     break;
             }
+            made--;
+            System.out.println("made="+made);
+            if (made==0) scan();
         }
     }