ADD: @marshmellow42 's 14b reader changes.

FIX: @marshmellow42 's ASKbiphaseDemod fixes.
CHG: added a check in ASKbiphaseDemod to make a compiler warning message go away.
This commit is contained in:
iceman1001
2015-06-14 14:39:50 +02:00
parent 1417a7f9d0
commit 1299c798fc
3 changed files with 205 additions and 88 deletions

View File

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