- wiegand_add_parity(pre+8, wiegand, 24);
- size_t bitLen = addParity(pre, prescoBits+8, 66, 4, 1);
+//see ASKDemod for what args are accepted
+int CmdPrescoDemod(const char *Cmd) {
+ bool st = true;
+ if (!ASKDemod_ext("32 0 0 0 0 a", FALSE, FALSE, 1, &st)) {
+ if (g_debugMode) PrintAndLog("DEBUG: Error Presco ASKDemod failed");
+ return 0;
+ }
+ size_t size = DemodBufferLen;
+ //call lfdemod.c demod for Presco
+ int ans = PrescoDemod(DemodBuffer, &size);
+ if (ans < 0) {
+ if (g_debugMode){
+ if (ans == -1)
+ PrintAndLog("DEBUG: Error - Presco: too few bits found");
+ else if (ans == -2)
+ PrintAndLog("DEBUG: Error - Presco: preamble not found");
+ else if (ans == -3)
+ PrintAndLog("DEBUG: Error - Presco: Size not correct: %d", size);
+ else
+ PrintAndLog("DEBUG: Error - Presco: ans: %d", ans);
+ }
+ return 0;
+ }
+ setDemodBuf(DemodBuffer, 128, ans);
+
+ //got a good demod
+ uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
+ uint32_t raw2 = bytebits_to_byte(DemodBuffer+32, 32);
+ uint32_t raw3 = bytebits_to_byte(DemodBuffer+64, 32);
+ uint32_t raw4 = bytebits_to_byte(DemodBuffer+96, 32);
+ uint32_t cardid = raw4;
+ PrintAndLog("Presco Tag Found: Card ID %08X, Raw: %08X%08X%08X%08X", cardid, raw1, raw2, raw3, raw4);