protected int sendMedtronicPumpCommand(byte command,byte repeat,byte[] postCommand){
  try {
    if (idPump != null && idPump.length > 0) {
      int pCLength=0;
      if (postCommand != null)       pCLength=postCommand.length;
      byte[] readSystemTime=new byte[6 + idPump.length + pCLength];
      int i=0;
      int size=2 + idPump.length + pCLength+ 1;
      byte[] sizByte=HexDump.hexStringToByteArray(HexDump.toHexString(size));
      log.debug("sizByte " + HexDump.toHexString(sizByte));
      readSystemTime[0]=(byte)0x81;
      readSystemTime[1]=(byte)sizByte[sizByte.length - 1];
      readSystemTime[2]=repeat;
      readSystemTime[3]=(byte)MedtronicConstants.MEDTRONIC_PUMP;
      for (i=0; i < idPump.length; i++)       readSystemTime[i + 4]=(byte)idPump[i];
      readSystemTime[idPump.length + 4]=command;
      log.debug("postcommadnLength ");
      for (i=0; i < postCommand.length; i++)       readSystemTime[idPump.length + 5 + i]=(byte)postCommand[i];
      log.debug("command sent " + HexDump.toHexString(readSystemTime));
      int resultWrite=mSerialDevice.write(readSystemTime);
      return resultWrite;
    }
  }
 catch (  Exception e) {
    StringBuffer sb1=new StringBuffer("");
    sb1.append("EXCEPTION!!!!!! " + e.getMessage() + " "+ e.getCause());
    for (    StackTraceElement st : e.getStackTrace()) {
      sb1.append(st.toString());
    }
    sendMessageToUI(sb1.toString(),false);
  }
  return -1;
}

protected int sendMedtronicPumpCommand ( byte command , byte repeat , byte [ ] postCommand ) { try { if ( idPump != null && idPump . length > 0 ) { int pCLength = 0 ; if ( postCommand != null ) pCLength = postCommand . length ; byte [ ] readSystemTime = new byte [ 6 + idPump . length + pCLength ] ; int i = 0 ; int size = 2 + idPump . length + pCLength + 1 ; byte [ ] sizByte = HexDump . hexStringToByteArray ( HexDump . toHexString ( size ) ) ; log . debug ( "sizByte " + HexDump . toHexString ( sizByte ) ) ; readSystemTime [ 0 ] = ( byte ) 0x81 ; readSystemTime [ 1 ] = ( byte ) sizByte [ sizByte . length - 1 ] ; readSystemTime [ 2 ] = repeat ; readSystemTime [ 3 ] = ( byte ) MedtronicConstants . MEDTRONIC_PUMP ; for ( i = 0 ; i < idPump . length ; i ++ ) readSystemTime [ i + 4 ] = ( byte ) idPump [ i ] ; readSystemTime [ idPump . length + 4 ] = command ; log . debug ( "postcommadnLength " ) ; for ( i = 0 ; i < postCommand . length ; i ++ ) readSystemTime [ idPump . length + 5 + i ] = ( byte ) postCommand [ i ] ; log . debug ( "command sent " + HexDump . toHexString ( readSystemTime ) ) ; int resultWrite = mSerialDevice . write ( readSystemTime ) ; return resultWrite ; } } catch ( Exception e ) { StringBuffer sb1 = new StringBuffer ( "" ) ; sb1 . append ( "EXCEPTION!!!!!! " + e . getMessage ( ) + " " + e . getCause ( ) ) ; for ( StackTraceElement st : e . getStackTrace ( ) ) { sb1 . append ( st . toString ( ) ) ; } sendMessageToUI ( sb1 . toString ( ) , false ) ; } return - 1 ; }
sends a message to the serial device
