X-Git-Url: http://git.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/c54d1394c69fbe8199cf96f9e0ddb5172e71682c..e770c6482407fb67c37973cc3e95409cd5c6d952:/client/graph.c diff --git a/client/graph.c b/client/graph.c index 269c2dd9..00997437 100644 --- a/client/graph.c +++ b/client/graph.c @@ -66,8 +66,7 @@ void setGraphBuf(uint8_t *buff, size_t size) } size_t getFromGraphBuf(uint8_t *buff) { - if ( buff == NULL ) return -1; - + if (buff == NULL ) return 0; uint32_t i; for (i=0;i127) GraphBuffer[i]=127; //trim @@ -76,6 +75,8 @@ size_t getFromGraphBuf(uint8_t *buff) } return i; } + + // Get or auto-detect clock rate int GetClock(const char *str, int peak, int verbose) { @@ -89,11 +90,11 @@ int GetClock(const char *str, int peak, int verbose) { uint8_t grph[MAX_GRAPH_TRACE_LEN]={0}; size_t size = getFromGraphBuf(grph); - if ( size < 0 ) { + if ( size == 0 ) { PrintAndLog("Failed to copy from graphbuffer"); return -1; } - clock = DetectASKClock(grph,size,0); + clock = DetectASKClock(grph,size,0,20); // Only print this message if we're not looping something if (!verbose){ PrintAndLog("Auto-detected clock rate: %d", clock); @@ -134,7 +135,7 @@ void DetectHighLowInGraph(int *high, int *low, bool addFuzz) { } } -int GetNRZpskClock(const char *str, int peak, int verbose) +int GetPskClock(const char *str, int peak, int verbose) { int clock; sscanf(str, "%i", &clock); @@ -146,11 +147,40 @@ int GetNRZpskClock(const char *str, int peak, int verbose) { uint8_t grph[MAX_GRAPH_TRACE_LEN]={0}; size_t size = getFromGraphBuf(grph); - clock = DetectpskNRZClock(grph,size,0); + if ( size == 0 ) { + PrintAndLog("Failed to copy from graphbuffer"); + return -1; + } + clock = DetectPSKClock(grph,size,0); // Only print this message if we're not looping something if (!verbose){ PrintAndLog("Auto-detected clock rate: %d", clock); } } return clock; -} \ No newline at end of file +} + +int GetNrzClock(const char *str, int peak, int verbose) +{ + int clock; + sscanf(str, "%i", &clock); + if (!strcmp(str, "")) + clock = 0; + + // Auto-detect clock + if (!clock) + { + uint8_t grph[MAX_GRAPH_TRACE_LEN]={0}; + size_t size = getFromGraphBuf(grph); + if ( size == 0 ) { + PrintAndLog("Failed to copy from graphbuffer"); + return -1; + } + clock = DetectNRZClock(grph,size,0); + // Only print this message if we're not looping something + if (!verbose){ + PrintAndLog("Auto-detected clock rate: %d", clock); + } + } + return clock; +}