Program: 35954
Project: 35954
Buggy source:
/** 
 * Called repetitively while the IOIO is connected. Reads and writes to the IBus
 * @throws ConnectionLostException When IOIO connection is lost.
 * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
 */
@Override public void loop() throws ConnectionLostException, InterruptedException {
  statusLED.write(true);
  if ((Calendar.getInstance().getTimeInMillis() - lastRead) > 30) {
    readBuffer.clear();
  }
  if (!callbackRegistered && mIBusCbListener != null)   initiateHandlers();
  try {
    if (busIn.available() > 0) {
      lastRead=Calendar.getInstance().getTimeInMillis();
      readBuffer.add((byte)busIn.read());
      if (readBuffer.size() == 1) {
        msgLength=256;
      }
 else       if (readBuffer.size() == 2) {
        msgLength=(int)readBuffer.get(1);
      }
      if (readBuffer.size() == msgLength + 2) {
        if (checksumMessage(readBuffer)) {
          String data="String_Node_Str";
          for (int i=0; i < readBuffer.size(); i++)           data=String.format("String_Node_Str",data,readBuffer.get(i));
          Log.d(TAG,String.format("String_Node_Str",DeviceLookup.get(readBuffer.get(0)),DeviceLookup.get(readBuffer.get(2)),data));
          handleMessage(readBuffer);
        }
        readBuffer.clear();
      }
    }
 else     if (actionQueue.size() > 0) {
      if ((Calendar.getInstance().getTimeInMillis() - lastSend) > 75) {
        Log.d(TAG,String.format("String_Node_Str",actionQueue.get(0).toString()));
        IBusMethodHolder command=IBusCommandMap.get(actionQueue.get(0));
        byte[] outboundMsg=new byte[]{};
        try {
          outboundMsg=(byte[])command.methodReference.invoke(command.classInstance,command.args);
        }
 catch (        IllegalAccessException e) {
          e.printStackTrace();
        }
catch (        IllegalArgumentException e) {
          e.printStackTrace();
        }
catch (        InvocationTargetException e) {
          e.printStackTrace();
        }
        actionQueue.remove(0);
        String out="String_Node_Str";
        for (int i=0; i < outboundMsg.length; i++) {
          out=String.format("String_Node_Str",out,outboundMsg[i]);
          busOut.write(outboundMsg[i]);
        }
        Log.d(TAG,out);
        lastSend=Calendar.getInstance().getTimeInMillis();
      }
    }
  }
 catch (  IOException e) {
    Log.e(TAG,String.format("String_Node_Str",e.getMessage()));
  }
  statusLED.write(false);
  Thread.sleep(2);
}

Fixed version (ground truth):
/** 
 * Called repetitively while the IOIO is connected. Reads and writes to the IBus
 * @throws ConnectionLostException When IOIO connection is lost.
 * @see ioio.lib.util.AbstractIOIOActivity.IOIOThread#loop()
 */
@Override public void loop() throws ConnectionLostException, InterruptedException {
  statusLED.write(true);
  if ((Calendar.getInstance().getTimeInMillis() - lastRead) > 30) {
    readBuffer.clear();
  }
  if (!callbackRegistered && mIBusCbListener != null)   initiateHandlers();
  try {
    if (busIn.available() > 0) {
      lastRead=Calendar.getInstance().getTimeInMillis();
      readBuffer.add((byte)busIn.read());
      if (readBuffer.size() == 1) {
        msgLength=256;
      }
 else       if (readBuffer.size() == 2) {
        msgLength=(int)readBuffer.get(1);
      }
      if (readBuffer.size() == msgLength + 2) {
        if (checksumMessage(readBuffer)) {
          String data="String_Node_Str";
          for (int i=0; i < readBuffer.size(); i++)           data=String.format("String_Node_Str",data,readBuffer.get(i));
          Log.d(TAG,String.format("String_Node_Str",DeviceLookup.get(readBuffer.get(0)),DeviceLookup.get(readBuffer.get(2)),data));
          handleMessage(readBuffer);
        }
        readBuffer.clear();
      }
    }
 else     if (actionQueue.size() > 0) {
      if ((Calendar.getInstance().getTimeInMillis() - lastSend) > 75) {
        Log.d(TAG,String.format("String_Node_Str",actionQueue.get(0).toString()));
        IBusMethodHolder command=IBusCommandMap.get(actionQueue.get(0));
        byte[] outboundMsg=new byte[]{};
        try {
          outboundMsg=(byte[])command.methodReference.invoke(command.classInstance);
        }
 catch (        IllegalAccessException e) {
          e.printStackTrace();
        }
catch (        IllegalArgumentException e) {
          e.printStackTrace();
        }
catch (        InvocationTargetException e) {
          e.printStackTrace();
        }
        actionQueue.remove(0);
        String out="String_Node_Str";
        for (int i=0; i < outboundMsg.length; i++) {
          out=String.format("String_Node_Str",out,outboundMsg[i]);
          busOut.write(outboundMsg[i]);
        }
        Log.d(TAG,out);
        lastSend=Calendar.getInstance().getTimeInMillis();
      }
    }
  }
 catch (  IOException e) {
    Log.e(TAG,String.format("String_Node_Str",e.getMessage()));
  }
  statusLED.write(false);
  Thread.sleep(2);
}