?? zlg500s_test.c
字號:
#define PcdTest_globals
#include "config.h"
#include "zlg500S_comm.h"
#include "zlg500S.h"
#include "zlg500S_test.h"
#define LED1 (1<<10)
#define LED2 (1<<11)
#define LED3 (1<<12)
#define LED4 (1<<13)
//INT8U Key[6] = {0xff,0xff,0xff,0xff,0xff,0xff};
INT8U Status;
INT8U DataBfr[16];
INT8U Card_Snr[4];
INT8U TxMode;
INT8U Atq[2];
INT8U Sak;
void PcdTest(void)
{
INT8U temp;
ZLG500S_COMM_Init();
IODIR |= LED1 | LED2 | LED3 | LED4;
IOSET = LED1 | LED2 | LED3 | LED4;
GetDvcInfo(DataBfr);
DataBfr[0] = 0xff;
DataBfr[1] = 0xff;
DataBfr[2] = 0xff;
DataBfr[3] = 0xff;
DataBfr[4] = 0xff;
DataBfr[5] = 0xff;
PCDLoadKey(KEYA,0,DataBfr);
while(1)
{
if(PiccRequest(REQSTD,DataBfr) != OK) continue; //從請求
if(PiccAnticoll(SELCODE1,0,Card_Snr)!=OK) continue; //訪碰撞
if(PiccSelect(SELCODE1,Card_Snr,DataBfr)!=OK) continue; //選擇
if(PiccAuthE2(KEYA,Card_Snr,0,4)!=OK) continue; //驗證塊4
if(PiccRead(4,DataBfr)!=OK) continue; //讀塊4
DataBfr[0] = 0x10; DataBfr[4] = 0xef; DataBfr[8] = 0x10;
DataBfr[1] = 0x0; DataBfr[5] = 0xff; DataBfr[9] = 0x0;
DataBfr[2] = 0x0; DataBfr[6] = 0xff; DataBfr[10] = 0x0;
DataBfr[3] = 0x0; DataBfr[7] = 0xff; DataBfr[11] = 0x0;
DataBfr[12] = 0x04; DataBfr[13] = 0xfb; DataBfr[14] = 0x04; DataBfr[15] = 0xfb;
if(PiccWrite(4,DataBfr)!=OK) continue; //寫值塊4
//DataBfr[0] = 0x0;
if(PiccRead(4,DataBfr)!=OK) continue; //讀值塊4
//DataBfr[0] = 0x01;
//DataBfr[1] = 0x0;
//DataBfr[2] = 0x0;
//DataBfr[3] = 0x0;
if(PiccValue(DECREMENT,4,DataBfr,5)!=OK) continue; //減值塊4至塊5
//if(PiccValue(INCREMENT,4,DataBfr,6)!=OK) continue; //加值塊4至塊6
if(PiccRead(5,DataBfr)!=OK) continue; //讀值塊5
if(PiccRead(6,DataBfr)!=OK) continue; //讀值塊6
PiccHalt(); //將卡掛起
IOCLR = LED1;
LedDly = 20;
while(LedDly);
IOSET = LED1;
//測試卡自動檢測----不連續檢測,卡不掛起,TX交替,E2密碼驗證,密鑰A,讀4塊
DataBfr[0] = 0;
while(PiccAutoDetect(0, ADTXALERT, REQSTD, 'E', KEYA, DataBfr, 4) != 0);
while(PiccADRcv(&TxMode,Atq,&Sak,Card_Snr,DataBfr) != 0);
DataBfr[0] = 0x10; DataBfr[4] = 0xef; DataBfr[8] = 0x10;
DataBfr[1] = 0x0; DataBfr[5] = 0xff; DataBfr[9] = 0x0;
DataBfr[2] = 0x0; DataBfr[6] = 0xff; DataBfr[10] = 0x0;
DataBfr[3] = 0x0; DataBfr[7] = 0xff; DataBfr[11] = 0x0;
DataBfr[12] = 0x04; DataBfr[13] = 0xfb; DataBfr[14] = 0x04; DataBfr[15] = 0xfb;
if(PiccWrite(4,DataBfr)!=OK) continue;
DataBfr[0] = 0x0;
if(PiccRead(4,DataBfr)!=OK) continue;
DataBfr[0] = 0x01;
DataBfr[1] = 0x0;
DataBfr[2] = 0x0;
DataBfr[3] = 0x0;
if(PiccValue(DECREMENT,4,DataBfr,5)!=OK) continue;
if(PiccValue(INCREMENT,4,DataBfr,6)!=OK) continue;
if(PiccRead(5,DataBfr)!=OK) continue;
if(PiccRead(6,DataBfr)!=OK) continue;
PiccHalt();
IOCLR = LED2;
LedDly = 20;
while(LedDly);
IOSET = LED2;
//測試卡自動檢測----發回后繼續檢測,檢測后將卡掛起,TX全發送,直接密碼驗證,密鑰A,讀4塊
DataBfr[0] = 0xff; DataBfr[1] = 0xff; DataBfr[2] = 0xff;
DataBfr[3] = 0xff; DataBfr[4] = 0xff; DataBfr[5] = 0xff;
while(PiccAutoDetect(ADCONTINUE | ADHALT, ADALLTX, REQSTD, 'F', KEYA, DataBfr, 4) != 0);
temp = 3;
while(temp)
{
if(PiccADRcv(&TxMode,Atq,&Sak,Card_Snr,DataBfr) == 0)
{
temp--;
IOCLR = LED3;
LedDly = 20;
while(LedDly);
IOSET = LED3;
}
}
PiccReadADDT(ADRFU,&TxMode,Atq,&Sak,Card_Snr,DataBfr);
//測試卡自動檢測----不連續檢測,檢測后將卡掛起,TX全發送,直接密碼驗證,密鑰A,讀4塊
DataBfr[0] = 0xff; DataBfr[1] = 0xff; DataBfr[2] = 0xff;
DataBfr[3] = 0xff; DataBfr[4] = 0xff; DataBfr[5] = 0xff;
while(PiccAutoDetect(ADHALT, ADALLTX, REQSTD, 'F', KEYA, DataBfr, 4) != 0);
temp = 3;
while(temp)
{
if(!zlg500S_Int)
{ //讀回數據,繼續檢測
if(PiccReadADDT(ADRFU | ADREENABLE,&TxMode,Atq,&Sak,Card_Snr,DataBfr) == 0)
{
temp--;
IOCLR = LED4;
LedDly = 20;
while(LedDly);
IOSET = LED4;
}
}
}
PiccReadADDT(ADRFU,&TxMode,Atq,&Sak,Card_Snr,DataBfr); //讀回數據,停止檢測
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -