FIX: adding a test to see if we managed to get the correct demodulation from an unknown t55x7 tag.

By checking if the configuration data (page 0, block 0)  has some settings that must be the same.   think  reserved 7bits, This is a trail and error approach.
But together with setting a manual configuration to read a tag and this automatic verification it will help out alot I think.
This commit is contained in:
iceman1001 2015-03-12 23:04:02 +01:00
parent a8cd503dd5
commit 3e4811c8b7
2 changed files with 38 additions and 15 deletions

View file

@ -218,45 +218,67 @@ int CmdReadBlk(const char *Cmd)
if (CmdDetectClockRate("f")){ //wave is almost certainly FSK if (CmdDetectClockRate("f")){ //wave is almost certainly FSK
// FSK // FSK
if ( FSKrawDemod("0 0", FALSE)) if ( FSKrawDemod("0 0", FALSE) && test())
printT55xx("FSK"); printT55xx("FSK");
// FSK inverted // FSK inverted
if ( FSKrawDemod("0 1", FALSE)) if ( FSKrawDemod("0 1", FALSE) && test())
printT55xx("FSK inv"); printT55xx("FSK inv");
} else { } else {
// ASK/MAN (autoclock, normal, maxerrors 1) // ASK/MAN (autoclock, normal, maxerrors 1)
if ( ASKmanDemod("0 0 1", FALSE, FALSE) ) if ( ASKmanDemod("0 0 1", FALSE, FALSE) && test())
printT55xx("ASK/MAN"); printT55xx("ASK/MAN");
// ASK/MAN (autoclock, inverted, maxerrors 1) // ASK/MAN (autoclock, inverted, maxerrors 1)
if ( ASKmanDemod("0 1 1", FALSE, FALSE) ) if ( ASKmanDemod("0 1 1", FALSE, FALSE) && test())
printT55xx("ASK/MAN Inv"); printT55xx("ASK/MAN Inv");
// NZR (autoclock, normal, maxerrors 1) // NZR (autoclock, normal, maxerrors 1)
if ( NRZrawDemod("0 0 1", FALSE) ) if ( NRZrawDemod("0 0 1", FALSE) && test())
printT55xx("NZR"); printT55xx("NZR");
// NZR (autoclock, inverted, maxerrors 1) // NZR (autoclock, inverted, maxerrors 1)
if ( NRZrawDemod("0 1 1", FALSE) ) if ( NRZrawDemod("0 1 1", FALSE) && test())
printT55xx("NZR inv"); printT55xx("NZR inv");
// PSK (autoclock, normal, maxerrors 1) // PSK (autoclock, normal, maxerrors 1)
if (!PSKDemod("0 0 1", FALSE)) if ( PSKDemod("0 0 1", FALSE) && test())
printT55xx("PSK"); printT55xx("PSK");
// PSK (autoclock, inverted, maxerrors 1) // PSK (autoclock, inverted, maxerrors 1)
if (!PSKDemod("0 1 1", FALSE)) if ( PSKDemod("0 1 1", FALSE) && test())
printT55xx("PSK inv"); printT55xx("PSK inv");
//PSK2? //PSK2?
// if (!BiphaseRawDecode("0",FALSE)) // if (!BiphaseRawDecode("0",FALSE) && test())
// printT55xx("BIPHASE"); // printT55xx("BIPHASE");
// if (!BiphaseRawDecode("1",FALSE)) // if (!BiphaseRawDecode("1",FALSE) && test())
// printT55xx("BIPHASE inv"); // printT55xx("BIPHASE inv");
} }
return 0; return 0;
} }
bool test(){
if ( !DemodBufferLen)
return false;
uint8_t si = 1;
uint8_t safer = PackBits(si, 4, DemodBuffer); si += 4;
uint8_t resv = PackBits(si, 7, DemodBuffer); si += 7+3;
uint8_t extend = PackBits(si, 1, DemodBuffer); si += 1;
//PrintAndLog("test: %X %X %X ", safer, resv, extend);
// 2nibble must be zeroed.
if ( resv > 0x00) return FALSE;
if ( safer == 0x6 || safer == 0x9){
if ( extend == 0x00)
return TRUE;
}
if ( resv== 0x00) return TRUE;
return FALSE;
}
void printT55xx(const char *demodStr){ void printT55xx(const char *demodStr){
@ -434,7 +456,7 @@ int CmdInfo(const char *Cmd){
uint32_t resv = PackBits(si, 7, bits); si += 7; uint32_t resv = PackBits(si, 7, bits); si += 7;
uint32_t dbr = PackBits(si, 3, bits); si += 3; uint32_t dbr = PackBits(si, 3, bits); si += 3;
uint32_t extend = PackBits(si, 1, bits); si += 1; uint32_t extend = PackBits(si, 1, bits); si += 1;
uint32_t datamodulation = PackBits(si, 5, bits); si += 5; uint32_t datamod = PackBits(si, 5, bits); si += 5;
uint32_t pskcf = PackBits(si, 2, bits); si += 2; uint32_t pskcf = PackBits(si, 2, bits); si += 2;
uint32_t aor = PackBits(si, 1, bits); si += 1; uint32_t aor = PackBits(si, 1, bits); si += 1;
uint32_t otp = PackBits(si, 1, bits); si += 1; uint32_t otp = PackBits(si, 1, bits); si += 1;
@ -452,14 +474,14 @@ int CmdInfo(const char *Cmd){
PrintAndLog(" reserved : %d", resv); PrintAndLog(" reserved : %d", resv);
PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr)); PrintAndLog(" Data bit rate : %s", GetBitRateStr(dbr));
PrintAndLog(" eXtended mode : %s", (extend) ? "Yes - Warning":"No"); PrintAndLog(" eXtended mode : %s", (extend) ? "Yes - Warning":"No");
PrintAndLog(" Modulation : %s", GetModulationStr(datamodulation) ); PrintAndLog(" Modulation : %s", GetModulationStr(datamod));
PrintAndLog(" PSK clock freq : %d", pskcf); PrintAndLog(" PSK clock freq : %d", pskcf);
PrintAndLog(" AOR - Answer on Request : %s", (aor) ? "Yes":"No"); PrintAndLog(" AOR - Answer on Request : %s", (aor) ? "Yes":"No");
PrintAndLog(" OTP - One Time Pad : %s", (otp) ? "Yes - Warning":"No" ); PrintAndLog(" OTP - One Time Pad : %s", (otp) ? "Yes - Warning":"No" );
PrintAndLog(" Max block : %d", maxblk); PrintAndLog(" Max block : %d", maxblk);
PrintAndLog(" Password mode : %s", (pwd) ? "Yes":"No"); PrintAndLog(" Password mode : %s", (pwd) ? "Yes":"No");
PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No"); PrintAndLog(" Sequence Start Terminator : %s", (sst) ? "Yes":"No");
PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No"); PrintAndLog(" Fast Write : %s", (fw) ? "Yes":"No");
PrintAndLog(" Inverse data : %s", (inv) ? "Yes":"No"); PrintAndLog(" Inverse data : %s", (inv) ? "Yes":"No");
PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No"); PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No");
PrintAndLog("-------------------------------------------------------------"); PrintAndLog("-------------------------------------------------------------");
@ -543,10 +565,10 @@ char * GetSaferStr(uint32_t id){
sprintf(retStr,"%d",id); sprintf(retStr,"%d",id);
if (id == 6) { if (id == 6) {
sprintf(retStr,"%d - pasdwd",id); sprintf(retStr,"%d - passwd",id);
} }
if (id == 9 ){ if (id == 9 ){
sprintf(retStr,"%d - testmode ",id); sprintf(retStr,"%d - testmode",id);
} }
return buf; return buf;

View file

@ -22,4 +22,5 @@ char * GetSaferStr(uint32_t id);
char * GetModulationStr( uint32_t id); char * GetModulationStr( uint32_t id);
uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bitstream); uint32_t PackBits(uint8_t start, uint8_t len, uint8_t* bitstream);
void printT55xx(const char *demodStr); void printT55xx(const char *demodStr);
bool test();
#endif #endif