PrintAndLog(" h This help");\r
PrintAndLog(" d <FSK|ASK|PSK|NZ|BI> Set demodulation FSK / ASK / PSK / NZ / Biphase");\r
PrintAndLog(" i [1] Inverse data signal, defaults to normal");\r
- PrintAndLog(" o [offsett] Set offset, where data should start decode from in bitstream");\r
+ PrintAndLog(" o [offset] Set offset, where data should start decode in bitstream");\r
PrintAndLog("");\r
PrintAndLog("Examples:");\r
PrintAndLog(" lf t55xx config d FSK - FSK demodulation");\r
\r
int CmdT55xxSetConfig(const char *Cmd){\r
\r
- uint8_t data[] = {0x78,0x00,0x00,0x00,0x00,0x00,0x00};\r
- uint8_t cmd[] = {0x00,0x00};\r
- ComputeCrc14443(CRC_14443_B, data, 7 , &cmd[0], &cmd[1]);\r
- PrintAndLog("%02X %02X",cmd[0], cmd[1]);\r
- int len = 0;\r
- int foundModulation = 2;\r
uint8_t offset = 0;\r
- bool inverse = FALSE;\r
bool errors = FALSE;\r
uint8_t cmdp = 0;\r
char modulation[4] = {0x00};\r
+ char tmp = 0x00;\r
\r
while(param_getchar(Cmd, cmdp) != 0x00 && !errors)\r
{\r
- switch(param_getchar(Cmd, cmdp))\r
+ tmp = param_getchar(Cmd, cmdp);\r
+ switch(tmp)\r
{\r
case 'h':\r
case 'H':\r
return usage_t55xx_config();\r
case 'd':\r
- len = param_getstr(Cmd, cmdp+1, modulation);\r
- cmdp+= len+1;\r
- //FSK|ASK|PSK|NZ|BI\r
- if ( strcmp(modulation, "FSK" ) == 0)\r
- foundModulation = 1;\r
- else if ( strcmp(modulation, "ASK" ) == 0)\r
- foundModulation = 2;\r
- else if ( strcmp(modulation, "PSK" ) == 0)\r
- foundModulation = 3;\r
- else if ( strcmp(modulation, "NZ" ) == 0)\r
- foundModulation = 4;\r
- else if ( strcmp(modulation, "BI" ) == 0)\r
- foundModulation = 5;\r
+ param_getstr(Cmd, cmdp+1, modulation);\r
+ cmdp += 2;\r
+ \r
+ if ( strcmp(modulation, "FSK" ) == 0) config.modulation = DEMOD_FSK;\r
+ else if ( strcmp(modulation, "ASK" ) == 0) config.modulation = DEMOD_ASK;\r
+ else if ( strcmp(modulation, "PSK" ) == 0) config.modulation = DEMOD_PSK;\r
+ else if ( strcmp(modulation, "NZ" ) == 0) config.modulation = DEMOD_NZR;\r
+ else if ( strcmp(modulation, "BI" ) == 0) config.modulation = DEMOD_BI;\r
else {\r
PrintAndLog("Unknown modulation '%s'", modulation);\r
errors = TRUE;\r
}\r
break;\r
case 'i':\r
- inverse = param_getchar(Cmd,cmdp+1) == '1';\r
+ config.inversed = param_getchar(Cmd,cmdp+1) == '1';\r
cmdp+=2;\r
break;\r
case 'o':\r
errors |= param_getdec(Cmd, cmdp+1,&offset);\r
- if ( offset >= 32 ){\r
- PrintAndLog("Offset must be smaller than 32");\r
- errors = TRUE;\r
- }\r
- cmdp+=2;\r
+ if ( !errors )\r
+ config.offset = offset;\r
+ cmdp += 2;\r
break;\r
default:\r
PrintAndLog("Unknown parameter '%c'", param_getchar(Cmd, cmdp));\r
errors = TRUE;\r
break;\r
}\r
+ \r
+ PrintAndLog(" %c %d [%d]", param_getchar(Cmd, cmdp) , errors, cmdp);\r
}\r
// No args\r
if (cmdp == 0) {\r
if (errors)\r
return usage_t55xx_config();\r
\r
- config.modulation = foundModulation;\r
- config.inversed = inverse;\r
- config.offset = offset;\r
config.block0 = 0;\r
+ printConfiguration( config );\r
return 0;\r
}\r
\r
if ( !DemodBufferLen) \r
return false;\r
\r
- uint8_t si = 1;\r
+ if ( PackBits(0, 32, DemodBuffer) == 0x00 )\r
+ return FALSE;\r
+ \r
+ uint8_t si = 0;\r
+ \r
uint8_t safer = PackBits(si, 4, DemodBuffer); si += 4; \r
uint8_t resv = PackBits(si, 7, DemodBuffer); si += 7+3;\r
uint8_t extend = PackBits(si, 1, DemodBuffer); si += 1;\r
int i = config.offset;\r
int pos = 32 + config.offset;\r
for (; i < pos; ++i)\r
- bits[i]=DemodBuffer[i];\r
+ bits[i - config.offset]=DemodBuffer[i];\r
\r
blockData = PackBits(0, 32, bits);\r
PrintAndLog("0x%08X %s [%s]", blockData, sprint_bin(bits,32), demodStr);\r
\r
int special(const char *Cmd) {\r
uint32_t blockData = 0;\r
- uint8_t bits[64] = {0x00};\r
+ uint8_t bits[32] = {0x00};\r
\r
PrintAndLog("[OFFSET] [DATA] [BINARY]");\r
PrintAndLog("----------------------------------------------------");\r
int i,j = 0;\r
- for (; j < 32; ++j){\r
+ for (; j < 128; ++j){\r
\r
for (i = 0; i < 32; ++i)\r
bits[i]=DemodBuffer[j+i];\r
\r
RepaintGraphWindow();\r
\r
- uint8_t si = 5;\r
+ uint8_t si = config.offset;\r
uint32_t bl0 = PackBits(si, 32, DemodBuffer);\r
uint32_t bl1 = PackBits(si+32, 32, DemodBuffer);\r
\r
return 2;\r
\r
\r
- uint8_t si = 1;\r
+ uint8_t si = config.offset;\r
uint32_t bl0 = PackBits(si, 32, DemodBuffer);\r
\r
uint32_t safer = PackBits(si, 4, DemodBuffer); si += 4; \r