11 Replies Latest reply on Oct 24, 2013 1:27 PM by 966575

    Chaining in T=1 protocol in javacard for data_size>256


      Dear Friends

      I have a problem that confused me a couple of days. I want to send out data which has size bigger than 256. I found some sample codes in web. these codes like this:

      private void sendData(APDU apdu) {

              // work out how many bytes to send this time and how many will be left

              BUF_IN_OFFSET[0] = 0;



              short remain = (short) ((short)372 - BUF_IN_OFFSET[0]);

              boolean chain = remain > MAX_APDU;

              short sendLen = chain ? MAX_APDU : remain;


              // Get ready to send



              apdu.sendBytesLong(data, BUF_IN_OFFSET[0], sendLen);


               // Check to see if there are more APDU's to send

              if (chain) {

                  BUF_IN_OFFSET[0] += sendLen; // count the bytes sent

                  remain -=sendLen;

                  ISOException.throwIt((short)(ISO7816.SW_BYTES_REMAINING_00 + remain));


              } else {

                  BUF_IN_OFFSET[0] = 0; // no more bytes to send





      When i execute this code on netbeans simulator it works currectly and response 61xx status word. but when i execute on real card (smartcafe 3.2 expert) it response 9000 and doesn't return remained data length. My card support both T=0/1 protocol and and i guess the used protocol related to this problem, or it may have another problem.

      does this code executed for T=1 protocol correctly?

      anyone can help me?

      Thanks in advance.

      Mohsen Mgh