switch(RevBuffer[0])//默认为15693协议
{
case 0x01: //寻卡
case 0x24: //写多重块
case 0x26: //重起准备
case 0x27: //写AFI
case 0x29: //写DSFID
case 0x2B: //获得系统信息
case 0x2C: //获得多重块安全状态
command[3] = 0x02; // ISO15693 高速, 单载波, 4出1
break;
case 0x20: //读单一块
command[3] = 0x01; // ISO15693 低速, 单载波, 256出1
break;
case 0x21: //写单一块
case 0x23: //读多重块
command[3] = 0x03; // ISO15693 高速, 单载波, 256出1
break;
}
WriteSingle(command, 4);
DelayMs(5);
DirectCommand(&RevBuffer[0]); //直接写15693协议
switch(RevBuffer[0])
{
case 0x01: //写命令的时候是0X01
flags = 0x06;
ReadUID();
GetUID();
putstr(UID,8);
break;
case 0x20://读单块,写命令的格式是:20 起始块,最好能够写到6个字节,便于下一次写入命令
switch(RevBuffer[2])
{
case 0x00:
ReadSingleBlock(RevBuffer[1]);
break;
case 0x01:
ReadSingleBlockWithAdd(RevBuffer[1]);
break;
}
putstr(Data,4);
break;
case 0x21://写单块,写命令的格式是:21 起始块 数据,总共6个字节
WriteSingleBlock(RevBuffer[1]);
putstr("1111",4);
break;
case 0x23://读两块,写命令的格式是:23 起始块 块的数量,最好能够写6个字节,便于下一次写入命令,
//FIFO为12个字节,所以每次最多读两块,即8个字节
ReadMultipleBlock(RevBuffer[1],RevBuffer[2]);//Bsize为1,表示读两块,即读的块数是(Bsize+1)
putstr(Data,(RevBuffer[2])*4);
break;
case 0x24://写多块,写命令的格式是:24 起始块 块的数量
WriteMultipleBlock(RevBuffer[1],RevBuffer[2]);
putstr("88888888",8);
break;
case 0x26://复位准备
ResetToReday();
putstr("98979561",8);
break;
case 0x27://写AFI,应用族识别符,应用的卡预选准则
//命令格式为:27 AFI
WriteAFI(RevBuffer[1]);
putstr("RevBuffer[1]",4);
break;
case 0x29://写DSFID,DSFID指明了应答器存储的数据结构
//命令格式为:29 DSFID
WriteDSFID(RevBuffer[1]);
putstr("RevBuffer[1]",4);
break;
case 0x2B://获取系统信息,返回值的格式说明:
//00 = no error,
//0F=Tag reference field present,Tag memory field present,Tag AFI field present,Tag DSFID field present
//6EADD606000007E0 : Reverse byte ordered.Normal UID byte order is EO 07 00 00 06 D6 AD 6E.
//19 : Data Storage Format ID
//33 : AFI
//3F 03 88 : 3F meaning number of blocks = 64,03 meaning block size = 32 bits,8F defined by tag manufacturer
GetSystemInfo();
putstr(Data,15);
break;
case 0x2C:
//命令格式是:2c 起始块 块的大小
//获得多块的安全状态,返回值格式说明
//00 :00 no tag error,
//00 : 00 security status of block number 00 (block #1),
//00 : 00 security status of block number 01 (block #2),
GetMult_BlkSelStatus(RevBuffer[1],RevBuffer[2]);
putstr(Data,RevBuffer[2]+1);