- int offset=0, clk=0, invert=0, maxErr=0, ans=0;
- ans = sscanf(Cmd, "%i %i 0 %i", &offset, &clk, &maxErr);
- if (ans>0)
- ans = ASKDemod(Cmd+2, FALSE, FALSE, 0);
- else
- ans = ASKDemod(Cmd, FALSE, FALSE, 0);
- if (!ans) {
- if (g_debugMode || verbose) PrintAndLog("Error AskDemod: %d", ans);
- return 0;
- }
+ int offset=0, clk=0, invert=0, maxErr=0;
+ sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr);
+
+ uint8_t BitStream[MAX_DEMOD_BUF_LEN];
+ size_t size = getFromGraphBuf(BitStream);
+ //invert here inverts the ask raw demoded bits which has no effect on the demod, but we need the pointer
+ int errCnt = askdemod(BitStream, &size, &clk, &invert, maxErr, 0, 0);
+ if ( errCnt < 0 || errCnt > maxErr ) {
+ if (g_debugMode) PrintAndLog("DEBUG: no data or error found %d, clock: %d", errCnt, clk);
+ return 0;
+ }