Page 1 of 1

the byte array can not receive the data in data field of APDU command

Posted: Thu Nov 19, 2015 7:37 am
by marclo
I have a question when writing a simple java card applet.

Here is my code:

Code: Select all

public class javacard_applet extends Applet
{
   
   public static void install(byte[] bArray, short bOffset, byte bLength)
   {
      new javacard_applet().register(bArray, (short) (bOffset + 1), bArray[bOffset]);
   }

   public void process(APDU apdu)
   {
      if (selectingApplet())
      {
         return;
      }

      byte[] buf = apdu.getBuffer();
      switch (buf[ISO7816.OFFSET_INS])
      {
      case (byte)0x01:
         break;
      case (byte)0x02:
         break;
      default:
         ISOException.throwIt(ISO7816.SW_INS_NOT_SUPPORTED);
      }
   }
   
}


when I send APDU command
>> /send 00010000051122334455

The array buf can not receive the data in the data field of APDU command. I mean it can only receive the first five bytes(0001000005) but the last five bytes(1122334455).



Why this happened? Am I making any mistakes?

Re: the byte array can not receive the data in data field of APDU command

Posted: Tue Nov 24, 2015 7:18 am
by Ellisun
Maybe, you using protocol is T0.
In T0, you should call apdu.setIncomingAndReceive() function to indicates that this APDU has incoming data. It is the primary receive method.