(使用X-Cube-NFC5中间件RFAL)。
我没有从发送到卡的APDU命令得到任何响应。 (也没有我使用的rfalIsoDep函数的错误代码)。
我选择了NFC卡并将其激活。我写了一个函数将APDU命令发送到PICC。
调用rfalIsoDepGetApduTransceiveStatus()直到它不再忙,我发现rxbufferLength为0。
我希望即使我的APDU命令不正确,我至少应该得到0x90 0x00的响应。
我已将rfalWorker()添加到我的循环中
rfalIsoDepGetApduTransceiveStatus()as
我认为它是响应所必需的。另外:根据文档(rfal.chm + x-cube-nfc5.chm),rfal正在修改Txbuffer.prologue,还是我还要配置它?
在任何示例中我都看不到需要配置序言。
代码如下:
错误=
rfalIsoDepPollAHandleActivation
(RFAL_COMPLIANCE_MODE_NFC_11,RFAL_ISODEP_FSXI_512,RFAL_ISODEP_NO_DID,RFAL_BR_424,&安培; isoDepDevice);
if(err!= ERR_NONE)返回false;
rfalIsoDepApduTxRxParam myParam;
//传递给rfalIsoDepStartApduTransceive(param)的Param
rfalIsoDepApduBufFormat apduCommand; //包含序言+ APDU缓冲区的结构
rfalIsoDepApduBufFormat apduResponse; //包含序言+ APDU缓冲区的结构
uint8_t DDF2 [] ='2PAY.SYS.DDF01';
uint8_t headerLen = 5;
uint16_t
ddflen = sizeof(DDF2);
//设置APDU命令
APDU
命令
.apdu [0] = 0x00; // CLA
APDU
命令
.apdu [1] = 0xA4; // INS
APDU
命令
.apdu [2] = 0x04; // P1
APDU
命令
.apdu [3] = 0x00; // P2
APDU
命令
.apdu [4] = ddflen - 1; // P2
// INS
for(uint8_t i; i< ddflen; i ++){
APDU
命令
.apdu [i + headerLen] = DDF2 ;
}
myParam.FWT = isoDepDevice.info.FWT;
myParam.dFWT = isoDepDevice.info.dFWT;
myParam.FSx = RFAL_ISODEP_FSX_KEEP;
//myParam.FSx = isoDepDevice.info.FSx;
myParam.DID = isoDepDevice.info.DID;
// RFAL_ISODEP_NO_DID
myParam.ourFSx = isoDepDevice.info.FSx;
myParam.txBuf =&
APDU
命令
;
myParam.rxBuf =&
APDU
响应
;
myParam.rxBufLen =& myADPURxLen;
myParam.txBufLen = ddflen;
错误=
rfalIsoDepStartApduTransceive
(myParam
);
for(uint8_t b = 0; b 以下为原文
Hi All. I am Using The Nucelo-NFC5A1(ST25R3911B) board with STM32-Nuceo-F410RE board.
(Using the X-Cube-NFC5 middleware RFAL).
I am not getting any responses from my APDU commands sent to a card. ( Also no Error Codes from the rfalIsoDep functions I use).
I have selected the NFC card and activated it. I have written a function to send the APDU command to the PICC.
After calling the rfalIsoDepGetApduTransceiveStatus() until it is not busy anymore, I find that the rxbufferLength is 0.
I would expect that even when my APDU command is incorrect, I should at least get a response of 0x90 0x00.
I have added rfalWorker() into my loop for
rfalIsoDepGetApduTransceiveStatus() as
I assume it is required for the response.Also: According to documentation(rfal.chm + x-cube-nfc5.chm), the rfal is modifying the Txbuffer.prologue, or should I also configure this?
I could not see in any example that the prologue needs to be configured.
code is as folllows:
err =
rfalIsoDepPollAHandleActivation
(RFAL_COMPLIANCE_MODE_NFC_11,RFAL_ISODEP_FSXI_512,RFAL_ISODEP_NO_DID,RFAL_BR_424,&isoDepDevice);
if( err != ERR_NONE ) return false;
rfalIsoDepApduTxRxParam myParam;
//Param to be passed to rfalIsoDepStartApduTransceive(param)
rfalIsoDepApduBufFormat apduCommand; // Struct that contains prologue + APDU Buffer
rfalIsoDepApduBufFormat apduResponse; // Struct that contains prologue + APDU Buffer
uint8_t DDF2[] = '2PAY.SYS.DDF01';
uint8_t headerLen = 5;
uint16_t
ddflen = sizeof(DDF2);
//Setup APDU Command
apdu
Command
.apdu[0] = 0x00; //CLA
apdu
Command
.apdu[1] = 0xA4; //INS
apdu
Command
.apdu[2] = 0x04; //P1
apdu
Command
.apdu[3] = 0x00; //P2
apdu
Command
.apdu[4] = ddflen - 1; //P2
//INS
for (uint8_t i;i
apdu
Command
.apdu[i + headerLen]= DDF2;
}
myParam.FWT = isoDepDevice.info.FWT;
myParam.dFWT = isoDepDevice.info.dFWT;
myParam.FSx = RFAL_ISODEP_FSX_KEEP;
//myParam.FSx = isoDepDevice.info.FSx;
myParam.DID = isoDepDevice.info.DID;
// RFAL_ISODEP_NO_DID
myParam.ourFSx = isoDepDevice.info.FSx;
myParam.txBuf = &
apdu
Command
;
myParam.rxBuf = &
apdu
Response
;
myParam.rxBufLen = &myADPURxLen;
myParam.txBufLen = ddflen;
err =
rfalIsoDepStartApduTransceive
(myParam
);
for (uint8_t b=0;b<30;b++)
{
rfalWorker();
result =
rfalIsoDepGetApduTransceiveStatus();
if (result == ERR_BUSY) {
logUsart('.');
HAL_Delay(250);
}
if (result == ERR_NONE) {
logUsart('RX Done rn');
break;
}
}
logUsart('R-APDU responded with %d Bytes rn',
myADPURxLen
);
//Here I receive 0 Bytes in the rxBuflen field
#x-nucleo-nfc05a1 #st25r3911b #iso14443a-iso-dep #rfal #apdu #x-cube-nfc5