Program: 35949
Project: 35949
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 {
  if ((Calendar.getInstance().getTimeInMillis() - lastRead) > 30) {
    readBuffer.clear();
  }
  if (!callbackRegistered && mIBusCbListener != null)   initiateHandlers();
  try {
    if (busIn.available() > 0) {
      statusLED.write(true);
      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();
      }
      statusLED.write(false);
    }
 else     if (actionQueue.size() > 0) {
      statusLED.write(true);
      if ((Calendar.getInstance().getTimeInMillis() - lastSend) > 75) {
        Log.d(TAG,String.format("String_Node_Str",actionQueue.get(0).toString()));
        IBusCommandsEnum command=actionQueue.get(0).commandType;
        IBusSystemCommand clsInstance=IBusSysMap.get(command.getSystem().toByte());
        Object cmdArgs=actionQueue.get(0).commandArgs;
        byte[] outboundMsg=new byte[]{};
        try {
          Method requestedMethod=clsInstance.getClass().getMethod(command.getMethodName());
          if (cmdArgs == null)           outboundMsg=(byte[])requestedMethod.invoke(clsInstance);
 else           outboundMsg=(byte[])requestedMethod.invoke(clsInstance,cmdArgs);
        }
 catch (        IllegalAccessException e) {
          e.printStackTrace();
        }
catch (        IllegalArgumentException e) {
          e.printStackTrace();
        }
catch (        InvocationTargetException e) {
          e.printStackTrace();
        }
catch (        NoSuchMethodException 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();
        statusLED.write(false);
      }
    }
  }
 catch (  IOException e) {
    Log.e(TAG,String.format("String_Node_Str",e.getMessage()));
  }
  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 {
  if ((Calendar.getInstance().getTimeInMillis() - lastRead) > 30) {
    readBuffer.clear();
  }
  if (!callbackRegistered && mIBusCbListener != null)   initiateHandlers();
  try {
    if (busIn.available() > 0) {
      statusLED.write(true);
      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();
      }
      statusLED.write(false);
    }
 else     if (actionQueue.size() > 0) {
      statusLED.write(true);
      if ((Calendar.getInstance().getTimeInMillis() - lastSend) > 75) {
        Log.d(TAG,String.format("String_Node_Str",actionQueue.get(0).toString()));
        IBusCommandsEnum command=actionQueue.get(0).commandType;
        IBusSystemCommand clsInstance=IBusSysMap.get(command.getSystem().toByte());
        Object cmdArgs=actionQueue.get(0).commandArgs;
        byte[] outboundMsg=new byte[]{};
        try {
          Method requestedMethod=clsInstance.getClass().getMethod(command.getMethodName());
          if (cmdArgs == null)           outboundMsg=(byte[])requestedMethod.invoke(clsInstance);
 else           outboundMsg=(byte[])requestedMethod.invoke(clsInstance,cmdArgs);
        }
 catch (        IllegalAccessException e) {
          e.printStackTrace();
        }
catch (        IllegalArgumentException e) {
          e.printStackTrace();
        }
catch (        InvocationTargetException e) {
          e.printStackTrace();
        }
catch (        NoSuchMethodException 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();
      }
      statusLED.write(false);
    }
  }
 catch (  IOException e) {
    Log.e(TAG,String.format("String_Node_Str",e.getMessage()));
  }
  Thread.sleep(2);
}