uint8_t BitStream[MAX_DEMOD_BUF_LEN]={0};
size = sizeof(BitStream);
if ( !getDemodBuf(BitStream, &size) ) return 0;
- errCnt=BiphaseRawDecode(BitStream, &size, offset, invert);
+ errCnt=BiphaseRawDecode(BitStream, &size, &offset, invert);
if (errCnt<0){
PrintAndLog("Error during decode:%d", errCnt);
return 0;
if (errCnt>0){
PrintAndLog("# Errors found during Demod (shown as 7 in bit stream): %d",errCnt);
}
+
PrintAndLog("Biphase Decoded using offset: %d - # invert:%d - data:",offset,invert);
PrintAndLog("%s", sprint_bin_break(BitStream, size, 16));
if (offset) setDemodBuf(DemodBuffer,DemodBufferLen-offset, offset); //remove first bit from raw demod
+ setClockGrid(g_DemodClock, g_DemodStartIdx + g_DemodClock*offset/2);
return 1;
}
sscanf(Cmd, "%i %i %i %i", &offset, &clk, &invert, &maxErr);
uint8_t BitStream[MAX_GRAPH_TRACE_LEN];
- size_t size = getFromGraphBuf(BitStream);
+ size_t size = getFromGraphBuf(BitStream);
+ int startIdx = 0;
//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);
+ int errCnt = askdemod_ext(BitStream, &size, &clk, &invert, maxErr, 0, 0, &startIdx);
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);
+ errCnt = BiphaseRawDecode(BitStream, &size, &offset, invert);
if (errCnt < 0){
if (g_debugMode || verbose) PrintAndLog("Error BiphaseRawDecode: %d", errCnt);
return 0;
- }
+ }
if (errCnt > maxErr) {
if (g_debugMode || verbose) PrintAndLog("Error BiphaseRawDecode too many errors: %d", errCnt);
return 0;
}
//success set DemodBuffer and return
setDemodBuf(BitStream, size, 0);
+ setClockGrid(clk, startIdx + clk*offset/2);
if (g_debugMode || verbose){
PrintAndLog("Biphase Decoded using offset: %d - clock: %d - # errors:%d - data:",offset,clk,errCnt);
printDemodBuff();
uint32_t rawHi = bytebits_to_byte(BitStream+idx+32,32);
uint32_t rawHi2 = bytebits_to_byte(BitStream+idx,32);
setDemodBuf(BitStream,96,idx);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (idx*g_DemodClock));
size = removeParity(BitStream, idx+8, 4, 1, 88);
if (size != 66){
if (Em410xDecode(BitStream, &BitLen, &idx, hi, lo)) {
//set GraphBuffer for clone or sim command
setDemodBuf(DemodBuffer, (BitLen==40) ? 64 : 128, idx+1);
- g_DemodStartIdx += (idx+1)*g_DemodClock;
+ setClockGrid(g_DemodClock, g_DemodStartIdx + ((idx+1)*g_DemodClock));
+
if (g_debugMode) {
PrintAndLog("DEBUG: idx: %d, Len: %d, Printing Demod Buffer:", idx, BitLen);
printDemodBuff();
}
setDemodBuf(DemodBuffer, 32, 0);
+ setClockGrid(0,0);
+
*word = bytebits_to_byteLSBF(DemodBuffer, 32);
}
return true;
// set and leave DemodBuffer intact
setDemodBuf(DemodBuffer, 128, preambleIndex);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (preambleIndex*g_DemodClock));
+
uint8_t bits_no_spacer[117];
memcpy(bits_no_spacer, DemodBuffer + 11, 117);
PrintAndLog("Decoded Raw: %s", sprint_hex(ByteStream, 8));
}
PrintAndLog("Raw: %08x%08x%08x", raw1,raw2,raw3);
- setDemodBuf(DemodBuffer+ans, 96, 0);
+ setDemodBuf(DemodBuffer, 96, ans);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
+
return 1;
}
//by marshmellow
(unsigned int) fmtLen, (unsigned int) fc, (unsigned int) cardnum);
}
setDemodBuf(BitStream,BitLen,idx);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (idx*g_DemodClock));
if (g_debugMode){
PrintAndLog("DEBUG: idx: %d, Len: %d, Printing Demod Buffer:", idx, BitLen);
printDemodBuff();
return -1;
}
setDemodBuf(DemodBuffer, size, (size_t)startIdx);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (startIdx*g_DemodClock));
if (invert)
if (g_debugMode)
PrintAndLog("Had to invert bits");
PrintAndLog("IO Prox XSF(%02d)%02x:%05d (%08x%08x) [%02x %s]",version,facilitycode,number,code,code2, crc, crcStr);
setDemodBuf(BitStream,64,idx);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (idx*g_DemodClock));
+
if (g_debugMode){
PrintAndLog("DEBUG: idx: %d, Len: %d, Printing demod buffer:",idx,64);
printDemodBuff();
return 0;
}
- setDemodBuf(DemodBuffer+ans, 64, 0);
- //setGrid_Clock(64);
+ setDemodBuf(DemodBuffer, 64, ans);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
//got a good demod
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
}
if (size != 128) return 0;
setDemodBuf(DemodBuffer, size, startIdx+4);
- startIdx = 8+32; //4 = extra i added, 8 = preamble, 32 = reserved bits (always 0)
+ setClockGrid(g_DemodClock, g_DemodStartIdx + ((startIdx+4)*g_DemodClock));
+ startIdx = 8+32; // 8 = preamble, 32 = reserved bits (always 0)
//get ID
uint32_t ID = 0;
for (uint8_t wordIdx=0; wordIdx<4; wordIdx++){
return 0;
}
setDemodBuf(DemodBuffer, 96, ans);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
//setGrid_Clock(32);
//got a good demod
PrintAndLog("Paradox TAG ID: %x%08x - FC: %d - Card: %d - Checksum: %02x - RAW: %08x%08x%08x",
hi>>10, (hi & 0x3)<<26 | (lo>>10), fc, cardnum, (lo>>2) & 0xFF, rawHi2, rawHi, rawLo);
setDemodBuf(BitStream,BitLen,idx);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (idx*g_DemodClock));
if (g_debugMode){
PrintAndLog("DEBUG: idx: %d, len: %d, Printing Demod Buffer:", idx, BitLen);
printDemodBuff();
uint32_t cardid = raw4;
PrintAndLog("Presco Tag Found: Card ID %08X", cardid);
PrintAndLog("Raw: %08X%08X%08X%08X", raw1,raw2,raw3,raw4);
- setDemodBuf(DemodBuffer+ans, 128, 0);
-
+ setDemodBuf(DemodBuffer, 128, ans);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
+
uint32_t sitecode = 0, usercode = 0, fullcode = 0;
bool Q5=false;
char cmd[12] = {0};
uint32_t rawHi2 = bytebits_to_byte(BitStream+idx+32,32);
uint32_t rawHi3 = bytebits_to_byte(BitStream+idx,32);
setDemodBuf(BitStream,128,idx);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (idx*g_DemodClock));
size = removeParity(BitStream, idx+8, 8, 1, 120);
if (size != 105){
return 0;
}
setDemodBuf(DemodBuffer, 96, ans);
- //setGrid_Clock(40);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
//got a good demod
uint32_t raw1 = bytebits_to_byte(DemodBuffer , 32);
uint8_t checksum = bytebits_to_byte(DemodBuffer+ans+32+24, 8);
PrintAndLog("Viking Tag Found: Card ID %08X, Checksum: %02X", cardid, (unsigned int) checksum);
PrintAndLog("Raw: %08X%08X", raw1,raw2);
- setDemodBuf(DemodBuffer+ans, 64, 0);
+ setDemodBuf(DemodBuffer, 64, ans);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
return 1;
}
return 0;
}
setDemodBuf(DemodBuffer, 96, ans);
- //setGrid_Clock(64);
+ setClockGrid(g_DemodClock, g_DemodStartIdx + (ans*g_DemodClock));
//got a good demod
uint32_t raw1 = bytebits_to_byte(DemodBuffer, 32);
#include <math.h>
#include <limits.h>
#include <stdio.h>
+#include <QSlider>
#include <QHBoxLayout>
#include <string.h>
#include "proxguiqt.h"
plotGridLines(&painter, plotRect);
//Start painting graph
- PlotGraph(GraphBuffer, GraphTraceLen,plotRect,infoRect,&painter,0);
- PlotGraph(s_Buff, GraphTraceLen,plotRect,infoRect,&painter,1);
if (showDemod && DemodBufferLen > 8) {
PlotDemod(DemodBuffer, DemodBufferLen,plotRect,infoRect,&painter,2,g_DemodStartIdx);
}
+ PlotGraph(s_Buff, GraphTraceLen,plotRect,infoRect,&painter,1);
+ PlotGraph(GraphBuffer, GraphTraceLen,plotRect,infoRect,&painter,0);
// End graph drawing
//Draw the cursors
Plot::Plot(QWidget *parent) : QWidget(parent), GraphStart(0), GraphPixelsPerPoint(1)
{
+ //Need to set this, otherwise we don't receive keypress events
setFocusPolicy( Qt::StrongFocus);
resize(600, 300);
//take 01 or 10 = 1 and 11 or 00 = 0
//check for phase errors - should never have 111 or 000 should be 01001011 or 10110100 for 1010
//decodes biphase or if inverted it is AKA conditional dephase encoding AKA differential manchester encoding
-int BiphaseRawDecode(uint8_t *BitStream, size_t *size, int offset, int invert) {
+int BiphaseRawDecode(uint8_t *BitStream, size_t *size, int *offset, int invert) {
uint16_t bitnum = 0;
uint16_t errCnt = 0;
- size_t i = offset;
+ size_t i = *offset;
uint16_t MaxBits=512;
//if not enough samples - error
if (*size < 51) return -1;
if (BitStream[i+1]==BitStream[i+2]) offsetA=0;
if (BitStream[i+2]==BitStream[i+3]) offsetB=0;
}
- if (!offsetA && offsetB) offset++;
- for (i=offset; i<*size-3; i+=2){
+ if (!offsetA && offsetB) *offset+=1;
+ for (i=*offset; i<*size-3; i+=2){
//check for phase error
if (BitStream[i+1]==BitStream[i+2]) {
BitStream[bitnum++]=7;
//by marshmellow (from holiman's base)
// full fsk demod from GraphBuffer wave to decoded 1s and 0s (no mandemod)
int fskdemod_ext(uint8_t *dest, size_t size, uint8_t rfLen, uint8_t invert, uint8_t fchigh, uint8_t fclow, int *startIdx) {
+ if (justNoise(dest, *size)) return 0;
// FSK demodulator
size = fsk_wave_demod(dest, size, fchigh, fclow, startIdx);
size = aggregate_bits(dest, size, rfLen, invert, fchigh, fclow, startIdx);
//make sure buffer has enough data
if (*size < 96*50) return -1;
- if (justNoise(dest, *size)) return -2;
-
// FSK demodulator
*size = fskdemod(dest, *size, 50, 1, 10, 8); // fsk2a RF/50
if (*size < 96) return -3; //did we get a good demod?
// loop to get raw HID waveform then FSK demodulate the TAG ID from it
int HIDdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo) {
- if (justNoise(dest, *size)) return -1;
-
size_t numStart=0, size2=*size, startIdx=0;
// FSK demodulator
*size = fskdemod(dest, size2,50,1,10,8); //fsk2a
}
int IOdemodFSK(uint8_t *dest, size_t size) {
- if (justNoise(dest, size)) return -1;
//make sure buffer has data
if (size < 66*64) return -2;
// FSK demodulator
// loop to get raw paradox waveform then FSK demodulate the TAG ID from it
int ParadoxdemodFSK(uint8_t *dest, size_t *size, uint32_t *hi2, uint32_t *hi, uint32_t *lo) {
- if (justNoise(dest, *size)) return -1;
-
size_t numStart=0, size2=*size, startIdx=0;
// FSK demodulator
*size = fskdemod(dest, size2,50,1,10,8); //fsk2a
//make sure buffer has data
if (*size < 128*50) return -5;
- //test samples are not just noise
- if (justNoise(dest, *size)) return -1;
-
// FSK demodulator
*size = fskdemod(dest, *size, 50, 1, 10, 8); // fsk2a RF/50
if (*size < 128) return -2; //did we get a good demod?
extern int askdemod(uint8_t *BinStream, size_t *size, int *clk, int *invert, int maxErr, uint8_t amp, uint8_t askType);
extern int askdemod_ext(uint8_t *BinStream, size_t *size, int *clk, int *invert, int maxErr, uint8_t amp, uint8_t askType, int *startIdx);
extern void askAmp(uint8_t *BitStream, size_t size);
-extern int BiphaseRawDecode(uint8_t * BitStream, size_t *size, int offset, int invert);
+extern int BiphaseRawDecode(uint8_t * BitStream, size_t *size, int *offset, int invert);
extern uint32_t bytebits_to_byte(uint8_t* src, size_t numbits);
extern uint32_t bytebits_to_byteLSBF(uint8_t* src, size_t numbits);
extern uint16_t countFC(uint8_t *BitStream, size_t size, uint8_t fskAdj);