mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2024-09-21 07:46:12 +08:00
Bigger graph buffer
1280000 samples -> 10.24s for 125kHz 8bit sampling Allocate graph related memory on heap
This commit is contained in:
parent
42ab3ee1e6
commit
8b6a274e28
|
@ -1011,7 +1011,7 @@ static int CmdUndecimate(const char *Cmd) {
|
|||
CLIParserFree(ctx);
|
||||
|
||||
//We have memory, don't we?
|
||||
int swap[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
int *swap = calloc(MAX_GRAPH_TRACE_LEN, sizeof(int));
|
||||
uint32_t g_index = 0, s_index = 0;
|
||||
while (g_index < g_GraphTraceLen && s_index + factor < MAX_GRAPH_TRACE_LEN) {
|
||||
int count = 0;
|
||||
|
@ -1028,6 +1028,7 @@ static int CmdUndecimate(const char *Cmd) {
|
|||
memcpy(g_GraphBuffer, swap, s_index * sizeof(int));
|
||||
g_GraphTraceLen = s_index;
|
||||
RepaintGraphWindow();
|
||||
free(swap);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -1707,7 +1708,7 @@ int CmdHpf(const char *Cmd) {
|
|||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||
CLIParserFree(ctx);
|
||||
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
removeSignalOffset(bits, size);
|
||||
// push it back to graph
|
||||
|
@ -1716,6 +1717,7 @@ int CmdHpf(const char *Cmd) {
|
|||
computeSignalProperties(bits, size);
|
||||
|
||||
RepaintGraphWindow();
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2103,12 +2105,13 @@ static int CmdLoad(const char *Cmd) {
|
|||
PrintAndLogEx(SUCCESS, "loaded " _YELLOW_("%zu") " samples", g_GraphTraceLen);
|
||||
|
||||
if (nofix == false) {
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
|
||||
removeSignalOffset(bits, size);
|
||||
setGraphBuf(bits, size);
|
||||
computeSignalProperties(bits, size);
|
||||
free(bits);
|
||||
}
|
||||
|
||||
setClockGrid(0, 0);
|
||||
|
@ -2240,12 +2243,13 @@ int CmdNorm(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||
computeSignalProperties(bits, size);
|
||||
|
||||
RepaintGraphWindow();
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2386,12 +2390,13 @@ static int CmdDirectionalThreshold(const char *Cmd) {
|
|||
directionalThreshold(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, up, down);
|
||||
|
||||
// set signal properties low/high/mean/amplitude and isnoice detection
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
// set signal properties low/high/mean/amplitude and is_noice detection
|
||||
computeSignalProperties(bits, size);
|
||||
|
||||
RepaintGraphWindow();
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2429,11 +2434,12 @@ static int CmdZerocrossings(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||
computeSignalProperties(bits, size);
|
||||
RepaintGraphWindow();
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -2742,11 +2748,12 @@ static int CmdDataIIR(const char *Cmd) {
|
|||
|
||||
iceSimple_Filter(g_GraphBuffer, g_GraphTraceLen, k);
|
||||
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||
computeSignalProperties(bits, size);
|
||||
RepaintGraphWindow();
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -3369,11 +3376,12 @@ static int CmdCenterThreshold(const char *Cmd) {
|
|||
centerThreshold(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, up, down);
|
||||
|
||||
// set signal properties low/high/mean/amplitude and isnoice detection
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
// set signal properties low/high/mean/amplitude and is_noice detection
|
||||
computeSignalProperties(bits, size);
|
||||
RepaintGraphWindow();
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -3414,11 +3422,12 @@ static int CmdEnvelope(const char *Cmd) {
|
|||
|
||||
envelope_square(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen);
|
||||
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
// set signal properties low/high/mean/amplitude and is_noice detection
|
||||
computeSignalProperties(bits, size);
|
||||
RepaintGraphWindow();
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -433,7 +433,7 @@ int CmdFlexdemod(const char *Cmd) {
|
|||
#endif
|
||||
int i, j, start, bit, sum;
|
||||
|
||||
int data[g_GraphTraceLen];
|
||||
int *data = malloc(g_GraphTraceLen * sizeof(int));
|
||||
memcpy(data, g_GraphBuffer, g_GraphTraceLen);
|
||||
|
||||
size_t size = g_GraphTraceLen;
|
||||
|
@ -454,6 +454,7 @@ int CmdFlexdemod(const char *Cmd) {
|
|||
|
||||
if (start == size - LONG_WAIT) {
|
||||
PrintAndLogEx(WARNING, "nothing to wait for");
|
||||
free(data);
|
||||
return PM3_ENODATA;
|
||||
}
|
||||
|
||||
|
@ -497,6 +498,7 @@ int CmdFlexdemod(const char *Cmd) {
|
|||
}
|
||||
}
|
||||
RepaintGraphWindow();
|
||||
free(data);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -117,10 +117,11 @@ int demodHID(bool verbose) {
|
|||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint32_t hi2 = 0, hi = 0, lo = 0;
|
||||
|
||||
uint8_t bits[g_GraphTraceLen];
|
||||
uint8_t *bits = malloc(g_GraphTraceLen);
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID not enough samples"));
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
//get binary from fsk wave
|
||||
|
@ -146,6 +147,7 @@ int demodHID(bool verbose) {
|
|||
|
||||
setDemodBuff(bits, size, idx);
|
||||
setClockGrid(50, waveIdx + (idx * 50));
|
||||
free(bits);
|
||||
|
||||
if (hi2 == 0 && hi == 0 && lo == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID no values found"));
|
||||
|
|
|
@ -403,7 +403,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
|||
|
||||
// worst case with g_GraphTraceLen=40000 is < 4096
|
||||
// under normal conditions it's < 2048
|
||||
uint8_t data[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
uint8_t *data = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||
size_t datasize = getFromGraphBuf(data);
|
||||
|
||||
uint8_t rawbits[4096] = {0};
|
||||
|
@ -446,6 +446,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
|||
count = 0;
|
||||
}
|
||||
}
|
||||
free(data);
|
||||
|
||||
if (rawbit > 0) {
|
||||
PrintAndLogEx(INFO, "Recovered %d raw bits, expected: %zu", rawbit, g_GraphTraceLen / 32);
|
||||
|
|
|
@ -66,10 +66,11 @@ static int CmdIOProxWatch(const char *Cmd) {
|
|||
int demodIOProx(bool verbose) {
|
||||
(void) verbose; // unused so far
|
||||
int idx = 0, retval = PM3_SUCCESS;
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size < 65) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - IO prox not enough samples in GraphBuffer");
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
//get binary from fsk wave
|
||||
|
@ -93,6 +94,7 @@ int demodIOProx(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - IO prox error demoding fsk %d", idx);
|
||||
}
|
||||
}
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(bits, size, idx);
|
||||
|
@ -103,6 +105,7 @@ int demodIOProx(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - IO prox data not found - FSK Bits: %zu", size);
|
||||
if (size > 92) PrintAndLogEx(DEBUG, "%s", sprint_bytebits_bin_break(bits, 92, 16));
|
||||
}
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -156,6 +159,7 @@ int demodIOProx(bool verbose) {
|
|||
printDemodBuff(0, false, false, true);
|
||||
printDemodBuff(0, false, false, false);
|
||||
}
|
||||
free(bits);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -441,4 +445,3 @@ int getIOProxBits(uint8_t version, uint8_t fc, uint16_t cn, uint8_t *bits) {
|
|||
PrintAndLogEx(SUCCESS, "IO raw bits:\n %s \n", sprint_bytebits_bin(bits, 64));
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
|
|
@ -103,10 +103,11 @@ static uint8_t GetParadoxBits(const uint32_t fc, const uint32_t cn, unsigned int
|
|||
int demodParadox(bool verbose, bool oldChksum) {
|
||||
(void) verbose; // unused so far
|
||||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Paradox not enough samples");
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -125,6 +126,7 @@ int demodParadox(bool verbose, bool oldChksum) {
|
|||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Paradox error demoding fsk %d", idx);
|
||||
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -175,6 +177,7 @@ int demodParadox(bool verbose, bool oldChksum) {
|
|||
|
||||
if (hi2 == 0 && hi == 0 && lo == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Paradox no value found");
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -230,6 +233,7 @@ int demodParadox(bool verbose, bool oldChksum) {
|
|||
printDemodBuff(0, false, false, false);
|
||||
}
|
||||
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -500,5 +504,3 @@ int detectParadox(uint8_t *dest, size_t *size, int *wave_start_idx) {
|
|||
|
||||
return (int)idx;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -43,10 +43,11 @@ static int CmdHelp(const char *Cmd);
|
|||
int demodPyramid(bool verbose) {
|
||||
(void) verbose; // unused so far
|
||||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||
uint8_t bits[MAX_GRAPH_TRACE_LEN] = {0};
|
||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||
size_t size = getFromGraphBuf(bits);
|
||||
if (size == 0) {
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid not enough samples");
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
//get binary from fsk wave
|
||||
|
@ -65,6 +66,7 @@ int demodPyramid(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: size not correct: %zu", size);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: error demoding fsk idx: %d", idx);
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
setDemodBuff(bits, size, idx);
|
||||
|
@ -113,6 +115,7 @@ int demodPyramid(bool verbose) {
|
|||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: parity check failed - IDX: %d, hi3: %08X", idx, rawHi3);
|
||||
else
|
||||
PrintAndLogEx(DEBUG, "DEBUG: Error - Pyramid: at parity check - tag size does not match Pyramid format, SIZE: %zu, IDX: %d, hi3: %08X", size, idx, rawHi3);
|
||||
free(bits);
|
||||
return PM3_ESOFT;
|
||||
}
|
||||
|
||||
|
@ -181,6 +184,7 @@ int demodPyramid(bool verbose) {
|
|||
printDemodBuff(0, false, false, false);
|
||||
}
|
||||
|
||||
free(bits);
|
||||
return PM3_SUCCESS;
|
||||
}
|
||||
|
||||
|
@ -507,4 +511,3 @@ int detectPyramid(uint8_t *dest, size_t *size, int *waveStartIdx) {
|
|||
|
||||
return (int)startIdx;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ int GetNrzClock(const char *str, bool verbose);
|
|||
int GetFskClock(const char *str, bool verbose);
|
||||
bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge);
|
||||
|
||||
#define MAX_GRAPH_TRACE_LEN (40000 * 8)
|
||||
#define MAX_GRAPH_TRACE_LEN (40000 * 32)
|
||||
#define GRAPH_SAVE 1
|
||||
#define GRAPH_RESTORE 0
|
||||
|
||||
|
|
Loading…
Reference in a new issue