\r
int res = sscanf(Cmd, "%d %x", &block, &password);\r
\r
- if ( res < 1 || res > 2 ){\r
- usage_t55xx_read();\r
- return 1;\r
- }\r
+ if ( res < 1 || res > 2 )\r
+ return usage_t55xx_read();\r
+\r
\r
if ((block < 0) | (block > 7)) {\r
PrintAndLog("Block must be between 0 and 7");\r
setGraphBuf(got, 12000);\r
\r
DecodeT55xxBlock();\r
- PrintAndLog("FIRE");\r
printT55xxBlock("");\r
-\r
return 0;\r
}\r
\r
WaitForResponse(CMD_ACK,NULL);\r
setGraphBuf(got, 12000);\r
\r
- tryDetectModulation();\r
+ if ( !tryDetectModulation() ){\r
+ PrintAndLog("Could not detect modulation automatically. Try setting it manually with \'lf t55xx config\'");\r
+ }\r
return 0;\r
}\r
\r
bool tryDetectModulation(){\r
\r
uint8_t hits = 0;\r
+ t55xx_conf_block_t tests[10];\r
\r
- //IF true, the wave is almost certainly FSK\r
if (GetFskClock("", FALSE, FALSE)){ \r
-\r
if ( FSKrawDemod("0 0", FALSE) && test()){\r
- printT55xxBlock("FSK");\r
+ tests[hits].modulation = 1;\r
+ tests[hits].inversed = 0;\r
++hits;\r
}\r
if ( FSKrawDemod("0 1", FALSE) && test()) {\r
- printT55xxBlock("FSK inv");\r
+ tests[hits].modulation = 1;\r
+ tests[hits].inversed = 1;\r
++hits;\r
- }\r
+ }\r
} else {\r
if ( ASKmanDemod("0 0 1", FALSE, FALSE) && test()) {\r
- printT55xxBlock("ASK/MAN");\r
+ tests[hits].modulation = 2;\r
+ tests[hits].inversed = 0;\r
++hits;\r
- }\r
+ }\r
\r
if ( ASKmanDemod("0 1 1", FALSE, FALSE) && test()) {\r
- printT55xxBlock("ASK/MAN Inv");\r
+ tests[hits].modulation = 2;\r
+ tests[hits].inversed = 1;\r
++hits;\r
- }\r
+ }\r
\r
if ( NRZrawDemod("0 0 1", FALSE) && test()) {\r
- printT55xxBlock("NZR");\r
+ tests[hits].modulation = 3;\r
+ tests[hits].inversed = 0;\r
++hits;\r
}\r
\r
if ( NRZrawDemod("0 1 1", FALSE) && test()) {\r
- printT55xxBlock("NZR inv");\r
+ tests[hits].modulation = 3;\r
+ tests[hits].inversed = 1;\r
++hits;\r
- }\r
+ }\r
\r
if ( PSKDemod("0 0 1", FALSE) && test()) {\r
- printT55xxBlock("PSK");\r
+ tests[hits].modulation = 4;\r
+ tests[hits].inversed = 0;\r
++hits;\r
}\r
\r
if ( PSKDemod("0 1 1", FALSE) && test()) {\r
- printT55xxBlock("PSK inv");\r
+ tests[++hits].modulation = 4;\r
+ tests[hits].inversed = 1;\r
++hits;\r
}\r
//PSK2?\r
// if (!BiphaseRawDecode("0",FALSE) && test()) {\r
- // printT55xx("BIPHASE");\r
+ // tests[++hits].modulation = 5;\r
+ // tests[hits].inversed = 0;\r
//}\r
// if (!BiphaseRawDecode("1",FALSE) && test()) {\r
- // printT55xx("BIPHASE inv");\r
+ // tests[++hits].modulation = 5;\r
+ // tests[hits].inversed = 1;\r
// }\r
} \r
- if ( hits == 1) \r
+ if ( hits == 1) {\r
+ PrintAndLog("Modulation: %d Inverse: %d", tests[0].modulation, tests[0].inversed);\r
+ config.modulation = tests[0].modulation;\r
+ config.inversed = tests[0].inversed;\r
return TRUE;\r
+ }\r
\r
- if ( hits > 1)\r
+ if ( hits > 1) {\r
PrintAndLog("Found [%d] possible matches for modulation.",hits);\r
-\r
+ for(int i=0; i<hits; ++i){\r
+ PrintAndLog("Modulation: %d Inverse: %d", tests[i].modulation, tests[i].inversed);\r
+ }\r
+ }\r
return FALSE;\r
}\r
\r
\r
int CmdT55xxReadTrace(const char *Cmd)\r
{\r
- uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0x00};\r
-\r
char cmdp = param_getchar(Cmd, 0);\r
\r
- if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') {\r
- usage_t55xx_trace();\r
- return 0;\r
- }\r
+ if (strlen(Cmd) > 1 || cmdp == 'h' || cmdp == 'H') \r
+ return usage_t55xx_trace();\r
\r
if ( strlen(Cmd)==0){\r
\r
PrintAndLog("command execution time out");\r
return 1;\r
}\r
- //darn\r
- //CmdSamples("12000");\r
+\r
+ uint8_t got[12000];\r
+ GetFromBigBuf(got,sizeof(got),0);\r
+ WaitForResponse(CMD_ACK,NULL);\r
+ setGraphBuf(got, 12000);\r
}\r
\r
- size_t bitlen = getFromGraphBuf(bits);\r
- if ( bitlen == 0 )\r
+ DecodeT55xxBlock();\r
+\r
+ if ( !DemodBufferLen) \r
return 2;\r
\r
RepaintGraphWindow();\r
\r
uint8_t si = 5;\r
- uint32_t bl0 = PackBits(si, 32, bits);\r
- uint32_t bl1 = PackBits(si+32, 32, bits);\r
- \r
- uint32_t acl = PackBits(si, 8, bits); si += 8;\r
- uint32_t mfc = PackBits(si, 8, bits); si += 8;\r
- uint32_t cid = PackBits(si, 5, bits); si += 5;\r
- uint32_t icr = PackBits(si, 3, bits); si += 3;\r
- uint32_t year = PackBits(si, 4, bits); si += 4;\r
- uint32_t quarter = PackBits(si, 2, bits); si += 2;\r
- uint32_t lotid = PackBits(si, 12, bits); si += 12;\r
- uint32_t wafer = PackBits(si, 5, bits); si += 5;\r
- uint32_t dw = PackBits(si, 15, bits); \r
+ uint32_t bl0 = PackBits(si, 32, DemodBuffer);\r
+ uint32_t bl1 = PackBits(si+32, 32, DemodBuffer);\r
+ \r
+ uint32_t acl = PackBits(si, 8, DemodBuffer); si += 8;\r
+ uint32_t mfc = PackBits(si, 8, DemodBuffer); si += 8;\r
+ uint32_t cid = PackBits(si, 5, DemodBuffer); si += 5;\r
+ uint32_t icr = PackBits(si, 3, DemodBuffer); si += 3;\r
+ uint32_t year = PackBits(si, 4, DemodBuffer); si += 4;\r
+ uint32_t quarter = PackBits(si, 2, DemodBuffer); si += 2;\r
+ uint32_t lotid = PackBits(si, 12, DemodBuffer); si += 12;\r
+ uint32_t wafer = PackBits(si, 5, DemodBuffer); si += 5;\r
+ uint32_t dw = PackBits(si, 15, DemodBuffer); \r
+ \r
+ year += 2000;\r
\r
PrintAndLog("");\r
PrintAndLog("-- T55xx Trace Information ----------------------------------");\r
PrintAndLog(" CID : 0x%02X (%d)", cid, cid);\r
PrintAndLog(" ICR IC Revision : %d",icr );\r
PrintAndLog(" Manufactured");\r
- PrintAndLog(" Year/Quarter : %d/%d",2000+year, quarter );\r
+ PrintAndLog(" Year/Quarter : %d/%d",year, quarter );\r
PrintAndLog(" Lot ID : %d", lotid );\r
PrintAndLog(" Wafer number : %d", wafer);\r
PrintAndLog(" Die Number : %d", dw);\r
PrintAndLog("-------------------------------------------------------------");\r
PrintAndLog(" Raw Data - Page 1");\r
- PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bits+5,32) );\r
- PrintAndLog(" Block 0 : 0x%08X %s", bl1, sprint_bin(bits+37,32) );\r
+ PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(DemodBuffer+5,32) );\r
+ PrintAndLog(" Block 0 : 0x%08X %s", bl1, sprint_bin(DemodBuffer+37,32) );\r
PrintAndLog("-------------------------------------------------------------");\r
/*\r
TRACE - BLOCK O\r
*/\r
char cmdp = param_getchar(Cmd, 0);\r
\r
- if (cmdp == 'h' || cmdp == 'H') {\r
+ if (cmdp == 'h' || cmdp == 'H')\r
return usage_t55xx_info();\r
- } else {\r
- CmdT55xxReadBlock("0");\r
- } \r
+ \r
+ if (strlen(Cmd)==0){\r
+ \r
+ // read block 0, Page 0. Configuration.\r
+ UsbCommand c = {CMD_T55XX_READ_BLOCK, {0, 0, 0}};\r
+ c.d.asBytes[0] = 0x0; \r
+\r
+ //Password mode\r
+ // if ( res == 2 ) {\r
+ // c.arg[2] = password;\r
+ // c.d.asBytes[0] = 0x1; \r
+ // }\r
\r
- // config\r
+ SendCommand(&c);\r
+ if ( !WaitForResponseTimeout(CMD_ACK,NULL,2500) ) {\r
+ PrintAndLog("command execution time out");\r
+ return 1;\r
+ }\r
+\r
+ uint8_t got[12000];\r
+ GetFromBigBuf(got,sizeof(got),0);\r
+ WaitForResponse(CMD_ACK,NULL);\r
+ setGraphBuf(got, 12000);\r
+ }\r
\r
- uint8_t bits[LF_BITSSTREAM_LEN] = {0x00};\r
+ DecodeT55xxBlock();\r
\r
+ if ( !DemodBufferLen) \r
+ return 2;\r
+ \r
+ \r
uint8_t si = 1;\r
- uint32_t bl0 = PackBits(si, 32, bits);\r
- \r
- uint32_t safer = PackBits(si, 4, bits); si += 4; \r
- uint32_t resv = PackBits(si, 7, bits); si += 7;\r
- uint32_t dbr = PackBits(si, 3, bits); si += 3;\r
- uint32_t extend = PackBits(si, 1, bits); si += 1;\r
- uint32_t datamod = PackBits(si, 5, bits); si += 5;\r
- uint32_t pskcf = PackBits(si, 2, bits); si += 2;\r
- uint32_t aor = PackBits(si, 1, bits); si += 1; \r
- uint32_t otp = PackBits(si, 1, bits); si += 1; \r
- uint32_t maxblk = PackBits(si, 3, bits); si += 3;\r
- uint32_t pwd = PackBits(si, 1, bits); si += 1; \r
- uint32_t sst = PackBits(si, 1, bits); si += 1; \r
- uint32_t fw = PackBits(si, 1, bits); si += 1;\r
- uint32_t inv = PackBits(si, 1, bits); si += 1; \r
- uint32_t por = PackBits(si, 1, bits); si += 1;\r
+ uint32_t bl0 = PackBits(si, 32, DemodBuffer);\r
+ \r
+ uint32_t safer = PackBits(si, 4, DemodBuffer); si += 4; \r
+ uint32_t resv = PackBits(si, 7, DemodBuffer); si += 7;\r
+ uint32_t dbr = PackBits(si, 3, DemodBuffer); si += 3;\r
+ uint32_t extend = PackBits(si, 1, DemodBuffer); si += 1;\r
+ uint32_t datamod = PackBits(si, 5, DemodBuffer); si += 5;\r
+ uint32_t pskcf = PackBits(si, 2, DemodBuffer); si += 2;\r
+ uint32_t aor = PackBits(si, 1, DemodBuffer); si += 1; \r
+ uint32_t otp = PackBits(si, 1, DemodBuffer); si += 1; \r
+ uint32_t maxblk = PackBits(si, 3, DemodBuffer); si += 3;\r
+ uint32_t pwd = PackBits(si, 1, DemodBuffer); si += 1; \r
+ uint32_t sst = PackBits(si, 1, DemodBuffer); si += 1; \r
+ uint32_t fw = PackBits(si, 1, DemodBuffer); si += 1;\r
+ uint32_t inv = PackBits(si, 1, DemodBuffer); si += 1; \r
+ uint32_t por = PackBits(si, 1, DemodBuffer); si += 1;\r
\r
PrintAndLog("");\r
PrintAndLog("-- T55xx Configuration & Tag Information --------------------");\r
PrintAndLog(" POR-Delay : %s", (por) ? "Yes":"No");\r
PrintAndLog("-------------------------------------------------------------");\r
PrintAndLog(" Raw Data - Page 0");\r
- PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(bits+5,32) );\r
+ PrintAndLog(" Block 0 : 0x%08X %s", bl0, sprint_bin(DemodBuffer+5,32) );\r
PrintAndLog("-------------------------------------------------------------");\r
\r
return 0;\r