Merge pull request #84 from marshmellow42/master

EM410x bug fix
This commit is contained in:
Martin Holst Swende 2015-03-25 11:10:51 +01:00
commit 062e28912c
3 changed files with 46 additions and 51 deletions

View file

@ -896,6 +896,7 @@ void CmdEM410xdemod(int findone, int *high, int *low, int ledcontrol)
//Dbprintf("DEBUG: No Tag");
}
WDT_HIT();
hi = 0;
lo = 0;
clk=0;
invert=0;

View file

@ -280,14 +280,13 @@ void printEM410x(uint32_t hi, uint64_t id)
}
if (hi){
//output 88 bit em id
PrintAndLog("EM TAG ID : %06x%016llx", hi, id);
PrintAndLog("\nEM TAG ID : %06x%016llx", hi, id);
} else{
//output 40 bit em id
PrintAndLog("EM TAG ID : %010llx", id);
PrintAndLog("\nEM TAG ID : %010llx", id);
PrintAndLog("Unique TAG ID : %010llx", id2lo);
PrintAndLog("");
PrintAndLog("Possible de-scramble patterns");
PrintAndLog("HoneyWell IdentKey");
PrintAndLog("\nPossible de-scramble patterns");
PrintAndLog("HoneyWell IdentKey {");
PrintAndLog("DEZ 8 : %08lld",id & 0xFFFFFF);
PrintAndLog("DEZ 10 : %010lld",id & 0xFFFFFFFF);
PrintAndLog("DEZ 5.5 : %05lld.%05lld",(id>>16LL) & 0xFFFF,(id & 0xFFFF));
@ -296,7 +295,6 @@ void printEM410x(uint32_t hi, uint64_t id)
PrintAndLog("DEZ 3.5C : %03lld.%05lld",(id & 0xFF0000) >> 16,(id & 0xFFFF));
PrintAndLog("DEZ 14/IK2 : %014lld",id);
PrintAndLog("DEZ 15/IK3 : %015lld",id2lo);
PrintAndLog("Other : %05lld_%03lld_%08lld",(id&0xFFFF),((id>>16LL) & 0xFF),(id & 0xFFFFFF));
PrintAndLog("DEZ 20/ZK : %02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld%02lld",
(id2lo & 0xf000000000) >> 36,
(id2lo & 0x0f00000000) >> 32,
@ -309,9 +307,8 @@ void printEM410x(uint32_t hi, uint64_t id)
(id2lo & 0x00000000f0) >> 4,
(id2lo & 0x000000000f)
);
PrintAndLog("");
uint64_t paxton = (((id>>32) << 24) | (id & 0xffffff)) + 0x143e00;
PrintAndLog("}\nOther : %05lld_%03lld_%08lld",(id&0xFFFF),((id>>16LL) & 0xFF),(id & 0xFFFFFF));
PrintAndLog("Pattern Paxton : %0d", paxton);
uint32_t p1id = (id & 0xFFFFFF);
@ -400,8 +397,8 @@ int CmdAskEM410xDemod(const char *Cmd)
PrintAndLog(" : data askem410xdemod 64 1 0 = demod an EM410x Tag ID from GraphBuffer using a clock of RF/64 and inverting data and allowing 0 demod errors");
return 0;
}
uint32_t hi;
uint64_t lo;
uint32_t hi = 0;
uint64_t lo = 0;
if (AskEm410xDemod(Cmd, &hi, &lo)) {
PrintAndLog("EM410x pattern found: ");
printEM410x(hi, lo);

View file

@ -88,26 +88,24 @@ uint8_t Em410xDecode(uint8_t *BitStream, size_t *size, size_t *startIdx, uint32_
return 0;
}
// 111111111 bit pattern represent start of frame
uint8_t preamble[] = {1,1,1,1,1,1,1,1,1};
// include 0 in front to help get start pos
uint8_t preamble[] = {0,1,1,1,1,1,1,1,1,1};
uint32_t idx = 0;
uint32_t parityBits = 0;
uint8_t errChk = 0;
uint8_t FmtLen = 10;
*startIdx = 0;
for (uint8_t extraBitChk=0; extraBitChk<5; extraBitChk++){
errChk = preambleSearch(BitStream+extraBitChk+*startIdx, preamble, sizeof(preamble), size, startIdx);
if (errChk == 0) return 0;
errChk = preambleSearch(BitStream, preamble, sizeof(preamble), size, startIdx);
if (errChk == 0 || *size < 64) return 0;
if (*size > 64) FmtLen = 22;
if (*size<64) return 0;
*startIdx += 1; //get rid of 0 from preamble
idx = *startIdx + 9;
for (i=0; i<FmtLen; i++){ //loop through 10 or 22 sets of 5 bits (50-10p = 40 bits or 88 bits)
parityBits = bytebits_to_byte(BitStream+(i*5)+idx,5);
//check even parity
if (parityTest(parityBits, 5, 0) == 0){
//parity failed try next bit (in the case of 1111111111) but last 9 = preamble
startIdx++;
errChk = 0;
break;
//parity failed quit
return 0;
}
//set uint64 with ID from BitStream
for (uint8_t ii=0; ii<4; ii++){
@ -118,7 +116,6 @@ uint8_t Em410xDecode(uint8_t *BitStream, size_t *size, size_t *startIdx, uint32_
if (errChk != 0) return 1;
//skip last 5 bit parity test for simplicity.
// *size = 64 | 128;
}
return 0;
}