Read data from standart data file

Forum / MIFARE general topics and applications / Read data from standart data file

  • 16. August 2018 at 16:35
    Hello! I try to read data from Mifare Desfire EV1 -----> Application - 1 - (Card Holder Information) -----> File: 0x01 with this code


    private void cardLogic(final Intent intent) {

    try {

    if (CardType.DESFireEV1 == m_libInstance.getCardType(intent)) {
    IDESFireEV1 evOne = DESFireFactory.getInstance()
    .getDESFireEV2(m_libInstance.getCustomModules());

    Log.d(TAG, "Android version: " + Build.VERSION.RELEASE);
    Log.d(TAG, "Phone model: " + Build.MODEL);
    Log.d(TAG, "Card type: " + m_libInstance.getCardType(intent).getTagName());
    Log.d(TAG, "TapLinx version: " + m_libInstance.getTaplinxVersion());

    Log.d(TAG, "Total card memory: " + evOne.getTotalMemory());
    Log.d(TAG, "Current memory: " + evOne.getFreeMemory());

    try {
    evOne.getReader().connect();
    // Timeout to prevent exceptions in authenticate
    evOne.getReader().setTimeout(2000);

    evOne.selectApplication(0xFFFFFF);
    Log.d( TAG, "AID 000000 selected" );

    byte[] data = evOne.readData(0x1, 0, 0);

    evOne.getReader().close();

    if (data != null) {

    String str = new String(data, "ASCII");
    m_textView.setText(str);
    } else {

    m_textView.setText("Readed data is null");
    }

    } catch (Throwable t) {
    t.printStackTrace();
    }
    }

    } catch (NxpNfcLibException e) {

    e.printStackTrace();
    String str = " " + e.toString();
    m_textView.setText(str);
    }
    }

    I need to read all File. I have received exception com.nxp.mfclib.InvalidResponseLengthException: Incomplete response. What i am doing wrong? Maybe this is from readData() method? Any help apprecated. Thank a lot.
    + 0  |  - 0

    Re: Read data from standart data file

    20. August 2018 at 10:29
    Hi Greg

    Reading with length = 0 means reading the entire file. In contrast to a “read of file” on desktop operation systems, please take in mind, reading and writing is “expensive”, which means it takes time. Therefore, you should only read the bytes you really want to know. You should also take in mind; the size of the communication channel is limited. Usually much smaller than 128 bytes.

    You set the application ID to 0xffffff and not to 1. Could this be the mistake?

    The TapLinx team

    + 0  |  - 0
Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.