Page 1 of 1

Get 6C80 in the response APDU

Posted: Mon Feb 22, 2016 4:57 am
by nikonai
Here is part of my applet code which is to handle specific APDU command :

Code: Select all

...

private void updateCardMetaData(APDU apdu){
        byte[] buffer = apdu.getBuffer();
        short len = (short) (buffer[ISO7816.OFFSET_LC] & 0x00FF);
        cardMetaData=    processCardMetaData(buffer,len);
        short    length =(short) cardMetaData.length;
        Util.arrayCopyNonAtomic(cardMetaData, (short) 0, buffer, (short) 0,
        (short) length);
   
     apdu.setOutgoingAndSend((short) 0, length);
    }
 ...
//Code for processCardMetaData
private byte[] processCardMetaData(byte[] buffer,short len){
        //cardMetaData
        byte tempData[]= new byte[128];
        short counter=(short)0;
        short counter2=(short)(counter+5);
        while(counter<len){
            tempData[counter]    =buffer[counter2];
            counter+=1;
            counter2+=1;//=(short)(counter2+1);
        }
        return tempData;
    }


This is the APDU command which is supposed to write data to the card.

Code: Select all

 --> 805500002D416D626F6B6120496D6D6163756C617465204F64696D617C3130313337
36303130303030303035317C31323135

<-- 6C80

I don't expect any data in the response. Why do I get that error? Is there any error in my applet code?

Re: Get 6C80 in the response APDU

Posted: Thu Feb 25, 2016 11:17 pm
by mabel
From your code, it looks like you are copying the input data into cardMetaData buffer and copying back to the global buffer.

And last line in your function 'updateCardMetaData' you are trying to return the length bytes of data(128B) which is why you are getting 0x6C80.

If you don't expect any data in the response and just want to return "90 00", put ISOException.throwIt((short) 0x9000) instead of apdu.setOutgoingAndSend((short) 0, length).

Hope it helps!