element14 Community
element14 Community
    Register Log In
  • Site
  • Search
  • Log In Register
  • About Us
  • Community Hub
    Community Hub
    • What's New on element14
    • Feedback and Support
    • Benefits of Membership
    • Personal Blogs
    • Members Area
    • Achievement Levels
  • Learn
    Learn
    • Ask an Expert
    • eBooks
    • element14 presents
    • Learning Center
    • Tech Spotlight
    • STEM Academy
    • Webinars, Training and Events
    • Learning Groups
  • Technologies
    Technologies
    • 3D Printing
    • FPGA
    • Industrial Automation
    • Internet of Things
    • Power & Energy
    • Sensors
    • Technology Groups
  • Challenges & Projects
    Challenges & Projects
    • Design Challenges
    • element14 presents Projects
    • Project14
    • Arduino Projects
    • Raspberry Pi Projects
    • Project Groups
  • Products
    Products
    • Arduino
    • Avnet Boards Community
    • Dev Tools
    • Manufacturers
    • Multicomp Pro
    • Product Groups
    • Raspberry Pi
    • RoadTests & Reviews
  • Store
    Store
    • Visit Your Store
    • Choose another store...
      • Europe
      •  Austria (German)
      •  Belgium (Dutch, French)
      •  Bulgaria (Bulgarian)
      •  Czech Republic (Czech)
      •  Denmark (Danish)
      •  Estonia (Estonian)
      •  Finland (Finnish)
      •  France (French)
      •  Germany (German)
      •  Hungary (Hungarian)
      •  Ireland
      •  Israel
      •  Italy (Italian)
      •  Latvia (Latvian)
      •  
      •  Lithuania (Lithuanian)
      •  Netherlands (Dutch)
      •  Norway (Norwegian)
      •  Poland (Polish)
      •  Portugal (Portuguese)
      •  Romania (Romanian)
      •  Russia (Russian)
      •  Slovakia (Slovak)
      •  Slovenia (Slovenian)
      •  Spain (Spanish)
      •  Sweden (Swedish)
      •  Switzerland(German, French)
      •  Turkey (Turkish)
      •  United Kingdom
      • Asia Pacific
      •  Australia
      •  China
      •  Hong Kong
      •  India
      •  Korea (Korean)
      •  Malaysia
      •  New Zealand
      •  Philippines
      •  Singapore
      •  Taiwan
      •  Thailand (Thai)
      • Americas
      •  Brazil (Portuguese)
      •  Canada
      •  Mexico (Spanish)
      •  United States
      Can't find the country/region you're looking for? Visit our export site or find a local distributor.
  • Translate
  • Profile
  • Settings
EXPLORE-NFC
  • Products
  • Dev Tools
  • EXPLORE-NFC
  • More
  • Cancel
EXPLORE-NFC
Forum Is there any sample code for sending a simple APDU command with the ExplorerNFC board?
  • Blog
  • Forum
  • Documents
  • Events
  • Files
  • Members
  • Mentions
  • Sub-Groups
  • Tags
  • More
  • Cancel
  • New
Join EXPLORE-NFC to participate - click to join for free!
Actions
  • Share
  • More
  • Cancel
Forum Thread Details
  • State Suggested Answer
  • Replies 11 replies
  • Answers 2 answers
  • Subscribers 11 subscribers
  • Views 2948 views
  • Users 0 members are here
Related

Is there any sample code for sending a simple APDU command with the ExplorerNFC board?

Former Member
Former Member over 10 years ago

Hi All,

I´m trying to send a simple APDU command to a contactless smart card with the ExplorerNFC board but I could not find a the library for it in the doc and source files.

Is it possible ? I would like for instance to send a command such as : 0x80 0x08 0x00 0x00 ?

Does anyone have a simple solution ?

Thanks in advance, Aurelien

  • Sign in to reply
  • Cancel

Top Replies

  • Former Member
    Former Member over 10 years ago +2
    Hi, I'm using Raspberry Pi 2 Model B 1. I just downloaded the sample (main.c) https://github.com/JohnMcLear/NXP-Raspberry-Pi-Card-Polling-Demo 2. Replace the NXP Reader Library (NxpRdLib_PublicRelease…
  • Former Member
    Former Member over 9 years ago in reply to Former Member +1 suggested
    Michael, looks like your missing this in your code: $ diff ../../NfcReaderLibrary/read-HCE-Android.c read-hce.c 150c150 < phbalReg_RpiSpi_Init(&balReader, sizeof(phbalReg_RpiSpi_DataParams_t)); --- > status…
Parents
  • Former Member
    0 Former Member over 10 years ago

    Hi,

     

    I'm using Raspberry Pi 2 Model B

     

    1. I just downloaded the sample (main.c)

    https://github.com/JohnMcLear/NXP-Raspberry-Pi-Card-Polling-Demo

    2. Replace the NXP Reader Library (NxpRdLib_PublicRelease) by the latest version (from neard-explorenfc-0.8)

    3. Update the CMakeLists.txt

     

    cmake_minimum_required (VERSION 2.8)

    project (card_polling)

    #file(GLOB_RECURSE SOURCE_TMP "*.c" )

    #list(APPEND SRC ${SOURCE_TMP})

    set(NXP_RD_LIB "nxprdlib")

    include_directories (

      "/usr/include"

      "/usr/include/glib-2.0"

      "/usr/lib/arm-linux-gnueabihf/glib-2.0/include"

      "${PROJECT_SOURCE_DIR}/wiringPi"

      "${PROJECT_SOURCE_DIR}/${NXP_RD_LIB}"

      "${PROJECT_SOURCE_DIR}/${NXP_RD_LIB}/intfs"

        "${PROJECT_SOURCE_DIR}/${NXP_RD_LIB}/types"

        "${PROJECT_SOURCE_DIR}/${NXP_RD_LIB}/comps/phpalSli15693/src/Sw"

    )

    link_libraries(wiringPi glib-2.0)

    set(EXT_LIBS  pthread  m)

    add_definitions(-g -O0 -std=c99)

    list(APPEND SOURCE "${PROJECT_SOURCE_DIR}/main.c")

    source_group(src "${PROJECT_SOURCE_DIR}/main.c")

    file(GLOB_RECURSE SOURCE_TMP "${PROJECT_SOURCE_DIR}/${NXP_RD_LIB}/*.c" )

    list(APPEND SOURCE ${SOURCE_TMP})

    #source_group(wiringPi FILES ${SOURCE_TMP})

    #list(REMOVE_ITEM SOURCE "${PROJECT_SOURCE_DIR}/${NXP_RD_LIB}/ex/NxpRdLib.c")

    add_executable(${PROJECT_NAME} ${SOURCE})

    target_link_libraries(${PROJECT_NAME} ${EXT_LIBS})

     

    4. I can now send select AID commands and customized commands

     

    From the sample main.c, after UID is obtained, I add the followings

     

    memset(ats, 0, sizeof(ats));
    status = phpalI14443p4a_ActivateCard(&I14443p4a, 8, 0, 0, 0, ats);
    status = phpalI14443p4_Exchange(&I14443p4, PH_EXCHANGE_DEFAULT, CMD_SELECT_AID, sizeof(CMD_SELECT_AID), &pRecvBuf, &recvLen);
    DBG_PRINT("Select AID: %d\n", status);
    DumpHex("Select AID", pRecvBuf, recvLen);

     

    status = phpalI14443p4_Exchange(&I14443p4, PH_EXCHANGE_DEFAULT, CMD_CUSTOM, sizeof(CMD_CUSTOM), &pRecvBuf, &recvLen);
    DBG_PRINT("Get filesize: %d\n", status);
    • Cancel
    • Vote Up +2 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to Former Member

    Thank you for your post Eric,

    I have downloaded the latest library "NFCReaderLibraryforPNEV512B-3.010_R3", however, the phpalSli15693 folder was not located. Also, I ran the sample code as is, however, the status return code at the line below indicates PH_ERR_INTERFACE_ERROR  Communication error.

    Could you give some guidance on this as to ways I could troubleshoot further to determine what the cause of the error may be or any hints as to what could be causing this.

    .

    Error here, status code 0x20B:

    /* Reset the RF field */

    PH_CHECK_SUCCESS_FCT(status, phhalHw_FieldReset(halReader));

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelneurohr
    0 michaelneurohr over 9 years ago in reply to Former Member

    Hi,

    I wrote some instructions including some example code here.

    https://github.com/michaelneurohr/NfcReaderLibrary/tree/raspberrypi

     

    Checkout the two files read-HCE-Android-README.md and read-HCE-Android.c

     

    Michael

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to michaelneurohr

    @Michael

     

    Compiling read-HCE-Android.c works fine, but running it I get an error immediately.

     

    $ sudo ./read-hce

    Start Example: Read NDEF from Type 4 Tag

    Line: 153   Error - (0x0789) has occurred : 0xCCEE CC-Component ID, EE-Error code. Refer-ph_Status.h

     

    Thanks,

    Wolfgang

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • michaelneurohr
    0 michaelneurohr over 9 years ago in reply to Former Member

    Hi Wolfgang,

     

    did you kill the explore-nfc daemon running in the background in case you installed the EXPLORE-NFC software before? The daemon might have the EXPLORE-NFC allocated in your case.

     

    Michael

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to michaelneurohr

    Hi Michael,

     

    error message is the same, no matter if the daemon is running or not

     

    Wolfgang

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
  • Former Member
    0 Former Member over 9 years ago in reply to Former Member

    Michael,

     

    looks like your missing this in your code:

     

    $ diff ../../NfcReaderLibrary/read-HCE-Android.c read-hce.c

    150c150

    <     phbalReg_RpiSpi_Init(&balReader, sizeof(phbalReg_RpiSpi_DataParams_t));

    ---

    >     status = phbalReg_RpiSpi_Init(&balReader, sizeof(phbalReg_RpiSpi_DataParams_t));

     

    Wolfgang

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Reply
  • Former Member
    0 Former Member over 9 years ago in reply to Former Member

    Michael,

     

    looks like your missing this in your code:

     

    $ diff ../../NfcReaderLibrary/read-HCE-Android.c read-hce.c

    150c150

    <     phbalReg_RpiSpi_Init(&balReader, sizeof(phbalReg_RpiSpi_DataParams_t));

    ---

    >     status = phbalReg_RpiSpi_Init(&balReader, sizeof(phbalReg_RpiSpi_DataParams_t));

     

    Wolfgang

    • Cancel
    • Vote Up +1 Vote Down
    • Sign in to reply
    • Verify Answer
    • Reject Answer
    • Cancel
Children
  • michaelneurohr
    0 michaelneurohr over 9 years ago in reply to Former Member

    Yes, you are probably right. Depending on the initial value of status, the code works or not. Thanks for the note. I'll correct that.

     

    Michael

    • Cancel
    • Vote Up 0 Vote Down
    • Sign in to reply
    • Verify Answer
    • Cancel
element14 Community

element14 is the first online community specifically for engineers. Connect with your peers and get expert answers to your questions.

  • Members
  • Learn
  • Technologies
  • Challenges & Projects
  • Products
  • Store
  • About Us
  • Feedback & Support
  • FAQs
  • Terms of Use
  • Privacy Policy
  • Legal and Copyright Notices
  • Sitemap
  • Cookies

An Avnet Company © 2025 Premier Farnell Limited. All Rights Reserved.

Premier Farnell Ltd, registered in England and Wales (no 00876412), registered office: Farnell House, Forge Lane, Leeds LS12 2NE.

ICP 备案号 10220084.

Follow element14

  • X
  • Facebook
  • linkedin
  • YouTube