How to send ISO 14443A command frames with manual parity bits (ST25R3911B-DISCO)
Hi there!
I'm working on a Windows console application which uses ST25R3911DISCOComm DLL to communicate with ST25R3911B-DISCO board to process a ISO 14443A card (ST25R3911DISCOComm DLL is located in ST25R3911B_Discovery_GUI App installation directory).
My goal is to send commands with manual parity bits and CRC bytes. The problem I'm facing is no response from the card when RFAL_TXRX_FLAGS_PAR_TX_NONE flag is set.
For experimental purposes I tried to send a well known command RATS and to receive a well known response ATS from the card.
First of all I tried to send RATS command with auto generated parity bits yet manually calculated CRC bytes to see that the card returns the correct ATS answer:
flags = (RFAL_TXRX_FLAGS_NFCIP1_OFF | RFAL_TXRX_FLAGS_AGC_OFF | RFAL_TXRX_FLAGS_PAR_RX_KEEP | RFAL_TXRX_FLAGS_CRC_RX_KEEP | RFAL_TXRX_FLAGS_CRC_TX_MANUAL); // here RFAL_TXRX_FLAGS_PAR_TX_NONE is not set so parity bit are generated automatically
memcpy(txBuf, "\xE0\x80\x31\x73", 4);
txBufLen = 4; // expressed in number of bytes
printf("Tx...\n");
ErrorCode = rfalTransceiveBlockingTx(Handle, txBuf, txBufLen, flags, fwt);
if (ErrorCode != NoError) CheckErrorCode(Handle, ErrorCode);
printf("Rx...\n");
ErrorCode = rfalTransceiveBlockingRx(Handle, rxBuf, rxBufLen, &actLen);
if (ErrorCode != NoError) CheckErrorCode(Handle, ErrorCode);
Here txBuf array contains command bytes to send: 'E0 80' - RATS command code and Param byte, '31 73' - CRC-16 value for 'E0 80'.
The card returns 72 bits (actLen = 72) as expected: 6 bytes of ATS value (48 bits in total) + 2 CRC bytes (16 bits in total) + 8 parity bits (1 parity bit for each byte).
I examined content of rxBuf array and the principle of data and parity bits placement in rxBuf array was understood.
My next step - similar to data and parity bits placement in rxBuf I prepared content of txBuf for RATS command with manually calculated parity bits and CRC bytes and tried several Tx functions from DLL to send RATS command:
1. Using function rfalTransceiveBlockingTx() with flag RFAL_TXRX_FLAGS_PAR_TX_NONE is set.
memcpy(txBuf, "\xE0\x00\xC5\x98\x03", 5);
flags = (RFAL_TXRX_FLAGS_NFCIP1_OFF | RFAL_TXRX_FLAGS_AGC_OFF | RFAL_TXRX_FLAGS_PAR_RX_KEEP | RFAL_TXRX_FLAGS_CRC_RX_KEEP | RFAL_TXRX_FLAGS_CRC_TX_MANUAL | RFAL_TXRX_FLAGS_PAR_TX_NONE);
txBufLen = 4; // expressed in number of bytes
printf("Tx...\n");
ErrorCode = rfalTransceiveBlockingTx(Handle, txBuf, txBufLen, flags, fwt);
if (ErrorCode != NoError) CheckErrorCode(Handle, ErrorCode);
printf("Rx...\n");
ErrorCode = rfalTransceiveBlockingRx(Handle, rxBuf, rxBufLen, &actLen);
if (ErrorCode != NoError) CheckErrorCode(Handle, ErrorCode);
2. Using function rfalStartTransceive() with flag RFAL_TXRX_FLAGS_PAR_TX_NONE is set.
memcpy(txBuf, "\xE0\x00\xC5\x98\x03", 5);
flags = (RFAL_TXRX_FLAGS_NFCIP1_OFF | RFAL_TXRX_FLAGS_AGC_OFF | RFAL_TXRX_FLAGS_PAR_RX_KEEP | RFAL_TXRX_FLAGS_CRC_RX_KEEP | RFAL_TXRX_FLAGS_CRC_TX_MANUAL | RFAL_TXRX_FLAGS_PAR_TX_NONE);
txBufLen = 36; // expressed in number of bits
printf("Tx...\n");
ErrorCode = rfalStartTransceive(Handle, txBuf, txBufLen, flags, fwt);
if (ErrorCode != NoError) CheckErrorCode(Handle, ErrorCode);
printf("Rx...\n");
ErrorCode = rfalTransceiveBlockingRx(Handle, rxBuf, rxBufLen, &actLen);
if (ErrorCode != NoError) CheckErrorCode(Handle, ErrorCode);
In both cases the card does not returns any response. Function CheckErrorCode (after calling rfalTransceiveBlockingRx) prints "Error Timeout".
One more thing. If assume that I make a mistake with the placements or values of the data and parity bits in txBuf array (but the total number of bits is still correct - 36 bits) the card should response with 4 bit error code anyway. Unfortunately the card does not returns anything. I guess for some reason ST25R3911B-DISCO does not send correct number of bits in the command.
I would be grateful for any help!
