... to prevent double call to getFromGraphBuf()...
also adjust %hu to u and as there is a possible problem with %hu in
printf.
fchigh = param_get8(Cmd, 2);
fclow = param_get8(Cmd, 3);
if (strlen(Cmd)>0 && strlen(Cmd)<=2) {
fchigh = param_get8(Cmd, 2);
fclow = param_get8(Cmd, 3);
if (strlen(Cmd)>0 && strlen(Cmd)<=2) {
invert = 1; //if invert option only is used
rfLen = 0;
invert = 1; //if invert option only is used
rfLen = 0;
}
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
size_t BitLen = getFromGraphBuf(BitStream);
if (BitLen==0) return 0;
}
uint8_t BitStream[MAX_GRAPH_TRACE_LEN]={0};
size_t BitLen = getFromGraphBuf(BitStream);
if (BitLen==0) return 0;
+ if (g_debugMode==2) PrintAndLog("DEBUG: Got samples");
//get field clock lengths
//get field clock lengths
- uint8_t fc1=0, fc2=0, rf1=0;
- uint8_t ans = fskClocks(&fc1, &fc2, &rf1, false);
- if (ans == 0) {
- if (g_debugMode) PrintAndLog("\nError: cannot detect valid fsk field clocks");
- return 0; // can't detect field clock
+ fcs = countFC(BitStream, BitLen, 1);
+ if (!fcs) {
+ fchigh = 10;
+ fclow = 8;
+ } else {
+ fchigh = (fcs >> 8) & 0x00FF;
+ fclow = fcs & 0x00FF;
- fchigh = fc1;
- fclow = fc2;
- if (rfLen == 0) rfLen = rf1;
rfLen = detectFSKClk(BitStream, BitLen, fchigh, fclow);
if (!rfLen) rfLen = 50;
}
int size = fskdemod(BitStream, BitLen, rfLen, invert, fchigh, fclow);
rfLen = detectFSKClk(BitStream, BitLen, fchigh, fclow);
if (!rfLen) rfLen = 50;
}
int size = fskdemod(BitStream, BitLen, rfLen, invert, fchigh, fclow);
setDemodBuf(BitStream,size,0);
// Now output the bitstream to the scrollback by line of 16 bits
if (verbose || g_debugMode) {
setDemodBuf(BitStream,size,0);
// Now output the bitstream to the scrollback by line of 16 bits
if (verbose || g_debugMode) {
- PrintAndLog("\nUsing Clock:%hu, invert:%hu, fchigh:%hu, fclow:%hu", rfLen, invert, fchigh, fclow);
+ PrintAndLog("\nUsing Clock:%u, invert:%u, fchigh:%u, fclow:%u", (unsigned int)rfLen, (unsigned int)invert, (unsigned int)fchigh, (unsigned int)fclow);
PrintAndLog("%s decoded bitstream:",GetFSKType(fchigh,fclow,invert));
printDemodBuff();
}
PrintAndLog("%s decoded bitstream:",GetFSKType(fchigh,fclow,invert));
printDemodBuff();
}
return 1;
} else {
if (g_debugMode) PrintAndLog("no FSK data found");
return 1;
} else {
if (g_debugMode) PrintAndLog("no FSK data found");