完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
电子发烧友论坛|
嗨..我正在使用ST25R3911向卡发送APDU命令并获得有效响应。
我使用ST-CubeMX的HAL驱动程序和中间件(CPU = STM32F401RE) 一旦我尝试发送另一个APDU命令(或者甚至再次发送同一个命令),我就从卡中接收0个字节。 我从rfalIsoDepPollAHandleActivation()开始 然后我设置了可能的参数(rfalIsoDepApduTxRxParam) 然后我发送了我的第一个APDU命令。 (rfalIsoDepApduBufFormat) err = rfalIsoDepStartApduTransceive(myParam); 然后我在rfalworker()的循环中等待响应 for(int i = 0; i< TIMEOUT; i ++) { //运行RFAL Worker rfalWorker(); err = rfalIsoDepGetApduTransceiveStatus(); //检查APDU Transceive的状态 if(err == ERR_NONE) { logUsart('APDU Transceive Success r n'); rfalWorker(); HAL_Delay(20); 打破; } HAL_Delay(20); if(err == ERR_BUSY) { logUsart( ''); } } 收到我的rxBuf数据后, 我更改txBufLen和apdu命令并将数据发送到卡,但现在我得到0字节返回。 如果我发送相同的apdu命令到卡我也得到0字节返回。 我的第一个apdu发送代码与第二个apdu发送代码完全相同。 我还在加载下一个C-APDU之前清除了我的Rx和Tx APDU缓冲区。 ST_MEMSET(安培; apduCommand.apdu,0×00,的sizeof(apduCommand.apdu)); ST_MEMSET(安培; apduResponse.apdu,0×00,的sizeof(apduResponse.apdu)); 我还缺少其他初始化或参数设置吗? 我相信我不应该试着跑 rfalIsoDepPollAHandleActivation()再次(在下一个APDU Transceive之前)因为我没有以任何方式断开卡。 #send-apdu #NFC#st25r3911b #apdu 以上来自于谷歌翻译 以下为原文 Hi .. I am currently sending an APDU Command to a card with the ST25R3911 and get a valid response. I use the HAL drivers and middleware from ST-CubeMX ( CPU = STM32F401RE) As soon as I try to send another APDU command ( or even the same one again) I receive 0 bytes from the card. I start With rfalIsoDepPollAHandleActivation() then i set up may parameters (rfalIsoDepApduTxRxParam) then I send my first APDU Command. (rfalIsoDepApduBufFormat) err = rfalIsoDepStartApduTransceive(myParam); then I wait for the response in a loop with rfalworker() for (int i=0;i { // Run the RFAL Worker rfalWorker(); err = rfalIsoDepGetApduTransceiveStatus(); //Check The Status of the APDU Transceive if (err == ERR_NONE) { logUsart('APDU Transceive Successrn'); rfalWorker(); HAL_Delay(20); break; } HAL_Delay(20); if (err == ERR_BUSY) { logUsart('.'); } } after I received my rxBuf data, I change the txBufLen and apdu command and send the data to the card, but now i get 0 bytes returned. also if i send the same apdu command to the card I also get 0 bytes returned. my first apdu sending code is exactly the same as the second apdu sending code. I also clear my Rx and Tx APDU buffers before loading the next C-APDU. ST_MEMSET(&apduCommand.apdu,0x00,sizeof(apduCommand.apdu)); ST_MEMSET(&apduResponse.apdu,0x00,sizeof(apduResponse.apdu)); Is there any other initialization or, setting of parameters, that I am missing ? I believe that I should not try to run rfalIsoDepPollAHandleActivation() again (before the next APDU Transceive) as I am not disconnecting the card in any way. #send-apdu #nfc #st25r3911b #apdu |
|
相关推荐
4个回答
|
|
|
嗨马吕斯,
是的,你不应该尝试重新激活卡。 不确定发生了什么,但有一些想法可以获得更多信息: 我假设您将激活期间收到的参数(rfalIsoDepDevice-> DID,FWT,dFWT和FsX)输入rfalIsoDepApduTxRxParam?你的错误变量的值是什么 - 当它既不是ERR_None也不是ERR_Busy?Hal_Delay(20)太大,如果收到的APDU大于90 + x字节那么这将溢出ST25R3911BRegards的FIFO,尤利西斯 以上来自于谷歌翻译 以下为原文 Hi Marius, yes, you should not try to reactivate the card. Not sure what is happening but a few ideas for more information:
|
|
|
|
|
|
嗨尤利西斯
谢谢您的回复。 是的,激活后我使用从tfalIsoDepDevice返回的参数 错误= rfalIsoDepPollAHandleActivation(RFAL_COMPLIANCE_MODE_NFC_11,RFAL_ISODEP_FSXI_512,RFAL_ISODEP_NO_DID,RFAL_BR_424, &安培; isoDepDevice ); myParam.DID = RFAL_ISODEP_NO_DID; //isoDepDevice.info.DID; // myParam.FWT = isoDepDevice.info.FWT; myParam.dFWT = isoDepDevice.info.dFWT; myParam.FSx = isoDepDevice.info.FSx; myParam.ourFSx = RFAL_ISODEP_FSX_KEEP; myParam.txBuf =& apduCommand; myParam.txBufLen = apduTxLen; myParam.rxBufLen =& apduRxLen; myParam.rxBuf =& apduResponse;在向卡发送第二个APDU时: 当我发送err = rfalIsoDepStartApduTransceive(myParam)时,我得到No error; 我使用'for'例程运行(35次。我后来将其更改为350次)以获得Transceive状态。 所以经过350次调用rfalWorker();和rfalIsoDepGetApduTransceiveStatus(); 在350个循环后我仍然得到ERR_BUSY。 (我对第二个APDU命令的响应应该与我发送的第一个apdu命令的大小相同或更大) 我已经用HAL_Delay(1)的延迟改变了我的循环并且重试了2000(TIMEOUT = 2000) for(int i = 0; i< TIMEOUT; i ++) { err = rfalIsoDepGetApduTransceiveStatus(); //检查APDU Transceive的状态 HAL_Delay(1); //运行RFAL Worker rfalWorker(); if(err == ERR_NONE) { logUsart('APDU Transceive Success r n'); rfalWorker(); HAL_Delay(1); 打破; } HAL_Delay(1); if(err == ERR_BUSY) { // logUsart('。'); } } //用于循环结束 logUsart('AID接收缓冲区有%d字节 r n',apduRxLen); if(apduRxLen> 0) { logUsart('Rx数据:%s r n',hex2Str(apduResponse.apdu,apduRxLen)); 为了确保,我在发送第二个APDU命令之前在Param结构中再次编写了所有参数。 myParam.txBuf =& apduCommand; //& apduCommand; myParam.txBufLen = apduTxLen; myParam.rxBufLen =& apduRxLen; myParam.rxBuf =& apduResponse; myParam.DID = RFAL_ISODEP_NO_DID; // isoDepDevice.info.DID; // myParam.FWT = isoDepDevice.info.FWT; myParam.dFWT = isoDepDevice.info.dFWT; myParam.FSx = isoDepDevice.info.FSx; myParam.ourFSx = RFAL_ISODEP_FSX_KEEP; 但是仍然没有对第二个apdu命令做出响应(同样,我在时间问题的情况下从ERR_BUSY中删除了USART写入命令)但是仍然在ERR_BUSY上。 以上来自于谷歌翻译 以下为原文 HI Ulysses Thank you for your reply. Yes, After Activation I use the parameters returned from tfalIsoDepDevice err = rfalIsoDepPollAHandleActivation(RFAL_COMPLIANCE_MODE_NFC_11,RFAL_ISODEP_FSXI_512,RFAL_ISODEP_NO_DID,RFAL_BR_424, &isoDepDevice ); myParam.DID = RFAL_ISODEP_NO_DID; //isoDepDevice.info.DID; // myParam.FWT = isoDepDevice.info.FWT; myParam.dFWT = isoDepDevice.info.dFWT; myParam.FSx = isoDepDevice.info.FSx; myParam.ourFSx = RFAL_ISODEP_FSX_KEEP ; myParam.txBuf = &apduCommand; myParam.txBufLen = apduTxLen; myParam.rxBufLen = &apduRxLen; myParam.rxBuf = &apduResponse;On Sending a Second APDU to the Card : I get No error when I transmit err = rfalIsoDepStartApduTransceive(myParam); I Use a 'for' routine that runs ( 35 times. I later changed it to 350 times) to get the Transceive status. So after 350 times calling the rfalWorker(); and rfalIsoDepGetApduTransceiveStatus(); I still get ERR_BUSY after the 350 cycles. ( My response for the second APDU Command should be more or the same size as the first apdu command that I have sent) I have changed my loop with a delay of HAL_Delay(1) and retries of 2000 ( TIMEOUT = 2000) for (int i=0;i { err = rfalIsoDepGetApduTransceiveStatus(); //Check The Status of the APDU Transceive HAL_Delay(1); // Run the RFAL Worker rfalWorker(); if (err == ERR_NONE) { logUsart('APDU Transceive Successrn'); rfalWorker(); HAL_Delay(1); break; } HAL_Delay(1); if (err == ERR_BUSY) { // logUsart('.'); } } // for loop end logUsart('AID Receive Buffer have %d Bytesrn',apduRxLen); if (apduRxLen > 0) { logUsart('Rx Data: %srn',hex2Str(apduResponse.apdu,apduRxLen)); }Just to be sure, I have written the all parameters again in the Param struct before sending the second APDU comand. myParam.txBuf = &apduCommand;// &apduCommand; myParam.txBufLen = apduTxLen; myParam.rxBufLen = &apduRxLen; myParam.rxBuf = &apduResponse; myParam.DID = RFAL_ISODEP_NO_DID;//isoDepDevice.info.DID; // myParam.FWT = isoDepDevice.info.FWT; myParam.dFWT = isoDepDevice.info.dFWT; myParam.FSx = isoDepDevice.info.FSx; myParam.ourFSx = RFAL_ISODEP_FSX_KEEP ; but still no response on the second apdu command, ( also,I removed the USART Write command from ERR_BUSY in case of timing issues) but stays on ERR_BUSY. |
|
|
|
|
|
嗨马吕斯,
看起来像司机的状态机没有前进。也许在中断移植中存在问题。你能拿一个万用表测量ST25R3911B的INT引脚吗?如果它很高,那么ISR不会被执行。 问候,尤利西斯 以上来自于谷歌翻译 以下为原文 Hi Marius, looks like the state machine of the driver is not advancing. Maybe an issue in the interrupt porting. Can you grab a multimeter and measure the INT pin of ST25R3911B? If it is high then the ISR is not exexuted. Regards, Ulysses |
|
|
|
|
|
嗨尤利西斯。谢谢。
我将在SPI Pins和INT Pin上连接我的逻辑分析仪,看看发生了什么。 因为向卡发送和接收第一个APDU是好的,这很奇怪,但是当我尝试向卡发送另一个命令时,我没有得到任何回复(ERR_BUSY)。 以上来自于谷歌翻译 以下为原文 Hi Ulysses. Thank you. I will connect my logic analyser on the SPI Pins and INT Pin to see what is happening. Cause it is strange that sending and receiving the first APDU to the card is good, but as soon as I try to send another command to the card I get no response back (ERR_BUSY). |
|
|
|
|
只有小组成员才能发言,加入小组>>
stm32mp157的异核通信的rpmsg_sdb的m4固件和a7驱动该如何编写?
1453 浏览 0 评论
stm32f103用freertos对一个采样率为1kHz的传感器,进行采样,数据出差
1502 浏览 0 评论
请教:在使用UDE STK时,单片机使用SPC560D30L1,在配置文件怎么设置或选择?里面只有SPC560D40的选项
3649 浏览 1 评论
3842 浏览 1 评论
请问是否有通过UART连接的两个微处理器之间实现双向值交换的方法?
2461 浏览 1 评论
STM32H7打开DCache后,出现了串口接收信息为空的现象,是哪里出了问题?
727浏览 5评论
用NANO STM32F103RBT6的开发板烧录不了是哪里出了问题?
661浏览 5评论
710浏览 5评论
外部中断触发类型为双边沿触发,进入中断回调后有什么办法判断该边沿是上升沿还是下降沿?
941浏览 5评论
STM32L071CBT6低温环境下无法正常工作是什么原因引起的?
745浏览 5评论
/9
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-12-2 03:33 , Processed in 0.873686 second(s), Total 78, Slave 61 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191

淘帖
533