/**
  * sendCommand
  *
  * @param command
  * @return byte[] response
  * @throws Exception
  */
 public static byte[] sendCommand(byte[] cmd, CardChannel channel) throws Exception {
   if (channel == null) {
     throw new ChannelNotOpenException();
   }
   byte[] rep = null;
   ResponseAPDU r = null;
   try {
     CommandAPDU apdu = new CommandAPDU(cmd);
     try {
       System.out.println("APDU Command: " + BytesTool.byteArrayToHexString(apdu.getBytes()));
     } catch (ByteArrayToHexaStringException e) {
       throw e;
     }
     r = channel.transmit(apdu);
     rep = r.getBytes();
     try {
       System.out.println("APDU Response: " + BytesTool.byteArrayToHexString(rep));
     } catch (ByteArrayToHexaStringException e) {
       throw e;
     }
     return rep;
   } catch (CardException e) {
     e.printStackTrace();
     throw e;
   }
 }