- int clock;
-
- sscanf(str, "%i", &clock);
- if (!strcmp(str, ""))
- clock = 0;
-
- /* Auto-detect clock */
- if (!clock)
- {
- clock = DetectClock(peak);
- /* Only print this message if we're not looping something */
- if (!verbose)
- PrintAndLog("Auto-detected clock rate: %d", clock);
- }
-
- return clock;
+ int clock;
+
+ sscanf(str, "%i", &clock);
+ if (!strcmp(str, ""))
+ clock = 0;
+
+ /* Auto-detect clock */
+ if (!clock) {
+
+ uint8_t grph[MAX_GRAPH_TRACE_LEN] = {0x00};
+ int size = GetFromGraphBuf(grph);
+ if ( size < 0 ) {
+ PrintAndLog("Failed to copy from graphbuffer");
+ return -1;
+ }
+ clock = DetectASKClock(grph, size, 0);
+
+ /* Only print this message if we're not looping something */
+ if (verbose)
+ PrintAndLog("Auto-detected clock rate: %d", clock);
+ }
+ return clock;
+}
+
+// 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;
+ }
+ return true;