X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/d8c927bcecd62e67da420f73ee9d6620c30bde1f..2c5ed706511e60aacc291bc4c47d0efe1892596c:/client/cmdlft55xx.c diff --git a/client/cmdlft55xx.c b/client/cmdlft55xx.c index ced17ef5..aec47dc0 100644 --- a/client/cmdlft55xx.c +++ b/client/cmdlft55xx.c @@ -26,17 +26,7 @@ #define LF_TRACE_BUFF_SIZE 20000 // 32 x 32 x 10 (32 bit times numofblock (7), times clock skip..) #define LF_BITSSTREAM_LEN 1000 // more then 1000 bits shouldn't happend.. 8block * 4 bytes * 8bits = -// 0 = FSK -// 1 = ASK -// 2 = PSK -// 4 = NZR (direct) -typedef struct { - uint8_t modulation; - bool inversed; - uint32_t block0; -} t55xx_conf_block_t; - -// Default configuration: FSK, not inversed. +// Default configuration: ASK, not inversed. t55xx_conf_block_t config = { .modulation = 2, .inversed = FALSE, .block0 = 0x00}; int usage_t55xx_config(){ @@ -164,9 +154,7 @@ int CmdT55xxSetConfig(const char *Cmd){ } // No args if (cmdp == 0) { - PrintAndLog("Modulation: %d", config.modulation); - PrintAndLog("Invert : %d", config.inversed); - PrintAndLog("Block0 : %08X", config.block0); + printConfiguration( config ); return 0; } //Validations @@ -229,6 +217,9 @@ void DecodeT55xxBlock(){ char buf[6] = {0x00}; char *cmdStr = buf; + // clearing the DemodBuffer. + DemodBufferLen = 0x00; + // use the configuration switch( config.modulation ){ case 1: @@ -295,72 +286,73 @@ bool tryDetectModulation(){ if (GetFskClock("", FALSE, FALSE)){ if ( FSKrawDemod("0 0", FALSE) && test()){ - tests[hits].modulation = 1; - tests[hits].inversed = 0; + tests[hits].modulation = DEMOD_FSK; + tests[hits].inversed = FALSE; ++hits; } if ( FSKrawDemod("0 1", FALSE) && test()) { - tests[hits].modulation = 1; - tests[hits].inversed = 1; + tests[hits].modulation = DEMOD_FSK; + tests[hits].inversed = TRUE; ++hits; } } else { if ( ASKmanDemod("0 0 1", FALSE, FALSE) && test()) { - tests[hits].modulation = 2; - tests[hits].inversed = 0; + tests[hits].modulation = DEMOD_ASK; + tests[hits].inversed = FALSE; ++hits; } if ( ASKmanDemod("0 1 1", FALSE, FALSE) && test()) { - tests[hits].modulation = 2; - tests[hits].inversed = 1; + tests[hits].modulation = DEMOD_ASK; + tests[hits].inversed = TRUE; ++hits; } if ( NRZrawDemod("0 0 1", FALSE) && test()) { - tests[hits].modulation = 3; - tests[hits].inversed = 0; + tests[hits].modulation = DEMOD_NZR; + tests[hits].inversed = FALSE; ++hits; } if ( NRZrawDemod("0 1 1", FALSE) && test()) { - tests[hits].modulation = 3; - tests[hits].inversed = 1; + tests[hits].modulation = DEMOD_NZR; + tests[hits].inversed = TRUE; ++hits; } - if ( PSKDemod("0 0 1", FALSE) && test()) { - tests[hits].modulation = 4; - tests[hits].inversed = 0; + if ( PSKDemod("0 0 1", FALSE) >= 0 && test()) { + tests[hits].modulation = DEMOD_PSK; + tests[hits].inversed = FALSE; ++hits; } - if ( PSKDemod("0 1 1", FALSE) && test()) { - tests[++hits].modulation = 4; - tests[hits].inversed = 1; + if ( PSKDemod("0 1 1", FALSE) >= 0 && test()) { + tests[hits].modulation = DEMOD_PSK; + tests[hits].inversed = TRUE; ++hits; } //PSK2? // if (!BiphaseRawDecode("0",FALSE) && test()) { - // tests[++hits].modulation = 5; - // tests[hits].inversed = 0; + // tests[++hits].modulation = DEMOD_BI; + // tests[hits].inversed = FALSE; //} // if (!BiphaseRawDecode("1",FALSE) && test()) { - // tests[++hits].modulation = 5; - // tests[hits].inversed = 1; + // tests[++hits].modulation = DEMOD_BI; + // tests[hits].inversed = TRUE; // } } if ( hits == 1) { - PrintAndLog("Modulation: %d Inverse: %d", tests[0].modulation, tests[0].inversed); config.modulation = tests[0].modulation; config.inversed = tests[0].inversed; + printConfiguration( config ); return TRUE; } if ( hits > 1) { PrintAndLog("Found [%d] possible matches for modulation.",hits); for(int i=0; i