- for(int i=7; i>=0; i--) {
- d.config((((in & 0xff) & (1<<i))!=0)?1:0, 1);
- boolean init = true; // d.initErr()
- if (bytes < 100 || (bytes % 1000)==0) {
- d.flush();
- init = d.initErr();
- System.out.print("wrote " + bytes + " bytes, init="+init+" \r");
- d.rcon();
- }
- if (!init)
- throw new RuntimeException("initialization failed at byte " + bytes + ", bit " + i);
+ os.write((byte)Integer.parseInt(s, 2));
+ if ((bytes % 1000)==0) os.flush();
+ }
+ os.close();
+ }
+
+
+ // AvrDrone leftovers //////////////////////////////////////////////////////////////////////////////
+
+ private void init() throws IOException {
+ byte[] bytes = new byte[6];
+ int i=0;
+
+ out.write(0);
+ out.flush();
+
+ // read any crap that might be left in the buffer
+ while(true) {
+ System.arraycopy(bytes, 1, bytes, 0, 5);
+ bytes[5] = in.readByte();
+ i++;
+ System.out.print("\rsignature: read \"" + new String(bytes) + "\" ");
+ if (bytes[0] == (byte)'O' &&
+ bytes[1] == (byte)'B' &&
+ bytes[2] == (byte)'I' &&
+ bytes[3] == (byte)'T' &&
+ bytes[4] == (byte)'S') {
+ System.out.println("\rsignature: got proper signature ");
+ break;