Acr122U NFC Reader: Application Programming Interface
Acr122U NFC Reader: Application Programming Interface
READER
Application Programming Interface
info@acs.com.hk
Subject to change without prior notice
www.acs.com.hk
Table of Contents
1.0. Introduction ............................................................................................................. 5
1.1. USB Interface ........................................................................................................................ 5
2.0. Implementation ........................................................................................................ 6
2.1. Communication Flow Chart of ACR122U .............................................................................. 6
2.2. Smart Card Reader Interface Overview ................................................................................ 6
3.0. PICC Interface Description ..................................................................................... 7
3.1. ATR Generation ..................................................................................................................... 7
3.1.1. ATR format for ISO 14443 Part 3 PICCs ...................................................................... 7
3.1.2. ATR format for ISO 14443 Part 4 PICCs ...................................................................... 8
4.0. PICC Commands for General Purposes ................................................................ 9
4.1. Get Data................................................................................................................................. 9
5.0. PICC Commands (T=CL Emulation) for Mifare Classic Memory Cards ............. 10
5.1. Load Authentication Keys ....................................................................................................10
5.2. Authentication ......................................................................................................................11
5.3. Read Binary Blocks .............................................................................................................14
5.4. Update Binary Blocks ..........................................................................................................15
5.5. Value Block Related Commands .........................................................................................15
5.5.1. Value Block Operation ................................................................................................15
5.5.2. Read Value Block........................................................................................................16
5.5.3. Restore Value Block....................................................................................................17
6.0. Pseudo-APDUs ...................................................................................................... 18
6.1. Direct Transmit ....................................................................................................................18
6.2. Bi-Color LED and Buzzer Control ........................................................................................18
6.3. Get the Firmware Version of the reader ..............................................................................19
6.4. Get the PICC Operating Parameter .....................................................................................19
6.5. Set the PICC Operating Parameter .....................................................................................20
7.0. Basic Program Flow for Contactless Applications ............................................. 21
7.1. How to Access PCSC-Compliant Tags (ISO 14443-4)? .....................................................22
7.2. How to Access DESFire Tags (ISO 14443-4)? ...................................................................23
7.3. How to Access FeliCa Tags (ISO 18092)? ..........................................................................24
7.4. How to Access NFC Forum Type 1 Tags (ISO 18092), e.g. Jewel and Topaz Tags? ........24
7.5. Get the Current Setting of the Contactless Interface ...........................................................26
Appendix A. ACR122U PCSC Escape Command ......................................................... 27
Appendix B. APDU Command and Response Flow for ISO 14443-Compliant Tags .. 29
Appendix C. APDU Command and Response Flow for ISO 18092-Compliant Tags .. 30
Appendix D. Error Codes ............................................................................................... 31
Appendix E. Sample Codes for Setting the LED .......................................................... 32
Figures
Figure 1: Communication Flow Chart of ACR122U .......................................................................... 6
Figure 2: Basic Program Flow for Contactless Applications ........................................................... 21
Page 2 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Tables
Table 1: USB Interface ........................................................................................................................ 5
Table 2: ATR format for ISO 14443 Part 3 PICCs .............................................................................. 7
Table 3: ATR format for ISO 14443 Part 4 PICCs .............................................................................. 8
Table 4: Get UID APDU Format (5 Bytes) .......................................................................................... 9
Table 5: Get UID Response Format (UID + 2 Bytes) if P1 = 0x00 ..................................................... 9
Table 6: Get ATS of a ISO 14443 A card (ATS + 2 Bytes) if P1 = 0x01 ............................................. 9
Table 7: Response Codes................................................................................................................... 9
Table 8: Load Authentication Keys APDU Format (11 Bytes) .......................................................... 10
Table 9: Load Authentication Keys Response Format (2 Bytes) ...................................................... 10
Table 10: Load Authentication Keys Response Codes ................................................................... 10
Table 11: Load Authentication Keys APDU Format (6 Bytes) [Obsolete] ....................................... 11
Table 12: Load Authentication Keys APDU Format (10 Bytes)....................................................... 11
Table 13: Authenticate Data Bytes (5 Byte) .................................................................................... 11
Table 14: Load Authentication Keys Response Format (2 Bytes) .................................................. 11
Table 15: Load Authentication Keys Response Codes ................................................................... 11
Table 16: Read Binary APDU Format (5 Bytes) .............................................................................. 14
Table 17: Read Binary Block Response Format (N + 2 Bytes) ....................................................... 14
Table 18: Read Binary Block Response Codes .............................................................................. 14
Table 19: Update Binary APDU Format (4 or 16 + 5 Bytes) ........................................................... 15
Table 20: Update Binary Block Response Codes (2 Bytes) ............................................................ 15
Table 21: Value Block Operation APDU Format (10 Bytes) ............................................................ 15
Table 22: Value Block Operation Response Format (2 Bytes) ....................................................... 16
Table 23: Value Block Operation Response Codes ........................................................................ 16
Table 24: Read Value Block APDU Format (5 Bytes) ..................................................................... 16
Table 25: Read Value Block Response Format (4 + 2 Bytes) ........................................................ 16
Table 26: Read Value Block Response Codes ............................................................................... 16
Table 27: Restore Value Block APDU Format (7 Bytes) ................................................................. 17
Table 28: Restore Value Block Response Format (2 Bytes) ........................................................... 17
Table 29: Restore Value Block Response Codes .......................................................................... 17
Table 30: Direct Transmit Command Format (Length of the Payload + 5 Bytes) ........................... 18
Table 31: Direct Transmit Response Format .................................................................................. 18
Table 32: Bi-Color LED and Buzzer Control Command Format (9 Bytes) ...................................... 18
Table 33: Bi-Color LED and Buzzer Control Format (1 Byte) ......................................................... 18
Table 34: Bi-Color LED Blinking Duration Control Format (4 Bytes)............................................... 19
Table 35: Status Code ..................................................................................................................... 19
Table 36: : Current LED State (1 Byte) ........................................................................................... 19
Table 37: Command Format (5 Bytes) ............................................................................................ 19
Table 38: Response Format (10 bytes) ........................................................................................... 19
Page 3 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Table 39: Command Format (5 Bytes) ............................................................................................ 19
Table 40: Response Format (1 byte) ............................................................................................... 20
Table 41: Command Format (5 Bytes) ............................................................................................ 20
Table 42: Response Format (1 byte) ............................................................................................... 20
Table 43: PICC Operating Parameter. Default Value = FF ............................................................. 20
Table 44: ISO 7816-4 APDU Format............................................................................................... 22
Table 45: ISO 7816-4 Response Format (Data + 2 Bytes) ............................................................. 22
Table 46: Common ISO 7816-4 Response Codes .......................................................................... 22
Page 4 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
1.0. Introduction
The ACR122U is a PC-linked contactless smart card reader/writer used for accessing ISO14443-4
Type A and B, Mifare, ISO 18092 or NFC, and FeliCa tags. The ACR122U is PCSC-compliant so it is
compatible with existing PCSC applications. Furthermore, the standard Microsoft CCID driver is used
to simplify driver installation.
The ACR122U serves as the intermediary device between the personal computer and the contactless
tag via the USB interface. The reader carries out the command issued from the PC, whether the
command is used in order to communicate with a contactless tag or control the device peripherals
(LED or buzzer).
The ACR122U uses the PCSC APDUs for contactless tags following the PCSC Specification and
makes use of pseudo APDUs in sending commands for ISO 18092 tags and controlling the device
peripherals. This document will discuss how you can use the ACR122U in your smart card system.
Page 5 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
2.0. Implementation
2.1. Communication Flow Chart of ACR122U
The Standard Microsoft CCID and PCSC drivers are used. Therefore, no ACS drivers are required
because the drivers are already built inside the windows operating system. You also have to modify
your computer’s registry settings to be able to use the full capabilities of the ACR122U NFC Reader.
See ACR122U PCSC Escape Command for more details.
Page 6 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
3.0. PICC Interface Description
3.1. ATR Generation
If the reader detects a PICC, an ATR will be sent to the PCSC driver for identifying the PICC.
Page 7 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
3.1.2. ATR format for ISO 14443 Part 4 PICCs
Byte Value Designation Description
(Hex)
0 3B Initial Header
1 8N T0 Higher nibble 8 means: no TA1, TB1, TC1
only TD1 is following.
Lower nibble N is the number of historical
bytes (HistByte 0 to HistByte N-1)
2 80 TD1 Higher nibble 8 means: no TA2, TB2, TC2
only TD2 is following.
Lower nibble 0 means T = 0
3 01 TD2 Higher nibble 0 means no TA3, TB3, TC3,
TD3 following.
Lower nibble 1 means T = 1
4 XX T1 Historical Bytes:
to XX Tk
3+N XX ISO14443A:
XX The historical bytes from ATS response. Refer
to the ISO14443-4 specification.
ISO14443B:
The higher layer response from the ATTRIB
response (ATQB). Refer to the ISO14443-3
specification.
NOTE: Use the APDU “FF CA 01 00 00” to distinguish the ISO14443A-4 and ISO14443B-4
PICCs, and retrieve the full ATS if available. The ATS is returned for ISO14443A-3 or
ISO14443B-3/4 PICCs.
Since this card follows ISO 14443 Type B, the response would be ATQB which is 50 12
23 45 56 12 53 54 4E 33 81 C3 is 12 bytes long with no CRC-B
Note: You can refer to the ISO7816, ISO14443 and PCSC standards for more details.
Page 8 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
4.0. PICC Commands for General Purposes
4.1. Get Data
The “Get Data command” will return the serial number or ATS of the “connected PICC”.
Example:
1. To get the serial number of the “connected PICC”
UINT8 GET_UID[5]={0xFF, 0xCA, 0x00, 0x00, 0x04};
2. To get the ATS of the “connected ISO 14443 A PICC”
UINT8 GET_ATS[5]={0xFF, 0xCA, 0x01, 0x00, 0x04};
Page 9 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
5.0. PICC Commands (T=CL Emulation) for Mifare Classic
Memory Cards
5.1. Load Authentication Keys
The “Load Authentication Keys command” will load the authentication keys into the reader. The
authentication keys are used to authenticate the particular sector of the Mifare 1K/4K Memory Card.
Two kinds of authentication key locations are provided, volatile and non-volatile key locations
respectively.
Command
Class INS P1 P2 Lc Data In
Load Authentication Key
FF 82 Key Structure Key Number 06
Keys (6 bytes)
Table 8: Load Authentication Keys APDU Format (11 Bytes)
Example:
Load a key {FF FF FF FF FF FF} into the key location 0x00.
APDU = {FF 82 00 00 06 FF FF FF FF FF FF}
Page 10 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
5.2. Authentication
The “Authentication command” uses the keys stored in the reader to do authentication with the
MIFARE 1K/4K card (PICC). Two types of authentication keys are used: TYPE_A and TYPE_B.
NOTE: For MIFARE 1K Card, it has totally 16 sectors and each sector consists of 4 consecutive blocks.
E.g. Sector 0x00 consists of Blocks {0x00, 0x01, 0x02 and 0x03}; Sector 0x01 consists of Blocks {0x04,
0x05, 0x06 and 0x07}; the last sector 0x0F consists of Blocks {0x3C, 0x3D, 0x3E and 0x3F}.
Once the authentication is done successfully, there is no need to do the authentication again provided
that the blocks to be accessed are belonging to the same sector. Please refer to the MIFARE 1K/4K
specification for more details.
Page 11 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
MIFARE 1K Memory Map.
Page 12 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Example:
1. To authenticate the Block 0x04 with a {TYPE A, key number 0x00}. For PC/SC V2.01,
Obsolete.
APDU = {FF 88 00 04 60 00};
2. To authenticate the Block 0x04 with a {TYPE A, key number 0x00}. For PC/SC V2.07
alaAPDU = {FF 86 00 00 05 01 00 04 60 00}
Note:
MIFARE Ultralight does not need to do any authentication. The memory is free to access.
Page 13 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
5.3. Read Binary Blocks
The “Read Binary Blocks command” is used for retrieving “data blocks” from the PICC. The data
block/trailer block must be authenticated first.
Command Class INS P1 P2 Le
where:
Block Number (1 Byte): The block to be accessed
Number of Bytes to Read (1 Byte): Maximum 16 bytes
Example:
1. Read 16 bytes from the binary block 0x04 (MIFARE 1K or 4K)
APDU = {FF B0 00 04 10}
3. Read 16 bytes starting from the binary Page 0x04 (MIFARE Ultralight) (Pages 4, 5, 6 and 7
will be read)
APDU = {FF B0 00 04 10}
Page 14 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
5.4. Update Binary Blocks
The “Update Binary Blocks command” is used for writing “data blocks” into the PICC. The data
block/trailer block must be authenticated.
Command Class INS P1 P2 Lc Data In
where:
Block Number (1 Byte):The starting block to be updated.
Number of Bytes to Update (1 Byte):
16 bytes for MIFARE 1K/4K
4 bytes for MIFARE Ultralight.
Block Data (4 or 16 Bytes):
The data to be written into the binary block/blocks.
Example:
1. Update the binary block 0x04 of MIFARE 1K/4K with Data {00 01 .. 0F}
APDU = {FF D6 00 04 10 00 01 02 03 04 05 06 07 08 09 0A 0B 0C 0D 0E 0F}
2. Update the binary block 0x04 of MIFARE Ultralight with Data {00 01 02 03}
APDU = {FF D6 00 04 04 00 01 02 03}
Page 15 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
for value block.
VB_Value (4 Bytes): The value used for value manipulation. The value is a signed long integer (4
bytes).
Page 16 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
5.5.3. Restore Value Block
The “Restore Value Block command” is used to copy a value from a value block to another value
block.
Command Class INS P1 P2 Lc Data In
Value Block FF D7 00 Source 02 03 Target Block
Operation Block Number
Number
Table 27: Restore Value Block APDU Format (7 Bytes)
Source Block Number (1 Byte): The value of the source value block will be copied to the target value
block.
Target Block Number (1 Byte): The value block to be restored. The source and target value blocks
must be in the same sector.
Example:
3. Copy the value from value block 0x05 to value block 0x06
APDU = {FF D7 00 05 02 03 06}
Answer: 90 00 [9000]
Page 17 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
6.0. Pseudo-APDUs
Pseudo-APDUs are used for the following:
Exchanging Data with Non-PCSC Compliant Tags.
Retrieving and setting the reader parameters.
The Pseudo-APDUs can be sent through the “ACR122U PICC Interface” if the tag is already
connected.
Or the Pseudo-APDUs can be sent by using “Escape Command” if the tag is not presented
yet.
Page 18 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Data In: Blinking Duration Control
Byte 0 Byte 1 Byte 2 Byte 3
T1 Duration T2 Duration Number of Link to Buzzer
Initial Blinking State Toggle Blinking State repetition
(Unit = 100ms) (Unit = 100ms)
Table 34: Bi-Color LED Blinking Duration Control Format (4 Bytes)
Byte 3: Link to Buzzer. Control the buzzer state during the LED Blinking.
0x00: The buzzer will not turn on
0x01: The buzzer will turn on during the T1 Duration
0x02: The buzzer will turn on during the T2 Duration
0x03: The buzzer will turn on during the T1 and T2 Duration.
Note:
A. The LED State operation will be performed after the LED Blinking operation is completed.
B. The LED will not be changed if the corresponding LED Mask is not enabled.
C. The LED will not be blinking if the corresponding LED Blinking Mask is not enabled. Also, the
number of repetition must be greater than zero.
D. T1 and T2 duration parameters are used for controlling the duty cycle of LED blinking and Buzzer
Turn-On duration. For example, if T1=1 and T2=1, the duty cycle = 50%. #Duty Cycle = T1 / (T1 +
T2).
E. To control the buzzer only, just set the P2 “LED State Control” to zero.
F. The make the buzzer operating, the “number of repetition” must greater than zero.
G. To control the LED only, just set the parameter “Link to Buzzer” to zero.
Page 19 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Response Data Out
Result PICC Operating Parameter
Table 40: Response Format (1 byte)
Page 20 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
7.0. Basic Program Flow for Contactless Applications
Step 0. Start the application. The reader will do the PICC Polling and scan for tags continuously.
Once the tag is found and detected, the corresponding ATR will be sent to the PC. You must
make sure that the PCSC Escape Command has been set. See ACR122U PCSC Escape
Command for more details.
:
:
Step N. Disconnect the “ACR122U PICC Interface”. Shut down the application.
NOTE:
1. The antenna can be switched off in order to save the power.
Turn off the antenna power: FF 00 00 00 04 D4 32 01 00
Turn on the antenna power: FF 00 00 00 04 D4 32 01 01
2. Standard and Non-Standard APDUs Handling.
PICCs that use Standard APDUs: ISO14443-4 Type A and B, MIFARE .. etc
PICCs that use Non-Standard APDUs: FeliCa, Topaz .. etc.
Page 21 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
o Reader PC: The response data is returned.
Hint:
For ISO14443-4 Type A tags, the ATS can be obtained by using the APDU “FF CA 00 00 01”
Page 22 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
7.2. How to Access DESFire Tags (ISO 14443-4)?
DESFire supports ISO 7816-4 APDU Wrapping and Native modes. Once the DESFire Tag is
activated, the first APDU sent to the DESFire Tag will determine the “Command Mode”. If the first
APDU is “Native Mode”, the rest of the APDUs must be in “Native Mode” format. Similarly, if the first
APDU is “ISO 7816-4 APDU Wrapping Mode”, the rest of the APDUs must be in “ISO 7816-4 APDU
Wrapping Mode” format.
Example 1: DESFire ISO 7816-4 APDU Wrapping
To read 8 bytes random number from an ISO 14443-4 Type A PICC (DESFire)
APDU = {90 0A 00 00 01 00 00}
Class = 0x90; INS = 0x0A (DESFire Instruction); P1 = 0x00; P2 = 0x00
Lc = 0x01; Data In = 0x00; Le = 0x00 (Le = 0x00 for maximum length)
Answer: 7B 18 92 9D 9A 25 05 21 [$91AF]
The Status Code [91 AF] is defined in DESFire specification. Please refer to the DESFire
specification for more details.
Step 1: Send an APDU {90 60 00 00 00} to get the first frame. INS=0x60
Answer: 04 01 01 00 02 18 05 91 AF [$91AF]
Step 2: Send an APDU {90 AF 00 00 00} to get the second frame. INS=0xAF
Answer: 04 01 01 00 06 18 05 91 AF [$91AF]
Step 3: Send an APDU {90 AF 00 00 00} to get the last frame. INS=0xAF
Answer: 04 52 5A 19 B2 1B 80 8E 36 54 4D 40 26 04 91 00 [$9100]
To read 8 bytes random number from an ISO 14443-4 Type A PICC (DESFire)
APDU = {0A 00}
Answer: AF 25 9C 65 0C 87 65 1D D7[$1DD7]
In which, the first byte “AF” is the status code returned by the DESFire Card.
The Data inside the blanket [$1DD7] can simply be ignored by the application.
Note:
In DESFire Native Mode, the status code [90 00] will not be added to the response if the response length is
greater than 1. If the response length is less than 2, the status code [90 00] will be added in order to meet
the requirement of PCSC. The minimum response length is 2.
Page 23 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
7.3. How to Access FeliCa Tags (ISO 18092)?
Typical sequence may be:
- Present the FeliCa Tag and Connect the PICC Interface
- Read / Update the memory of the tag
Or
Note:
The NFC ID can be obtained by using the APDU “FF CA 00 00 00”
7.4. How to Access NFC Forum Type 1 Tags (ISO 18092), e.g.
Jewel and Topaz Tags?
Typical sequence may be:
- Present the Topaz Tag and Connect the PICC Interface
- Read / Update the memory of the tag
Step 2) Read the memory address 08 (Block 1: Byte-0) without using Pseudo APDU
<< 01 08
>> 18 [90 00]
In which, Response Data = 18
Or
Step 2) Read the memory address 08 (Block 1: Byte-0) using Pseudo APDU
<< FF 00 00 00 [05] D4 40 01 01 08
In which,
[05] is the length of the Pseudo APDU Data “D4 40 01 01 08”
D4 40 01 is the DataExchange Command.
01 08 is the data to be sent to the tag.
Page 24 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Tip: To read all the memory content of the tag
<< 00
>> 11 48 18 26 .. 00 [90 00]
Please refer to the Jewel and Topaz specification for more detailed information.
Page 25 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
7.5. Get the Current Setting of the Contactless Interface
Step 1) Get Status Command
<< FF 00 00 00 02 D4 04
>> D5 05 [Err] [Field] [NbTg] [Tg] [BrRx] [BrTx] [Type] 80 90 00
Page 26 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Appendix A. ACR122U PCSC Escape Command
1. Select the “ACS ACR122U PICC Interface 0”
2. Select the “Shared Mode” if the “ACR122U PICC Interface” is already connected, or “Direct
Mode” if the “ACR122U PICC Interface” is not connected.
3. Press the button “Connect” to establish a connection between the PC and the ACR122U reader.
4. Enter “3500” in the Command Text Box
5. Enter the PCSC Escape Command, e.g. “FF 00 48 00 00” and press the button “Send” to send
the command to the reader. #Get the firmware version
6. Press the button “Disconnect” to break the connection.
7. In order to send or receive Escape commands to a reader, follow the instructions below
8. The vendor IOCTL for the Escape command is defined as follows:
#define IOCTL_CCID_ESCAPE SCARD_CTL_CODE(3500)
The following instructions enumerate the steps to enable the PCSC Escape command:
Page 27 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Look for: VID_072F&PID_2200
Then expand the node. Look under Device
parameters
Page 28 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Appendix B. APDU Command and Response Flow
for ISO 14443-Compliant Tags
Assume an ISO14443-4 Type B tag is used.
PC Reader Tag
[APDU [APDU
Command] Command]
embedded in
e.g. [00 84 00
ISO14443
00 08] (Get
Frame
Challenge)
[APDU [APDU
Response] Response]
embedded in
e.g. [11 22 33
ISO14443
44 55 66 77
Frame
88] (90 00)
Page 29 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Appendix C. APDU Command and Response Flow
for ISO 18092-Compliant Tags
Assume a TOPAZ tag is used.
PC Reader Tag
[Native Command]
[Native Command] embedded in
e.g. [01 08] (read ISO18092 Frame
memory address 08)
or
Pseudo APDU
Command
+ [Native Command]
e.g. FF 00 00 00 05 D4
40 01 [01 08]
or
Pseudo APDU
Response
+ [Native Response]
e.g. D5 41 00 [00] (90
00)
Page 30 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Appendix D. Error Codes
Page 31 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Appendix E. Sample Codes for Setting the LED
Example 1: To read the existing LED State
// Assume both Red and Green LEDs are OFF initially //
// Not link to the buzzer //
To turn off both RED and Green LEDs, APDU = “FF 00 40 0C 04 00 00 00 00”
Example 3: To turn off the RED Color LED only, and leave the Green Color LED unchanged
// Assume both Red and Green LEDs are ON initially //
// Not link to the buzzer //
Red LED On
Green LED On
Page 32 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Example 4: To turn on the Red LED for 2 sec. After that, resume to the initial state
// Assume the Red LED is initially OFF, while the Green LED is initially ON. //
// The Red LED and buzzer will turn on during the T1 duration, while the Green LED will turn off during
the T1 duration. //
Red LED On
T2 = 0ms
T1 = 2000ms
Red LED Off
Green LED On
Buzzer Off
Example 5: To blink the Red LED of 1Hz for 3 times. After that, resume to initial state
// Assume the Red LED is initially OFF, while the Green LED is initially ON. //
// The Initial Red LED Blinking State is ON. Only the Red LED will be blinking.
// The buzzer will turn on during the T1 duration, while the Green LED will turn off during both the T1
and T2 duration.
// After the blinking, the Green LED will turn ON. The Red LED will resume to the initial state after the
blinking //
Red LED On
Buzzer On
Buzzer Off
1Hz = 1000ms Time Interval = 500ms ON + 500 ms OFF
T1 Duration = 500ms = 0x05
T2 Duration = 500ms = 0x05
Number of repetition = 0x03
Link to Buzzer = 0x01
Page 33 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk
Example 6: To blink the Red and Green LEDs of 1Hz for 3 times
// Assume both the Red and Green LEDs are initially OFF. //
// Both Initial Red and Green Blinking States are ON //
// The buzzer will turn on during both the T1 and T2 duration//
Red LED On
Green LED On
Buzzer Off
1Hz = 1000ms Time Interval = 500ms ON + 500 ms OFF
T1 Duration = 500ms = 0x05
T2 Duration = 500ms = 0x05
Number of repetition = 0x03
Link to Buzzer = 0x03
Example 7: To blink the Red and Green LED in turn of 1Hz for 3 times
// Assume both Red and Green LEDs are initially OFF. //
// The Initial Red Blinking State is ON; The Initial Green Blinking States is OFF //
// The buzzer will turn on during the T1 duration//
Red LED On
Buzzer On
Buzzer Off
Page 34 of 34
www.acs.com
ACR122U NFC Reader API Document Title Here info@acs.com.hk
.hk
Document Title Here
Version 1.4 www.acs.com.hk