\r
#define CONFIGURATION_BLOCK 0x00\r
#define TRACE_BLOCK 0x01\r
+#define T55x7_PWD 0x00000010\r
\r
// Default configuration\r
t55xx_conf_block_t config = { .modulation = DEMOD_ASK, .inverted = FALSE, .offset = 0x00, .block0 = 0x00};\r
\r
//Password mode\r
if ( res == 2 ) {\r
- c.arg[2] = password;\r
- c.d.asBytes[0] = 0x1; \r
+ \r
+ // try reading the config block and verify that PWD bit is set before doing this!\r
+ AquireData( CONFIGURATION_BLOCK );\r
+ if ( !tryDetectModulation() ) {\r
+ PrintAndLog("Could not detect is PWD bit is set in config block. Exits.");\r
+ return 1;\r
+ }\r
+ //if PWD bit is set, allow to execute read command with password.\r
+ if (( config.block0 & T55x7_PWD ) == 1) {\r
+ c.arg[2] = password;\r
+ c.d.asBytes[0] = 0x1; \r
+ } else { \r
+ PrintAndLog("PWD bit is NOT set in config block. Reading without password...");\r
+ }\r
}\r
\r
clearCommandBuffer();\r
uint8_t got[12000];\r
GetFromBigBuf(got,sizeof(got),0);\r
WaitForResponse(CMD_ACK,NULL);\r
- setGraphBuf(got, 12000);\r
- DemodBufferLen=0;\r
+ setGraphBuf(got, sizeof(got));\r
+ //DemodBufferLen=0;\r
if (!DecodeT55xxBlock()) return 3;\r
char blk[10]={0};\r
sprintf(blk,"%d", block);\r
return 1;\r
}\r
\r
- UsbCommand resp;\r
UsbCommand c = {CMD_T55XX_WRITE_BLOCK, {data, block, 0}};\r
+ UsbCommand resp;\r
c.d.asBytes[0] = 0x0; \r
\r
PrintAndLog("Writing to block: %d data : 0x%08X", block, data);\r