Datasheet
6. Appendix
Appendix 1: CRC Calculation
// this function calculates a CRC16 over a unsigned char Array with, LSB first
// @Param1 (DataBuf): An Array, which contains the Data for Calculation
// @Param2 (SizeOfDataBuf): length of the Data Buffer (DataBuf)
// @Param3 (Polynom): Value of the Generatorpolynom, 0x8408 is recommended
// @Param4 (Initial_Value): load value for CRC16, 0xFFFF is recommended for
// host to reader communication
// return: calculated CRC16
unsigned short GetCrc( unsigned char *DataBuf,
unsigned char SizeOfDataBuf,
unsigned short Polynom,
unsigned short Initial_Value)
{
unsigned short Crc16;
unsigned char Byte_Counter, Bit_Counter;
Crc16 = Initial_Value;
for (Byte_Counter=0; Byte_Counter < SizeOfDataBuf; Byte_Counter++)
{
Crc16^=DataBuf[Byte_Counter];
for (Bit_Counter=0; Bit_Counter<8; j++)
{
if (( Crc16 & 0x0001)==0) Crc16>>=1;
else Crc16=(Crc16>>1)^Polynom;
}
}
return (Crc16);
}
Appendix 2: Error Codes:
Error Code Description
EDX Error Decimal value Expected, or is missing
EHX Error Hexadecimal value Expected, or is missing
IOS Input and Outputblock are not in the same Sector
TNR Tag Not Responding
UPA Unknown Parameter
NMA No MiFare classic chip Authenticated
WDL Wrong Data Length of hex-string-parameter
NDB No Data Block
KBR Key B is Readable
ONE Operation Not Executed
BME Block Mode Error, not 0 or 3 (not writeable with value block function)
metraTec MiFare Protocol Guide Page 32 of 38