tag 标签: em4100

相关博文
  • 热度 18
    2011-9-2 10:00
    3266 次阅读|
    3 个评论
    Build the even parity bit for EM4100 format of RFID   Developing the EM4100 protocol of RFID, we have to understand the means of EVEN PARITY BIT of the whole 64-byte data. From http://www.priority1design.com.au/em4100_protocol.html , we know that we must calc 10 goups even parity bit, and 4 column party bits. But it is not Clear for the document to understand how to build even parity bit?   In our code, we just suppose the even parity rule as follow: RULE: The Even Parity Bit SHOULD BE to add all data waiting to be read, then check the sum is whether even or odd. If sum is even, then data is ok. Or we should discard the wrong EM4100 format data.   The EM4100 format:   The even parity checking code as below: // rfid_check_even_parity_bit: Suppose we had received whole EM4100 64-byte data bool rfid_check_even_parity_bit(U8* buf) {         // check 10 groups even parity bits         U32 sum = 0;         U32 i = 0, j = 0;         for(i=0; i10; i++) {             sum = buf + buf + buf + buf ;             sum = sum 0x01;             if(sum != buf ) { return FALSE; }         }                 // check 4 column parity bits         for(i=0; i4; i++) {             sum = 0;             for(j=0; j10; j++)                 sum += buf ;             sum = sum 0x01;             if(sum != buf ) { return FALSE; }         }                 return TRUE; }     Why build even parity bit here? We suppose, there are 9's '1' bits as head. If the card data is 0xff. If we use odd parity bit here, then two 0xff will build new 9's '1' bits, whch perhaps will bring us a wrong head. Then the even parity will give '0' bit follow 4's '1' bits(0xff). So the 9's '1' will be the only head in the whole 64-byte EM4100 data.   Written by Allen Zhan 2011.09.02 Release on EETC