Reading data from DESFire EV2 using ISOReadBinary

Forum / MIFARE and NFC Reader IC`s / Reading data from DESFire EV2 using ISOReadBinary

Tagged: 

  • 17. November 2016 at 14:17
    Hello,

    I am new in the field of NFC so I apologize in advance if my questions are basic questions.

    I am using a NCF3320 demonstration kit and I am trying to write and read data from DESFire EV2. I was able to write data successfully but when I use ISOReadBinary command to read data the code jumps to the HardFault_Handler. I added the following code to the classic example which was provided with the board documentation:

                else if (PHAC_DISCLOOP_CHECK_ANDMASK(wTagsDetected, PHAC_DISCLOOP_TYPEA_DETECTED_TAG_TYPE4A))
    {
    uint8_t aAID[3] = {0x01, 0x00, 0x00}; /**< Application Id for Desfire cards */
    uint8_t aISOFileId_A[2] = {0x05, 0xE1}; /**< ISO file Id for application */
    uint8_t aISODFName[7] = {0xD2, 0x76, 0x00, /**< DF Name buffer */
    0x00, 0x85, 0x01,
    0x01};
    uint8_t bDFLen = 7; /**< DF Name buffer length */
    uint8_t aISOFileId_F[2] = {0x03, 0xE1}; /**< ISOFileId for file */
    uint8_t aAccessRights[2] = {0xEE, 0xEE}; /**< Access Rights */
    uint8_t aFileSize[3] = {0x0F, 0x00, 0x00}; /**< File size specifier */
    uint8_t aOffset[3] = {0x00, 0x00, 0x00}; /**< Offset for write data */
    uint8_t aData[15] = {0x00, 0x0F, 0x20, /**< Data buffer */
    0x00, 0x3B, 0x00,
    0x34, 0x04, 0x06,
    0xE1, 0x04, 0x10,
    0x00, 0x00, 0x00};
    uint8_t aDataLen[3] = {0x0F, 0x00, 0x00}; /**< Valid data buffer length */
    uint8_t aNDEF_msg[15] = { /*NDEF message */
    0x00, 0x0C, 0xD1, 0x01,
    0x08, 'U', 0x01, 'n',
    'x', 'p', '.', 'c',
    'o', 'm', 0xFE};
    uint8_t **Buffer1;
    uint16_t *Buffer2;
    DEBUG_PRINTF ("\nType 4A-tag detected ");
    /* Create Application */
    status = phalMfdf_CreateApplication(&alMfdf, /**< [In] Pointer to parameters data structure */
    0x03, /**< [In] Option to indicate whether this application has ISO Fid and DF */
    aAID, /**< [In] 3 byte AID, LSB First */
    0x0F, /**< [In] Key Settings 1 - 1 Byte */
    0x21, /**< [In] Key Settings 2 - 1 Byte */
    aISOFileId_A, /**< [In] Two byte ISO File Id, LSB First */
    aISODFName, /**< [In] ISO DF Name. Maximum 16 bytes */
    bDFLen); /**< [In] Length of DF Name provided above */
    CHECK_SUCCESS(status);

    /* Select the AFC Application */
    status = phalMfdf_SelectApplication(&alMfdf, /**< [In] Pointer to parameters data structure */
    aAID); /**< [In] 3 byte AID, LSB First */
    CHECK_SUCCESS(status);

    /* Create Std File for CC */
    status = phalMfdf_CreateStdDataFile(&alMfdf, /**< [In] Pointer to parameters data structure */
    0x01, /**< [In] Option Parameter */
    0x01, /**< [In] File No. */
    aISOFileId_F, /**< [In] ISO File Id */
    PHAL_MFDF_COMMUNICATION_PLAIN, /**< [In] Communication option */
    aAccessRights, /**< [In] Access Rights */
    aFileSize); /**< [In] File size array */
    CHECK_SUCCESS(status);

    /* Now to create a file with ISO file ID 0xE104 */
    aISOFileId_F[0] = 0x04;

    /* Create Std File for NDEF */
    status = phalMfdf_CreateStdDataFile(&alMfdf, /**< [In] Pointer to parameters data structure */
    0x01, /**< [In] Option Parameter */
    0x02, /**< [In] File No. */
    aISOFileId_F, /**< [In] ISO File Id */
    PHAL_MFDF_COMMUNICATION_PLAIN, /**< [In] Communication option */
    aAccessRights, /**< [In] Access Rights */
    aFileSize); /**< [In] File size array */
    CHECK_SUCCESS(status);

    /* Write data to CC file */
    status = phalMfdf_WriteData(&alMfdf, /**< [In] Pointer to parameters data structure */
    PHAL_MFDF_COMMUNICATION_PLAIN, /**< [In] Communication option */
    0x01, /**< [In] File No. */
    aOffset, /**< [In] 3 bytes offset */
    aData, /**< [In] Data buffer */
    aDataLen); /**< [In] Length of the data */
    CHECK_SUCCESS(status);

    /* Now to Write NDEF msg in File No.2 */
    aDataLen[0] = 0x0E;

    /* Write data to NDEF file */
    status = phalMfdf_WriteData(&alMfdf, /**< [In] Pointer to parameters data structure */
    PHAL_MFDF_COMMUNICATION_PLAIN, /**< [In] Communication option */
    0x02, /**< [In] File No. */
    aOffset, /**< [In] 3 bytes offset */
    aNDEF_msg, /**< [In] Data buffer */
    aDataLen); /**< [In] Length of the data */
    CHECK_SUCCESS(status);
    DEBUG_PRINTF("\nWrite successful!");

    status=phalMfdf_IsoSelectFile(&alMfdf,0x00,0x04,aISOFileId_A,aISODFName,bDFLen,Buffer1,Buffer2);
    CHECK_SUCCESS(status);

    aISOFileId_F[0] = 0x03;

    status=phalMfdf_IsoSelectFile(&alMfdf,0x0C,0x00,aISOFileId_F,NULL,NULL,NULL,NULL);
    CHECK_SUCCESS(status);

    status=phalMfdf_IsoReadBinary(&alMfdf,PH_EXCHANGE_DEFAULT,0x00,0x83,0x0F,Buffer1,Buffer2);
    CHECK_SUCCESS(status);

    }


    any help would be greatly appreciated.
    + 0  |  - 0

    Re: Reading data from DESFire EV2 using ISOReadBinary

    21. November 2016 at 8:41

    I have made the following change to the code:

     uint8_t Buffer1[11]={''};
    uint16_t Buffer2=0;
    status=phalMfdf_IsoReadBinary(&alMfdf,PH_EXCHANGE_DEFAULT,0x00,0x84,0x0B,&Buffer1,&Buffer2);
    CHECK_SUCCESS(status);


    So now I can read data from the tag without causing any debug error but the data is not the same data that I wrote to the card. It seems that I am reading from the wrong address. Can anyone help please?




    + 0  |  - 0

    Re: Reading data from DESFire EV2 using ISOReadBinary

    21. November 2016 at 9:41
    Hi Mohammed,

    You provided code which uses the NxpRdLib. This is not the right forum for this kind of questions. Better you ask here:

    http://www.nxp.com/support/sales-and-support

    Regards,
    The TapLinx Team
    + 0  |  - 0

    Re: Reading data from DESFire EV2 using ISOReadBinary

    10. December 2016 at 5:52
    Reading data from desfire ev2 using isoreadbinar is a trending topic and i have no previous knowledge in this topic and this post helped me to read more about it. I am a writer of best essay writing service reviews company and ready to help students in writing at any time.
    + 0  |  - 0
Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.