中级会员
 
- 积分
- 277
- 金钱
- 277
- 注册时间
- 2020-1-19
- 在线时间
- 94 小时
|
1金钱
如下的测试代码,寻卡模式使用的是寻天线区内未进入休眠状态的卡PICC_REQIDL,然后使用6张卡进行测试,其中四张卡读写均正常且执行PcdHalt()后可以正常休眠不再被下次循环寻卡,但是其中两张卡测试的时候发现无法被寻卡,然后把寻卡模式改为寻天线区内全部卡PICC_REQALL后,这两张卡又可以被寻卡,且读写正常,请问这种情况是程序有问题还是卡本身坏了
- void RC522_Handel(void)
- {
- status = PcdRequest(PICC_REQIDL, CT); /*寻卡*/
- if(status == MI_OK) //寻卡成功
- {
- status = MI_ERR;
- status = PcdAnticoll(SN);/*防冲撞*/
- }
- if (status == MI_OK) //防冲撞成功
- {
- printf ("The Card ID is: %02X%02X%02X%02X\r\n", SN [0], SN [1], SN [2], SN [3] ); //打印卡片ID
- status = MI_ERR;
- status = PcdSelect(SN);
- }
- if(status == MI_OK) //选卡成功
- {
- status = MI_ERR;
- status = PcdAuthState(PICC_AUTHENT1A, 4, KeyValue, SN);
- }
- if(status == MI_OK) //验证成功
- {
- status = MI_ERR;
- status = PcdReadString(4,data_r);
- if(PcdHalt())
- {
- printf("卡已休眠\r\n");
- }
- }
- if(status == MI_OK) //读卡成功
- {
- status = MI_ERR;
- for(j=0;j<16;j++)
- {
- printf("%0x ",data_r[j]);
- }
- printf("\r\n");
- printf("%s\r\n",data_r);
- }
- }
复制代码 |
|