Need help understanding APDU response

denethon

I've been using the ACR122 card reader for a while which had no trouble reading either Mifare 1K or Mifare Ultralight NFC cards.

After upgrading the card reader to the newest version (ACR1251), my program can't read the UID from the Mifare 1K cards.

This is the snippet I use for reading:

CardTerminal terminal = terminalWithCardPresent.get(0);
terminal.waitForCardPresent(0);
Card card = terminal.connect("T=1");
if (card != null) {
    CommandAPDU command = new CommandAPDU((byte) 0xFF, (byte) 0xCA, (byte) 0x00, (byte) 0x00, (byte) 0x07);
    CardChannel channel = card.getBasicChannel();
    ResponseAPDU response = channel.transmit(command);
    StringBuilder sb = new StringBuilder();
    if (response.getSW1() == 0x90 && response.getSW2() == 0x00) {
        byte[] data = response.getData();
        String code = decoder.apply(data);
        sb.append(code);
    }
    cardIdRead.recieve(sb.toString());
}
terminal.waitForCardAbsent(0);

With the new version of the rad reader:

  • the ResponseAPDU.getSW1() function returns 98
  • while getSW2() returns 130

I've tried searching both the web and the card readers documentation for an explanation for the response codes with no luck. Anyone else had simular problems, and know how to read the UID from a card returnon sw1 sw2 98 130?

David

Converting the SW 98 130 into hex gave ‘6282’. From this table, it means "Fewer bytes than specified by the Le parameter could be read, since the end of the file was encountered first."

The 'FF CA' is documentated in ACR122U reader documentation, but is not found in ACR1251U documentation. From the ACR122U documentation, the Le should be '00' instead of '07'.

I suggest trying to send APDU 'FFCA000000', and if it failed, try to send 'FFCA0000XX' (with XX from '01' to '06').

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related