ECHO instruction

The ECHO instruction has been designed to test the driver and/or the libraries between the application and the reader. It allows to send and receive arbitrary length of data, and to simulate delayed answers and spurious card removals.

Command format

Field Value Remark
CLA FF
INS FD
P1 00
P2 Delay and options See table below
Lc Length of DataIn
DataIn Arbitrary data to send to the card (in fact, to the reader) Can be empty
Le Length of requested DataOut Can be 0

Note: this command supports extended APDU format. Lc and Le can theoretically go up to 64kB, yet the actual maximum size supported by the reader depends on its architecture and firmware options, please check with the datasheet.

Delay and options (P2)

P2 is an array of bits with the following definition:

Bits Value
7 0 : the size of the response is specified in P1 (deprecated)
1 : the size of the response is specified be Le (if present)
6 0 : no card removal
1 : simulate a spurious card removal
5-0 Delay in seconds
000000 : no delay, the reader answers immediately
000001 to 111111 : delay between 1 and 63 seconds

Response

Normal response

Field Value
DataOut Arbitrary data (length equal to Le)
SW 9000

How is DataOut generated?

DataOut is a deterministic value, which allows the test application to check that no byte has been lost.

DataOut bytes Value
Bytes from i = 0 to i = Lc-1 (if Lc > 0) DataOut[i] = DataIn[i] (echo)
Bytes from i = Lc to i = Le-1 (if Le > Lc) DataOut[i] = i

Response if card removal requested in P2

The reader does not provide a R-APDU, the SCardTransmit function shall return SCARD_W_REMOVED_CARD.

Examples

Command Description
FF FD 00 8F 10 No DataIn, wait 15s and return 16 bytes
FF FD 00 CF 10 No DataIn, wait 15s and simulate a spurious card removal
FF FD 00 80 F8 [248 bytes] Send 248 bytes to the reader in DataIn (short APDU)
FF FD 00 80 F8 Receive 248 bytes form the reader in DataOut (short APDU)
FF FD 00 80 F8 [248 bytes] F8 Echo of 248 bytes (short APDU)
FF FD 00 80 000FF0 [4080 bytes] Send 4080 bytes to the reader in DataIn (extended APDU)
FF FD 00 80 000FF0 Receive 4080 bytes form the reader in DataOut (extended APDU)
FF FD 00 80 000FF0 [4080 bytes] 0FF0 Echo of 4080 bytes (extended APDU)