]>
cvs.zerfleddert.de Git - proxmark3-svn/blob - client/graph.c
1 //-----------------------------------------------------------------------------
2 // Copyright (C) 2010 iZsh <izsh at fail0verflow.com>
4 // This code is licensed to you under the terms of the GNU GPL, version 2 or,
5 // at your option, any later version. See the LICENSE.txt file for the text of
7 //-----------------------------------------------------------------------------
9 //-----------------------------------------------------------------------------
17 int GraphBuffer
[MAX_GRAPH_TRACE_LEN
];
20 /* write a bit to the graph */
21 void AppendGraph(int redraw
, int clock
, int bit
)
25 for (i
= 0; i
< (int)(clock
/ 2); ++i
)
26 GraphBuffer
[GraphTraceLen
++] = bit
^ 1;
28 for (i
= (int)(clock
/ 2); i
< clock
; ++i
)
29 GraphBuffer
[GraphTraceLen
++] = bit
;
35 // clear out our graph window
36 int ClearGraph(int redraw
)
38 int gtl
= GraphTraceLen
;
47 // DETECT CLOCK NOW IN LFDEMOD.C
49 void setGraphBuf(uint8_t *buff
, size_t size
)
53 for (; i
< size
; ++i
){
54 GraphBuffer
[i
]=buff
[i
]-128;
60 size_t getFromGraphBuf(uint8_t *buff
)
63 for (i
=0;i
<GraphTraceLen
;++i
){
64 if (GraphBuffer
[i
]>127) GraphBuffer
[i
]=127; //trim
65 if (GraphBuffer
[i
]<-127) GraphBuffer
[i
]=-127; //trim
66 buff
[i
]=(uint8_t)(GraphBuffer
[i
]+128);
70 // Get or auto-detect clock rate
71 int GetClock(const char *str
, int peak
, int verbose
)
74 sscanf(str
, "%i", &clock
);
81 uint8_t grph
[MAX_GRAPH_TRACE_LEN
]={0};
82 size_t size
= getFromGraphBuf(grph
);
83 clock
= DetectASKClock(grph
,size
,0);
84 // Only print this message if we're not looping something
86 PrintAndLog("Auto-detected clock rate: %d", clock
);
93 int GetNRZpskClock(const char *str
, int peak
, int verbose
)
96 sscanf(str
, "%i", &clock
);
103 uint8_t grph
[MAX_GRAPH_TRACE_LEN
]={0};
104 size_t size
= getFromGraphBuf(grph
);
105 clock
= DetectpskNRZClock(grph
,size
,0);
106 // Only print this message if we're not looping something
108 PrintAndLog("Auto-detected clock rate: %d", clock
);