大神好,我在淘宝买了RCC522的IC卡S50的,什么都可以操作,就是除了加减值这个函数实现不了。寻卡,防冲撞,选卡,验证,读写都可以。就是寻卡,防冲撞,选卡,验证,加值不了。
/////////////////////////////////////////////////////////////////////
//¹¦ ÄÜ£º¿Û¿îºÍ³äÖµ
//²ÎÊý˵Ã÷: dd_mode[IN]£ºÃüÁî×Ö
// 0xC0 = ¿Û¿î
// 0xC1 = ³äÖµ
// addr[IN]£ºÇ®°üµØÖ·
// pValue[IN]£º4×Ö½ÚÔö(¼õ)Öµ£¬µÍλÔÚÇ°
//·µ »Ø: ³É¹¦·µ»ØMI_OK
/////////////////////////////////////////////////////////////////////
char PcdValue(unsigned char dd_mode,unsigned char addr,unsigned char *pValue)
{
char status;
unsigned int unLen;
unsigned char i,ucComMF522Buf[MAXRLEN];
ucComMF522Buf[0] = dd_mode;
ucComMF522Buf[1] = addr;
CalulateCRC(ucComMF522Buf,2,&ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE,ucComMF522Buf,4,ucComMF522Buf,&unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{ status = MI_ERR; }
if (status == MI_OK)
{
// memcpy(ucComMF522Buf, pValue, 4);
for (i=0; i<16; i++)
{ ucComMF522Buf[i] = *(pValue+i); }
CalulateCRC(ucComMF522Buf,4,&ucComMF522Buf[4]);
unLen = 0;
status = PcdComMF522(PCD_TRANSCEIVE,ucComMF522Buf,6,ucComMF522Buf,&unLen);
if (status != MI_ERR)
{ status = MI_OK; }
}
if (status == MI_OK)
{
ucComMF522Buf[0] = PICC_TRANSFER;
ucComMF522Buf[1] = addr;
CalulateCRC(ucComMF522Buf,2,&ucComMF522Buf[2]);
status = PcdComMF522(PCD_TRANSCEIVE,ucComMF522Buf,4,ucComMF522Buf,&unLen);
if ((status != MI_OK) || (unLen != 4) || ((ucComMF522Buf[0] & 0x0F) != 0x0A))
{ status = MI_ERR; }
}
return status;
}
|