- if (g_debugMode) \r
- PrintAndLog("Using Clock: %d - invert: %d - Bits Found: %d", clk, invert, bitlen);\r
-\r
- //move bits back to DemodBuffer\r
- setDemodBuf(bits, bitlen, 0);\r
- printBitStream(bits,bitlen);\r
- \r
- // bits has the manchester encoded data.\r
- errCnt = manrawdecode(bits, &bitlen); \r
- if ( errCnt == -1 || bitlen < 16 ){ \r
- PrintAndLog("no data found");\r
- if (g_debugMode) \r
- PrintAndLog("errCnt: %d, bitlen: %d, clk: %d, invert: %d", errCnt, bitlen, clk, invert);\r
- return 4;\r
+ return 0;\r
+}\r
+\r
+// detect configuration?\r
+bool tryDetectModulation(){\r
+ \r
+ uint8_t hits = 0;\r
+ t55xx_conf_block_t tests[10];\r
+ \r
+ if (GetFskClock("", FALSE, FALSE)){ \r
+ if ( FSKrawDemod("0 0", FALSE) && test()){\r
+ tests[hits].modulation = DEMOD_FSK;\r
+ tests[hits].inversed = FALSE;\r
+ ++hits;\r
+ }\r
+ if ( FSKrawDemod("0 1", FALSE) && test()) {\r
+ tests[hits].modulation = DEMOD_FSK;\r
+ tests[hits].inversed = TRUE;\r
+ ++hits;\r
+ }\r
+ } else {\r
+ if ( ASKmanDemod("0 0 1", FALSE, FALSE) && test()) {\r
+ tests[hits].modulation = DEMOD_ASK;\r
+ tests[hits].inversed = FALSE;\r
+ ++hits;\r
+ }\r
+\r
+ if ( ASKmanDemod("0 1 1", FALSE, FALSE) && test()) {\r
+ tests[hits].modulation = DEMOD_ASK;\r
+ tests[hits].inversed = TRUE;\r
+ ++hits;\r
+ }\r
+ \r
+ if ( NRZrawDemod("0 0 1", FALSE) && test()) {\r
+ tests[hits].modulation = DEMOD_NZR;\r
+ tests[hits].inversed = FALSE;\r
+ ++hits;\r
+ }\r
+\r
+ if ( NRZrawDemod("0 1 1", FALSE) && test()) {\r
+ tests[hits].modulation = DEMOD_NZR;\r
+ tests[hits].inversed = TRUE;\r
+ ++hits;\r
+ }\r
+ \r
+ if ( PSKDemod("0 0 1", FALSE) && test()) {\r
+ tests[hits].modulation = DEMOD_PSK;\r
+ tests[hits].inversed = FALSE;\r
+ ++hits;\r
+ }\r
+ \r
+ if ( PSKDemod("0 1 1", FALSE) && test()) {\r
+ tests[hits].modulation = DEMOD_PSK;\r
+ tests[hits].inversed = TRUE;\r
+ ++hits;\r
+ }\r
+ //PSK2?\r
+ // if (!BiphaseRawDecode("0",FALSE) && test()) {\r
+ // tests[++hits].modulation = DEMOD_BI;\r
+ // tests[hits].inversed = FALSE;\r
+ //}\r
+ // if (!BiphaseRawDecode("1",FALSE) && test()) {\r
+ // tests[++hits].modulation = DEMOD_BI;\r
+ // tests[hits].inversed = TRUE;\r
+ // }\r
+ } \r
+ if ( hits == 1) {\r
+ config.modulation = tests[0].modulation;\r
+ config.inversed = tests[0].inversed;\r
+ printConfiguration( config );\r
+ return TRUE;\r
+ }\r
+ \r
+ if ( hits > 1) {\r
+ PrintAndLog("Found [%d] possible matches for modulation.",hits);\r
+ for(int i=0; i<hits; ++i){\r
+ PrintAndLog("--[%d]---------------", i+1);\r
+ printConfiguration( tests[i] );\r
+ }\r