checkpoint
authoradam <adam@megacz.com>
Mon, 11 Sep 2006 13:37:44 +0000 (14:37 +0100)
committeradam <adam@megacz.com>
Mon, 11 Sep 2006 13:37:44 +0000 (14:37 +0100)
src/edu/berkeley/obits/device/atmel/ChipImpl.java
src/edu/berkeley/obits/device/atmel/FtdiChip.java

index 677bf5f..5cb10ec 100644 (file)
@@ -40,8 +40,6 @@ public class ChipImpl extends FtdiChip implements Chip {
 
     //
 
-    public void buffered() { buffered = true; }
-    public void buffered(boolean buf) { buffered = buf; }
     public void config(boolean bit) { config(bit?1:0, 1); }
     public void config(int dat) { config(dat, 8); }
     public void config(int dat, int numbits) {
index 94d860f..20f4a2a 100644 (file)
@@ -34,7 +34,6 @@ public class FtdiChip {
         } catch (IOException e) { throw new RuntimeException(e); }
     }
 
-    public boolean buffered = false;
     protected static int mask =
         (1<<0) |
         (1<<1)// |
@@ -54,16 +53,17 @@ public class FtdiChip {
     }
 
     protected int dbits = 0;
+
+    public boolean buffered = false;
+    public void buffered() { buffered = true; }
+    public void buffered(boolean buf) { buffered = buf; }
+
     protected synchronized void dbang(int bit, boolean val) {
         dbits = val ? (dbits | (1 << bit)) : (dbits & (~(1 << bit)));
-        if (buffered) {
-            baos.write((byte)dbits);
-        } else {
-            try {
-                out.write((byte)dbits);
-                out.flush();
-            } catch (IOException e) { throw new RuntimeException(e); }
-        }
+        try {
+            out.write((byte)dbits);
+            if (!buffered) out.flush();
+        } catch (IOException e) { throw new RuntimeException(e); }
     }