i'm trying to understand how the InDataExchange Command is actually working. I'm using a pn532 component (I send this command to PN532 from a microcontroler). When I'm using the InDataExchange command it seems to work since the status byte returned from the PN532 to my microcontroler is 0x00, which means the exchange worked. But actually i'm not sending anything in the data field, since I dont understand what we have to insert in the payload of this command (InDataExchange). I'm trying to read data written in a tag from PN532 component, but I just dont know how to say "read the data contained in the tag". I've heard of the C-APDU command, which is part of the ISO/IEC 14443-4 protocol, but i dont really get how it actually works..
2 Answers
The commands to use can depend on the type/model of the Tag (there is a minimum spec for Tags).
More details about the exact Tag type/model would be helpful but you can read the specs for most tag types at http://apps4android.org/nfc-specifications/
The simplest one is a Type 4 Tag but other types can use sudo C-APDU the datasheet/manuals will have more details e.g. Section 7 onwards on https://www.nxp.com/docs/en/user-guide/141520.pdf

- 8,198
- 2
- 15
- 35
-
Thank you , to be more precise: I am programming a PIC18 microcontroler, from which I send commands to the PN532 that is communicating (NFC) with a Mifare Desfire EV1 tag. So when i'm using the InDataExchange command (from the microcontroler), I send the following packet to PN532 : D4 - 40 - Tag of my target(Mifare Desfire Ev1) - DataOut with DataOut : CLA = 0x90 INS = 0x0A P1 = P2 = 0x00 Lc = 0x01 data = 0x00 Le = 0x00 The response the PN532 returned (he got the response from the Mifare tag) is the following : 6F 5F 53 8C B2 80 C0 ED 91 AF – Idash Jun 12 '20 at 06:20
-
I think packet data returned is structured like this : data - SW1 - SW2 (wtih a mobile app, I just wrote in the Mifare Ev1 tag the letter 'b', which i'm trying to read from the PN532) – Idash Jun 12 '20 at 06:20
-
And do I have to do the authentification process with the Desfire card before trying to read its content ? – Idash Jun 12 '20 at 08:18
In my case, I found this git repository with good examples. It is written in python, but I was easily able to translate them in Rust for my needs. https://github.com/adafruit/Adafruit_CircuitPython_PN532/blob/fc8b488dbf4573188b5c3141b3178e0032b9f30a/adafruit_pn532/adafruit_pn532.py#L407
On my project, I am working with MiFare Classic card. Here it explains how they are organized internally. It helps understand the documentation from the previous git repository. https://www.puntoflotante.net/TUTORIAL-RFID-ISO-14443A-TAGS-13.56-MHZ.htm
I've assumed MiFare classic cards, but there is other information about other cards too.