mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-08-20 21:33:47 -07:00
FIX: data plot AutoCorrelate slider, window too big, now limited to number of samples.
enhanced debugstatements, 'lf em 410x_demod' vs 'lf em 410x_read' now read does the same as all other LF, and demod too...
This commit is contained in:
parent
0e31ed346a
commit
91898babc0
9 changed files with 250 additions and 298 deletions
|
@ -18,12 +18,10 @@
|
|||
|
||||
int GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||
int GraphTraceLen;
|
||||
|
||||
int s_Buff[MAX_GRAPH_TRACE_LEN];
|
||||
|
||||
/* write a manchester bit to the graph */
|
||||
void AppendGraph(int redraw, int clock, int bit)
|
||||
{
|
||||
void AppendGraph(int redraw, int clock, int bit) {
|
||||
int i;
|
||||
//set first half the clock bit (all 1's or 0's for a 0 or 1 bit)
|
||||
for (i = 0; i < (int)(clock / 2); ++i)
|
||||
|
@ -37,8 +35,7 @@ void AppendGraph(int redraw, int clock, int bit)
|
|||
}
|
||||
|
||||
// clear out our graph window
|
||||
int ClearGraph(int redraw)
|
||||
{
|
||||
int ClearGraph(int redraw) {
|
||||
int gtl = GraphTraceLen;
|
||||
memset(GraphBuffer, 0x00, GraphTraceLen);
|
||||
GraphTraceLen = 0;
|
||||
|
@ -47,17 +44,16 @@ int ClearGraph(int redraw)
|
|||
return gtl;
|
||||
}
|
||||
// option '1' to save GraphBuffer any other to restore
|
||||
void save_restoreGB(uint8_t saveOpt)
|
||||
{
|
||||
void save_restoreGB(uint8_t saveOpt) {
|
||||
static int SavedGB[MAX_GRAPH_TRACE_LEN];
|
||||
static int SavedGBlen=0;
|
||||
static int SavedGBlen = 0;
|
||||
static bool GB_Saved = false;
|
||||
static int SavedGridOffsetAdj=0;
|
||||
static int SavedGridOffsetAdj = 0;
|
||||
|
||||
if (saveOpt == GRAPH_SAVE) { //save
|
||||
memcpy(SavedGB, GraphBuffer, sizeof(GraphBuffer));
|
||||
SavedGBlen = GraphTraceLen;
|
||||
GB_Saved=true;
|
||||
GB_Saved = true;
|
||||
SavedGridOffsetAdj = GridOffset;
|
||||
} else if (GB_Saved){ //restore
|
||||
memcpy(GraphBuffer, SavedGB, sizeof(GraphBuffer));
|
||||
|
@ -69,9 +65,8 @@ void save_restoreGB(uint8_t saveOpt)
|
|||
}
|
||||
|
||||
// DETECT CLOCK NOW IN LFDEMOD.C
|
||||
void setGraphBuf(uint8_t *buff, size_t size)
|
||||
{
|
||||
if ( buff == NULL ) return;
|
||||
void setGraphBuf(uint8_t *buf, size_t size) {
|
||||
if ( buf == NULL ) return;
|
||||
|
||||
ClearGraph(0);
|
||||
|
||||
|
@ -79,27 +74,26 @@ void setGraphBuf(uint8_t *buff, size_t size)
|
|||
size = MAX_GRAPH_TRACE_LEN;
|
||||
|
||||
for (uint16_t i = 0; i < size; ++i)
|
||||
GraphBuffer[i] = buff[i] - 128;
|
||||
GraphBuffer[i] = buf[i] - 128;
|
||||
|
||||
GraphTraceLen = size;
|
||||
RepaintGraphWindow();
|
||||
return;
|
||||
}
|
||||
size_t getFromGraphBuf(uint8_t *buff)
|
||||
{
|
||||
if (buff == NULL ) return 0;
|
||||
size_t getFromGraphBuf(uint8_t *buf) {
|
||||
|
||||
if (buf == NULL ) return 0;
|
||||
uint32_t i;
|
||||
for (i=0; i < GraphTraceLen; ++i){
|
||||
if (GraphBuffer[i] > 127) GraphBuffer[i] = 127; //trim
|
||||
if (GraphBuffer[i] < -127) GraphBuffer[i] = -127; //trim
|
||||
buff[i] = (uint8_t)(GraphBuffer[i]+128);
|
||||
buf[i] = (uint8_t)(GraphBuffer[i]+128);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
// A simple test to see if there is any data inside Graphbuffer.
|
||||
bool HasGraphData(){
|
||||
|
||||
if ( GraphTraceLen <= 0) {
|
||||
PrintAndLog("No data available, try reading something first");
|
||||
return false;
|
||||
|
@ -109,6 +103,7 @@ bool HasGraphData(){
|
|||
|
||||
// Detect high and lows in Grapbuffer.
|
||||
// Only loops the first 256 values.
|
||||
// Optional: 12% fuzz in case highs and lows aren't clipped
|
||||
void DetectHighLowInGraph(int *high, int *low, bool addFuzz) {
|
||||
|
||||
uint8_t loopMax = 255;
|
||||
|
@ -130,8 +125,7 @@ void DetectHighLowInGraph(int *high, int *low, bool addFuzz) {
|
|||
}
|
||||
|
||||
// Get or auto-detect ask clock rate
|
||||
int GetAskClock(const char str[], bool printAns, bool verbose)
|
||||
{
|
||||
int GetAskClock(const char str[], bool printAns, bool verbose) {
|
||||
int clock;
|
||||
sscanf(str, "%i", &clock);
|
||||
if (!strcmp(str, ""))
|
||||
|
@ -140,7 +134,7 @@ int GetAskClock(const char str[], bool printAns, bool verbose)
|
|||
if (clock != 0) return clock;
|
||||
|
||||
// Auto-detect clock
|
||||
uint8_t grph[MAX_GRAPH_TRACE_LEN]={0};
|
||||
uint8_t grph[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(grph);
|
||||
if (size == 0) {
|
||||
if (verbose)
|
||||
|
@ -162,8 +156,7 @@ int GetAskClock(const char str[], bool printAns, bool verbose)
|
|||
return clock;
|
||||
}
|
||||
|
||||
uint8_t GetPskCarrier(const char str[], bool printAns, bool verbose)
|
||||
{
|
||||
uint8_t GetPskCarrier(const char str[], bool printAns, bool verbose) {
|
||||
uint8_t carrier = 0;
|
||||
uint8_t grph[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
size_t size = getFromGraphBuf(grph);
|
||||
|
@ -182,8 +175,7 @@ uint8_t GetPskCarrier(const char str[], bool printAns, bool verbose)
|
|||
return carrier;
|
||||
}
|
||||
|
||||
int GetPskClock(const char str[], bool printAns, bool verbose)
|
||||
{
|
||||
int GetPskClock(const char str[], bool printAns, bool verbose) {
|
||||
int clock;
|
||||
sscanf(str, "%i", &clock);
|
||||
if (!strcmp(str, ""))
|
||||
|
@ -208,8 +200,7 @@ int GetPskClock(const char str[], bool printAns, bool verbose)
|
|||
return clock;
|
||||
}
|
||||
|
||||
uint8_t GetNrzClock(const char str[], bool printAns, bool verbose)
|
||||
{
|
||||
uint8_t GetNrzClock(const char str[], bool printAns, bool verbose) {
|
||||
int clock;
|
||||
sscanf(str, "%i", &clock);
|
||||
if (!strcmp(str, ""))
|
||||
|
@ -236,8 +227,7 @@ uint8_t GetNrzClock(const char str[], bool printAns, bool verbose)
|
|||
}
|
||||
//by marshmellow
|
||||
//attempt to detect the field clock and bit clock for FSK
|
||||
uint8_t GetFskClock(const char str[], bool printAns, bool verbose)
|
||||
{
|
||||
uint8_t GetFskClock(const char str[], bool printAns, bool verbose) {
|
||||
int clock;
|
||||
sscanf(str, "%i", &clock);
|
||||
if (!strcmp(str, ""))
|
||||
|
@ -282,8 +272,7 @@ uint8_t fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, bool verbose, int *f
|
|||
}
|
||||
|
||||
// test samples are not just noise
|
||||
bool graphJustNoise(int *bits, int size)
|
||||
{
|
||||
bool is_justnoise(int *bits, int size) {
|
||||
//might not be high enough for noisy environments
|
||||
#define THRESHOLD 15;
|
||||
bool isNoise = true;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue