ADD: AWID 50bit demod

This commit is contained in:
iceman1001 2016-05-13 22:52:25 +02:00
parent 204b708424
commit c5e8b91696

View file

@ -270,7 +270,7 @@ void AcquireTiType(void)
AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(32) | AT91C_SSC_MSBF; AT91C_BASE_SSC->SSC_RFMR = SSC_FRAME_MODE_BITS_IN_WORD(32) | AT91C_SSC_MSBF;
AT91C_BASE_SSC->SSC_TCMR = 0; AT91C_BASE_SSC->SSC_TCMR = 0;
AT91C_BASE_SSC->SSC_TFMR = 0; AT91C_BASE_SSC->SSC_TFMR = 0;
// iceman, FpgaSetupSsc() ?? the code above? can it be replaced?
LED_D_ON(); LED_D_ON();
// modulate antenna // modulate antenna
@ -870,7 +870,6 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
size = removeParity(dest, idx+8, 4, 1, 88); size = removeParity(dest, idx+8, 4, 1, 88);
if (size != 66) continue; if (size != 66) continue;
// ok valid card found!
// Index map // Index map
// 0 10 20 30 40 50 60 // 0 10 20 30 40 50 60
@ -880,37 +879,51 @@ void CmdAWIDdemodFSK(int findone, int *high, int *low, int ledcontrol)
// 00011010 1 01110101 0000000010001110 1 000000000000000000000000000000000 // 00011010 1 01110101 0000000010001110 1 000000000000000000000000000000000
// bbbbbbbb w ffffffff cccccccccccccccc w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx // bbbbbbbb w ffffffff cccccccccccccccc w xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
// |26 bit| |-117--| |-----142------| // |26 bit| |-117--| |-----142------|
//
// 00110010 0 0000011111010000000000000001000100101000100001111 0 00000000
// bbbbbbbb w ffffffffffffffffccccccccccccccccccccccccccccccccc w xxxxxxxx
// |50 bit| |----4000------||-----------2248975-------------|
//
// b = format bit len, o = odd parity of last 3 bits // b = format bit len, o = odd parity of last 3 bits
// f = facility code, c = card number // f = facility code, c = card number
// w = wiegand parity // w = wiegand parity
// (26 bit format shown)
uint32_t fc = 0; uint32_t fc = 0;
uint32_t cardnum = 0; uint32_t cardnum = 0;
uint32_t code1 = 0; uint32_t code1 = 0;
uint32_t code2 = 0; uint32_t code2 = 0;
uint8_t fmtLen = bytebits_to_byte(dest,8); uint8_t fmtLen = bytebits_to_byte(dest,8);
if (fmtLen==26){ switch(fmtLen) {
fc = bytebits_to_byte(dest+9, 8); case 26:
cardnum = bytebits_to_byte(dest+17, 16); fc = bytebits_to_byte(dest + 9, 8);
code1 = bytebits_to_byte(dest+8,fmtLen); cardnum = bytebits_to_byte(dest + 17, 16);
code1 = bytebits_to_byte(dest + 8,fmtLen);
Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo); Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, rawHi2, rawHi, rawLo);
} else { break;
case 50:
fc = bytebits_to_byte(dest + 9, 16);
cardnum = bytebits_to_byte(dest + 25, 32);
code1 = bytebits_to_byte(dest + 8, (fmtLen-32) );
code2 = bytebits_to_byte(dest + 8 + (fmtLen-32), 32);
Dbprintf("AWID Found - BitLength: %d, FC: %d, Card: %d - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, fc, cardnum, code1, code2, rawHi2, rawHi, rawLo);
break;
default:
if (fmtLen > 32 ) {
cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16); cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
if (fmtLen>32){
code1 = bytebits_to_byte(dest+8,fmtLen-32); code1 = bytebits_to_byte(dest+8,fmtLen-32);
code2 = bytebits_to_byte(dest+8+(fmtLen-32),32); code2 = bytebits_to_byte(dest+8+(fmtLen-32),32);
Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo); Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x%08x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, code2, rawHi2, rawHi, rawLo);
} else{ } else {
cardnum = bytebits_to_byte(dest+8+(fmtLen-17), 16);
code1 = bytebits_to_byte(dest+8,fmtLen); code1 = bytebits_to_byte(dest+8,fmtLen);
Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo); Dbprintf("AWID Found - BitLength: %d -unknown BitLength- (%d) - Wiegand: %x, Raw: %08x%08x%08x", fmtLen, cardnum, code1, rawHi2, rawHi, rawLo);
} }
break;
} }
if (findone){ if (findone){
if (ledcontrol) LED_A_OFF(); if (ledcontrol) LED_A_OFF();
return; return;
} }
// reset
idx = 0; idx = 0;
WDT_HIT(); WDT_HIT();
} }