ATR command when programming PC/SC reader
I have checked the programming interface for the MIFARE Ultralight and TOPAZ/Jewel IC tags. The API quite nicely describes how the bytes are saved on the card, how to address the memory blocks, how to make all operations like read, read-all, use of the OTP (One Time Programmable) function, how to read ROM bytes, how to switch from idle to ready state (REQA, WUPA commands), it says if commands are CRC protected, how to access the tag UID, etc.
When stared to program the NFC reader (ACR122U or SCL010) I found that all communication between PCD (reader) an PICC (tag) starts with the ATR (Answer-To-Reset) command, which is as described on Internet a command that the PCD sends to PICC for identificat开发者_StackOverflow社区ion purposes.
But none of the tags documentation mentions the ATR command – all communication with tags when they become powered (PQR) starts with REQA, WUPA commands in order to switch the card to the Ready mode.
My understanding is that ATR is built by PC/SC based on the NFC card the reader communicated with. Once the reader detect what type of technology is the tag based on it creates the ATR. Also according to documentation ATR for different NFC readers are different for the same NFC tags.
Am I right? Does the PC/SC build the ATR?
BR STeN
Short answer:
- You are correct about ATR being generated by PCSC reader
- I think the ATR will remain the same irrespective of the reader for contactless cards
Long answer:
ATR is for contact cards and is specified in ISO 7816. For contacless cards, it is the PC/SC reader (IFD) that generates the ATR.
The ATR is constructed based on:
- ATS (Answer to Select) for ISO 14443 Type A cards
- ATQB and ATTRIB bytes for ISO 14443 Type B cards
The ATR will be of the form 3B 8X 80 01 HB_ATS Parity_Byte where X is the number of bytes of Historical Bytes of ATS (HB_ATS).
The exact construction of ATR for contactless cards is given in section 3.1.3.2.3 of the PC/SC spec.
Given that the only variable is ATS, it should be the same regardless of the reader.
--Sid
ATR contains fixed fields as well as optional fields(conditional). So depending on some values of a field, subsequent fields may be omitted hence ATR might be different for different readers but they all conform to the standards.
Check out the smart card tutorial here.
In short, ATR frame is as below:
精彩评论