mirror of
https://github.com/Proxmark/proxmark3.git
synced 2025-07-16 02:03:00 -07:00
Fixed undecimation command
This commit is contained in:
parent
698b649e0e
commit
c856ceae8a
1 changed files with 21 additions and 13 deletions
|
@ -549,24 +549,32 @@ int CmdDec(const char *Cmd)
|
||||||
*/
|
*/
|
||||||
int CmdUndec(const char *Cmd)
|
int CmdUndec(const char *Cmd)
|
||||||
{
|
{
|
||||||
|
if(param_getchar(Cmd, 0) == 'h')
|
||||||
|
{
|
||||||
|
PrintAndLog("Usage: data undec [factor]");
|
||||||
|
PrintAndLog("This function performs un-decimation, by repeating each sample N times");
|
||||||
|
PrintAndLog("Options: ");
|
||||||
|
PrintAndLog(" h This help");
|
||||||
|
PrintAndLog(" factor The number of times to repeat each sample.[default:2]");
|
||||||
|
PrintAndLog("Example: 'data undec 3'");
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t factor = param_get8ex(Cmd, 0,2, 10);
|
||||||
//We have memory, don't we?
|
//We have memory, don't we?
|
||||||
int swap[MAX_GRAPH_TRACE_LEN] = { 0 };
|
int swap[MAX_GRAPH_TRACE_LEN] = { 0 };
|
||||||
uint32_t i = 0 ,j = 0;
|
uint32_t g_index = 0 ,s_index = 0;
|
||||||
while(j+1 < MAX_GRAPH_TRACE_LEN && i < GraphTraceLen)
|
while(g_index < GraphTraceLen && s_index < MAX_GRAPH_TRACE_LEN)
|
||||||
{
|
{
|
||||||
swap[j] = GraphBuffer[i];
|
int count = 0;
|
||||||
swap[j+1] = GraphBuffer[i];
|
for(count = 0; count < factor && s_index+count < MAX_GRAPH_TRACE_LEN; count ++)
|
||||||
i++;
|
swap[s_index+count] = GraphBuffer[g_index];
|
||||||
j+=2;
|
s_index+=count;
|
||||||
}
|
}
|
||||||
memcpy(GraphBuffer,swap, j);
|
|
||||||
GraphTraceLen = j;
|
|
||||||
PrintAndLog("Undecimated by 2");
|
|
||||||
RepaintGraphWindow();
|
|
||||||
|
|
||||||
/*
|
memcpy(GraphBuffer,swap, s_index * sizeof(int));
|
||||||
* Something is not right here, need to look into it,
|
GraphTraceLen = s_index;
|
||||||
* the undec seems to only operate on half the values **/
|
RepaintGraphWindow();
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue