add clock to ask rawdemod outputs

fix biphase invert bug (correctly)
This commit is contained in:
marshmellow42 2015-06-07 00:42:57 -04:00
parent 07b5a3c3ba
commit 8e2e6c8eb0

View file

@ -41,7 +41,7 @@ void setDemodBuf(uint8_t *buff, size_t size, size_t startIdx)
size = MAX_DEMOD_BUF_LEN; size = MAX_DEMOD_BUF_LEN;
size_t i = 0; size_t i = 0;
for (; i < size; i++){ for (; i < size; i++){
DemodBuffer[i]=buff[startIdx++]; DemodBuffer[i]=buff[startIdx++];
} }
DemodBufferLen=size; DemodBufferLen=size;
@ -344,8 +344,8 @@ int ASKDemod(const char *Cmd, bool verbose, bool emSearch, uint8_t askType)
setDemodBuf(BitStream,BitLen,0); setDemodBuf(BitStream,BitLen,0);
if (verbose || g_debugMode){ if (verbose || g_debugMode){
if (errCnt>0) PrintAndLog("# Errors during Demoding (shown as 7 in bit stream): %d",errCnt); if (errCnt>0) PrintAndLog("# Errors during Demoding (shown as 7 in bit stream): %d",errCnt);
if (askType) PrintAndLog("ASK/Manchester decoded bitstream:"); if (askType) PrintAndLog("ASK/Manchester - Clock: %d - Decoded bitstream:",clk);
else PrintAndLog("ASK/Raw decoded bitstream:"); else PrintAndLog("ASK/Raw - Clock: %d - Decoded bitstream:",clk);
// Now output the bitstream to the scrollback by line of 16 bits // Now output the bitstream to the scrollback by line of 16 bits
printDemodBuff(); printDemodBuff();
@ -499,21 +499,19 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose)
{ {
//ask raw demod GraphBuffer first //ask raw demod GraphBuffer first
int offset=0, clk=0, invert=0, maxErr=0, ans=0; int offset=0, clk=0, invert=0, maxErr=0, ans=0;
ans = sscanf(Cmd, "%i %i 0 %i", &offset, &clk, &maxErr); ans = sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &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;
}
//attempt to Biphase decode DemodBuffer uint8_t BitStream[MAX_DEMOD_BUF_LEN];
size_t size = DemodBufferLen; size_t size = getFromGraphBuf(BitStream);
uint8_t BitStream[MAX_DEMOD_BUF_LEN];
memcpy(BitStream, DemodBuffer, DemodBufferLen); int errCnt = askdemod(BitStream, &size, &clk, 0, maxErr, 0, 0);
int errCnt = BiphaseRawDecode(BitStream, &size, offset, invert); if ( errCnt < 0 || errCnt > maxErr ) {
if (g_debugMode) PrintAndLog("DEBUG: no data or error found %d, clock: %d", errCnt, clk);
return 0;
}
//attempt to Biphase decode BitStream
errCnt = BiphaseRawDecode(BitStream, &size, offset, invert);
if (errCnt < 0){ if (errCnt < 0){
if (g_debugMode || verbose) PrintAndLog("Error BiphaseRawDecode: %d", errCnt); if (g_debugMode || verbose) PrintAndLog("Error BiphaseRawDecode: %d", errCnt);
return 0; return 0;
@ -525,7 +523,7 @@ int ASKbiphaseDemod(const char *Cmd, bool verbose)
//success set DemodBuffer and return //success set DemodBuffer and return
setDemodBuf(BitStream, size, 0); setDemodBuf(BitStream, size, 0);
if (g_debugMode || verbose){ if (g_debugMode || verbose){
PrintAndLog("Biphase Decoded using offset: %d - # errors:%d - data:",offset,errCnt); PrintAndLog("Biphase Decoded using offset: %d - clock: %d - # errors:%d - data:",offset,clk,errCnt);
printDemodBuff(); printDemodBuff();
} }
return 1; return 1;