mirror of
https://github.com/RfidResearchGroup/proxmark3.git
synced 2025-07-16 10:03:04 -07:00
rename globals GraphTraceLen OddByteParity pm3_capabilities
This commit is contained in:
parent
6e0ce662c7
commit
ce57637c80
20 changed files with 167 additions and 167 deletions
|
@ -21,9 +21,9 @@ size_t DemodPCF7931(uint8_t **outBlocks) {
|
||||||
|
|
||||||
uint8_t *dest = BigBuf_get_addr();
|
uint8_t *dest = BigBuf_get_addr();
|
||||||
|
|
||||||
int GraphTraceLen = BigBuf_max_traceLen();
|
int g_GraphTraceLen = BigBuf_max_traceLen();
|
||||||
if (GraphTraceLen > 18000) {
|
if (g_GraphTraceLen > 18000) {
|
||||||
GraphTraceLen = 18000;
|
g_GraphTraceLen = 18000;
|
||||||
}
|
}
|
||||||
|
|
||||||
int i = 2, j, lastval, bitidx, half_switch;
|
int i = 2, j, lastval, bitidx, half_switch;
|
||||||
|
@ -41,7 +41,7 @@ size_t DemodPCF7931(uint8_t **outBlocks) {
|
||||||
|
|
||||||
/* Find first local max/min */
|
/* Find first local max/min */
|
||||||
if (dest[1] > dest[0]) {
|
if (dest[1] > dest[0]) {
|
||||||
while (i < GraphTraceLen) {
|
while (i < g_GraphTraceLen) {
|
||||||
if (!(dest[i] > dest[i - 1]) && dest[i] > lmax) {
|
if (!(dest[i] > dest[i - 1]) && dest[i] > lmax) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ size_t DemodPCF7931(uint8_t **outBlocks) {
|
||||||
}
|
}
|
||||||
dir = 0;
|
dir = 0;
|
||||||
} else {
|
} else {
|
||||||
while (i < GraphTraceLen) {
|
while (i < g_GraphTraceLen) {
|
||||||
if (!(dest[i] < dest[i - 1]) && dest[i] < lmin) {
|
if (!(dest[i] < dest[i - 1]) && dest[i] < lmin) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -63,7 +63,7 @@ size_t DemodPCF7931(uint8_t **outBlocks) {
|
||||||
pmc = 0;
|
pmc = 0;
|
||||||
block_done = 0;
|
block_done = 0;
|
||||||
|
|
||||||
for (bitidx = 0; i < GraphTraceLen; i++) {
|
for (bitidx = 0; i < g_GraphTraceLen; i++) {
|
||||||
|
|
||||||
if ((dest[i - 1] > dest[i] && dir == 1 && dest[i] > lmax) || (dest[i - 1] < dest[i] && dir == 0 && dest[i] < lmin)) {
|
if ((dest[i - 1] > dest[i] && dir == 1 && dest[i] > lmax) || (dest[i - 1] < dest[i] && dir == 0 && dest[i] < lmin)) {
|
||||||
lc = i - lastval;
|
lc = i - lastval;
|
||||||
|
@ -131,7 +131,7 @@ size_t DemodPCF7931(uint8_t **outBlocks) {
|
||||||
half_switch = 0;
|
half_switch = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < GraphTraceLen) {
|
if (i < g_GraphTraceLen) {
|
||||||
dir = (dest[i - 1] > dest[i]) ? 0 : 1;
|
dir = (dest[i - 1] > dest[i]) ? 0 : 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1036,7 +1036,7 @@ static int CmdAnalyseFoo(const char *Cmd) {
|
||||||
PrintAndLogEx(INFO, "Got: %s", data3);
|
PrintAndLogEx(INFO, "Got: %s", data3);
|
||||||
|
|
||||||
ClearGraph(false);
|
ClearGraph(false);
|
||||||
GraphTraceLen = 15000;
|
g_GraphTraceLen = 15000;
|
||||||
|
|
||||||
for (int i = 0; i < 4095; i++) {
|
for (int i = 0; i < 4095; i++) {
|
||||||
int o = 0;
|
int o = 0;
|
||||||
|
|
|
@ -328,7 +328,7 @@ int CmdGetBitStream(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
CmdHpf("");
|
CmdHpf("");
|
||||||
for (uint32_t i = 0; i < GraphTraceLen; i++) {
|
for (uint32_t i = 0; i < g_GraphTraceLen; i++) {
|
||||||
g_GraphBuffer[i] = (g_GraphBuffer[i] >= 1) ? 1 : 0;
|
g_GraphBuffer[i] = (g_GraphBuffer[i] >= 1) ? 1 : 0;
|
||||||
}
|
}
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -377,7 +377,7 @@ int ASKDemod_ext(int clk, int invert, int maxErr, size_t maxlen, bool amplify, b
|
||||||
uint8_t askamp = 0;
|
uint8_t askamp = 0;
|
||||||
|
|
||||||
if (maxlen == 0)
|
if (maxlen == 0)
|
||||||
maxlen = pm3_capabilities.bigbuf_size;
|
maxlen = g_pm3_capabilities.bigbuf_size;
|
||||||
|
|
||||||
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
uint8_t *bits = calloc(MAX_GRAPH_TRACE_LEN, sizeof(uint8_t));
|
||||||
if (bits == NULL) {
|
if (bits == NULL) {
|
||||||
|
@ -778,7 +778,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG
|
||||||
// sanity check
|
// sanity check
|
||||||
if (window > len) window = len;
|
if (window > len) window = len;
|
||||||
|
|
||||||
if (verbose) PrintAndLogEx(INFO, "performing " _YELLOW_("%zu") " correlations", GraphTraceLen - window);
|
if (verbose) PrintAndLogEx(INFO, "performing " _YELLOW_("%zu") " correlations", g_GraphTraceLen - window);
|
||||||
|
|
||||||
//test
|
//test
|
||||||
double autocv = 0.0; // Autocovariance value
|
double autocv = 0.0; // Autocovariance value
|
||||||
|
@ -843,7 +843,7 @@ int AutoCorrelate(const int *in, int *out, size_t len, size_t window, bool SaveG
|
||||||
|
|
||||||
int retval = correlation;
|
int retval = correlation;
|
||||||
if (SaveGrph) {
|
if (SaveGrph) {
|
||||||
//GraphTraceLen = GraphTraceLen - window;
|
//g_GraphTraceLen = g_GraphTraceLen - window;
|
||||||
memcpy(out, correl_buf, len * sizeof(int));
|
memcpy(out, correl_buf, len * sizeof(int));
|
||||||
if (distance > 0) {
|
if (distance > 0) {
|
||||||
setClockGrid(distance, idx);
|
setClockGrid(distance, idx);
|
||||||
|
@ -881,18 +881,18 @@ static int CmdAutoCorr(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Using window size " _YELLOW_("%u"), window);
|
PrintAndLogEx(INFO, "Using window size " _YELLOW_("%u"), window);
|
||||||
|
|
||||||
if (GraphTraceLen == 0) {
|
if (g_GraphTraceLen == 0) {
|
||||||
PrintAndLogEx(WARNING, "GraphBuffer is empty");
|
PrintAndLogEx(WARNING, "GraphBuffer is empty");
|
||||||
PrintAndLogEx(HINT, "Try `" _YELLOW_("lf read") "` to collect samples");
|
PrintAndLogEx(HINT, "Try `" _YELLOW_("lf read") "` to collect samples");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (window >= GraphTraceLen) {
|
if (window >= g_GraphTraceLen) {
|
||||||
PrintAndLogEx(WARNING, "window must be smaller than trace (" _YELLOW_("%zu") " samples)", GraphTraceLen);
|
PrintAndLogEx(WARNING, "window must be smaller than trace (" _YELLOW_("%zu") " samples)", g_GraphTraceLen);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
AutoCorrelate(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, window, updateGrph, true);
|
AutoCorrelate(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, window, updateGrph, true);
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -926,7 +926,7 @@ static int CmdBitsamples(const char *Cmd) {
|
||||||
g_GraphBuffer[cnt++] = 0;
|
g_GraphBuffer[cnt++] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GraphTraceLen = cnt;
|
g_GraphTraceLen = cnt;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -968,10 +968,10 @@ static int CmdDecimate(const char *Cmd) {
|
||||||
int n = arg_get_int_def(ctx, 1, 2);
|
int n = arg_get_int_def(ctx, 1, 2);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
for (size_t i = 0; i < (GraphTraceLen / n); ++i)
|
for (size_t i = 0; i < (g_GraphTraceLen / n); ++i)
|
||||||
g_GraphBuffer[i] = g_GraphBuffer[i * n];
|
g_GraphBuffer[i] = g_GraphBuffer[i * n];
|
||||||
|
|
||||||
GraphTraceLen /= n;
|
g_GraphTraceLen /= n;
|
||||||
PrintAndLogEx(SUCCESS, "decimated by " _GREEN_("%u"), n);
|
PrintAndLogEx(SUCCESS, "decimated by " _GREEN_("%u"), n);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -1003,7 +1003,7 @@ static int CmdUndecimate(const char *Cmd) {
|
||||||
//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 g_index = 0, s_index = 0;
|
uint32_t g_index = 0, s_index = 0;
|
||||||
while (g_index < GraphTraceLen && s_index + factor < MAX_GRAPH_TRACE_LEN) {
|
while (g_index < g_GraphTraceLen && s_index + factor < MAX_GRAPH_TRACE_LEN) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (count = 0; count < factor && s_index + count < MAX_GRAPH_TRACE_LEN; count++) {
|
for (count = 0; count < factor && s_index + count < MAX_GRAPH_TRACE_LEN; count++) {
|
||||||
swap[s_index + count] = (
|
swap[s_index + count] = (
|
||||||
|
@ -1016,7 +1016,7 @@ static int CmdUndecimate(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(g_GraphBuffer, swap, s_index * sizeof(int));
|
memcpy(g_GraphBuffer, swap, s_index * sizeof(int));
|
||||||
GraphTraceLen = s_index;
|
g_GraphTraceLen = s_index;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -1039,7 +1039,7 @@ static int CmdGraphShiftZero(const char *Cmd) {
|
||||||
int shift = arg_get_int_def(ctx, 1, 0);
|
int shift = arg_get_int_def(ctx, 1, 0);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
for (size_t i = 0; i < GraphTraceLen; i++) {
|
for (size_t i = 0; i < g_GraphTraceLen; i++) {
|
||||||
int shiftedVal = g_GraphBuffer[i] + shift;
|
int shiftedVal = g_GraphBuffer[i] + shift;
|
||||||
|
|
||||||
if (shiftedVal > 127)
|
if (shiftedVal > 127)
|
||||||
|
@ -1085,7 +1085,7 @@ static int CmdAskEdgeDetect(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "using threshold " _YELLOW_("%i"), threshold);
|
PrintAndLogEx(INFO, "using threshold " _YELLOW_("%i"), threshold);
|
||||||
int res = AskEdgeDetect(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, threshold);
|
int res = AskEdgeDetect(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, threshold);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
@ -1560,8 +1560,8 @@ void setClockGrid(uint32_t clk, int offset) {
|
||||||
if (offset > clk) offset %= clk;
|
if (offset > clk) offset %= clk;
|
||||||
if (offset < 0) offset += clk;
|
if (offset < 0) offset += clk;
|
||||||
|
|
||||||
if (offset > GraphTraceLen || offset < 0) return;
|
if (offset > g_GraphTraceLen || offset < 0) return;
|
||||||
if (clk < 8 || clk > GraphTraceLen) {
|
if (clk < 8 || clk > g_GraphTraceLen) {
|
||||||
g_GridLocked = false;
|
g_GridLocked = false;
|
||||||
g_GridOffset = 0;
|
g_GridOffset = 0;
|
||||||
g_PlotGridX = 0;
|
g_PlotGridX = 0;
|
||||||
|
@ -1644,17 +1644,17 @@ static int CmdHexsamples(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
// sanity checks
|
// sanity checks
|
||||||
if (requested > pm3_capabilities.bigbuf_size) {
|
if (requested > g_pm3_capabilities.bigbuf_size) {
|
||||||
requested = pm3_capabilities.bigbuf_size;
|
requested = g_pm3_capabilities.bigbuf_size;
|
||||||
PrintAndLogEx(INFO, "n is larger than big buffer size, will use %u", requested);
|
PrintAndLogEx(INFO, "n is larger than big buffer size, will use %u", requested);
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t got[pm3_capabilities.bigbuf_size];
|
uint8_t got[g_pm3_capabilities.bigbuf_size];
|
||||||
if (offset + requested > sizeof(got)) {
|
if (offset + requested > sizeof(got)) {
|
||||||
PrintAndLogEx(NORMAL, "Tried to read past end of buffer, <bytes %u> + <offset %u> > %d"
|
PrintAndLogEx(NORMAL, "Tried to read past end of buffer, <bytes %u> + <offset %u> > %d"
|
||||||
, requested
|
, requested
|
||||||
, offset
|
, offset
|
||||||
, pm3_capabilities.bigbuf_size
|
, g_pm3_capabilities.bigbuf_size
|
||||||
);
|
);
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -1698,7 +1698,7 @@ int CmdHpf(const char *Cmd) {
|
||||||
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
CLIExecWithReturn(ctx, Cmd, argtable, true);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
removeSignalOffset(bits, size);
|
removeSignalOffset(bits, size);
|
||||||
// push it back to graph
|
// push it back to graph
|
||||||
|
@ -1739,13 +1739,13 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose) {
|
||||||
// we don't have to worry about remaining trash
|
// we don't have to worry about remaining trash
|
||||||
// in the last byte in case the bits-per-sample
|
// in the last byte in case the bits-per-sample
|
||||||
// does not line up on byte boundaries
|
// does not line up on byte boundaries
|
||||||
uint8_t got[pm3_capabilities.bigbuf_size - 1];
|
uint8_t got[g_pm3_capabilities.bigbuf_size - 1];
|
||||||
memset(got, 0x00, sizeof(got));
|
memset(got, 0x00, sizeof(got));
|
||||||
|
|
||||||
uint32_t n = end - start;
|
uint32_t n = end - start;
|
||||||
|
|
||||||
if (n == 0 || n > pm3_capabilities.bigbuf_size - 1)
|
if (n == 0 || n > g_pm3_capabilities.bigbuf_size - 1)
|
||||||
n = pm3_capabilities.bigbuf_size - 1;
|
n = g_pm3_capabilities.bigbuf_size - 1;
|
||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
PrintAndLogEx(INFO, "Reading " _YELLOW_("%u") " bytes from device memory", n);
|
PrintAndLogEx(INFO, "Reading " _YELLOW_("%u") " bytes from device memory", n);
|
||||||
|
@ -1777,7 +1777,7 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose) {
|
||||||
uint8_t sample = getByte(bits_per_sample, &bout);
|
uint8_t sample = getByte(bits_per_sample, &bout);
|
||||||
g_GraphBuffer[j] = ((int) sample) - 127;
|
g_GraphBuffer[j] = ((int) sample) - 127;
|
||||||
}
|
}
|
||||||
GraphTraceLen = j;
|
g_GraphTraceLen = j;
|
||||||
|
|
||||||
if (verbose) PrintAndLogEx(INFO, "Unpacked %d samples", j);
|
if (verbose) PrintAndLogEx(INFO, "Unpacked %d samples", j);
|
||||||
|
|
||||||
|
@ -1785,10 +1785,10 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose) {
|
||||||
for (uint32_t j = 0; j < n; j++) {
|
for (uint32_t j = 0; j < n; j++) {
|
||||||
g_GraphBuffer[j] = ((int)got[j]) - 127;
|
g_GraphBuffer[j] = ((int)got[j]) - 127;
|
||||||
}
|
}
|
||||||
GraphTraceLen = n;
|
g_GraphTraceLen = n;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||||
computeSignalProperties(bits, size);
|
computeSignalProperties(bits, size);
|
||||||
|
@ -2002,7 +2002,7 @@ int CmdTuneSamples(const char *Cmd) {
|
||||||
if (test1 > 0) {
|
if (test1 > 0) {
|
||||||
PrintAndLogEx(SUCCESS, "\nDisplaying LF tuning graph. Divisor %d (blue) is %.2f kHz, %d (red) is %.2f kHz.\n\n",
|
PrintAndLogEx(SUCCESS, "\nDisplaying LF tuning graph. Divisor %d (blue) is %.2f kHz, %d (red) is %.2f kHz.\n\n",
|
||||||
LF_DIVISOR_134, LF_DIV2FREQ(LF_DIVISOR_134), LF_DIVISOR_125, LF_DIV2FREQ(LF_DIVISOR_125));
|
LF_DIVISOR_134, LF_DIV2FREQ(LF_DIVISOR_134), LF_DIVISOR_125, LF_DIV2FREQ(LF_DIVISOR_125));
|
||||||
GraphTraceLen = 256;
|
g_GraphTraceLen = 256;
|
||||||
g_CursorCPos = LF_DIVISOR_125;
|
g_CursorCPos = LF_DIVISOR_125;
|
||||||
g_CursorDPos = LF_DIVISOR_134;
|
g_CursorDPos = LF_DIVISOR_134;
|
||||||
ShowGraphWindow();
|
ShowGraphWindow();
|
||||||
|
@ -2050,20 +2050,20 @@ static int CmdLoad(const char *Cmd) {
|
||||||
}
|
}
|
||||||
free(path);
|
free(path);
|
||||||
|
|
||||||
GraphTraceLen = 0;
|
g_GraphTraceLen = 0;
|
||||||
char line[80];
|
char line[80];
|
||||||
while (fgets(line, sizeof(line), f)) {
|
while (fgets(line, sizeof(line), f)) {
|
||||||
g_GraphBuffer[GraphTraceLen] = atoi(line);
|
g_GraphBuffer[g_GraphTraceLen] = atoi(line);
|
||||||
GraphTraceLen++;
|
g_GraphTraceLen++;
|
||||||
|
|
||||||
if (GraphTraceLen >= MAX_GRAPH_TRACE_LEN)
|
if (g_GraphTraceLen >= MAX_GRAPH_TRACE_LEN)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
fclose(f);
|
fclose(f);
|
||||||
|
|
||||||
PrintAndLogEx(SUCCESS, "loaded " _YELLOW_("%zu") " samples", GraphTraceLen);
|
PrintAndLogEx(SUCCESS, "loaded " _YELLOW_("%zu") " samples", g_GraphTraceLen);
|
||||||
|
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
|
|
||||||
removeSignalOffset(bits, size);
|
removeSignalOffset(bits, size);
|
||||||
|
@ -2093,15 +2093,15 @@ int CmdLtrim(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
// sanitycheck
|
// sanitycheck
|
||||||
if (GraphTraceLen <= ds) {
|
if (g_GraphTraceLen <= ds) {
|
||||||
PrintAndLogEx(WARNING, "index out of bounds");
|
PrintAndLogEx(WARNING, "index out of bounds");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (uint32_t i = ds; i < GraphTraceLen; ++i)
|
for (uint32_t i = ds; i < g_GraphTraceLen; ++i)
|
||||||
g_GraphBuffer[i - ds] = g_GraphBuffer[i];
|
g_GraphBuffer[i - ds] = g_GraphBuffer[i];
|
||||||
|
|
||||||
GraphTraceLen -= ds;
|
g_GraphTraceLen -= ds;
|
||||||
g_DemodStartIdx -= ds;
|
g_DemodStartIdx -= ds;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
|
@ -2125,12 +2125,12 @@ static int CmdRtrim(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
// sanitycheck
|
// sanitycheck
|
||||||
if (GraphTraceLen <= ds) {
|
if (g_GraphTraceLen <= ds) {
|
||||||
PrintAndLogEx(WARNING, "index out of bounds");
|
PrintAndLogEx(WARNING, "index out of bounds");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphTraceLen = ds;
|
g_GraphTraceLen = ds;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return PM3_SUCCESS;
|
return PM3_SUCCESS;
|
||||||
}
|
}
|
||||||
|
@ -2154,7 +2154,7 @@ static int CmdMtrim(const char *Cmd) {
|
||||||
uint32_t stop = arg_get_u32(ctx, 2);
|
uint32_t stop = arg_get_u32(ctx, 2);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if (start > GraphTraceLen || stop > GraphTraceLen || start >= stop) {
|
if (start > g_GraphTraceLen || stop > g_GraphTraceLen || start >= stop) {
|
||||||
PrintAndLogEx(WARNING, "start and end points doesn't align");
|
PrintAndLogEx(WARNING, "start and end points doesn't align");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -2162,8 +2162,8 @@ static int CmdMtrim(const char *Cmd) {
|
||||||
// leave start position sample
|
// leave start position sample
|
||||||
start++;
|
start++;
|
||||||
|
|
||||||
GraphTraceLen = stop - start;
|
g_GraphTraceLen = stop - start;
|
||||||
for (uint32_t i = 0; i < GraphTraceLen; i++) {
|
for (uint32_t i = 0; i < g_GraphTraceLen; i++) {
|
||||||
g_GraphBuffer[i] = g_GraphBuffer[start + i];
|
g_GraphBuffer[i] = g_GraphBuffer[start + i];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2187,19 +2187,19 @@ int CmdNorm(const char *Cmd) {
|
||||||
int max = INT_MIN, min = INT_MAX;
|
int max = INT_MIN, min = INT_MAX;
|
||||||
|
|
||||||
// Find local min, max
|
// Find local min, max
|
||||||
for (uint32_t i = 10; i < GraphTraceLen; ++i) {
|
for (uint32_t i = 10; i < g_GraphTraceLen; ++i) {
|
||||||
if (g_GraphBuffer[i] > max) max = g_GraphBuffer[i];
|
if (g_GraphBuffer[i] > max) max = g_GraphBuffer[i];
|
||||||
if (g_GraphBuffer[i] < min) min = g_GraphBuffer[i];
|
if (g_GraphBuffer[i] < min) min = g_GraphBuffer[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
if (max != min) {
|
if (max != min) {
|
||||||
for (uint32_t i = 0; i < GraphTraceLen; ++i) {
|
for (uint32_t i = 0; i < g_GraphTraceLen; ++i) {
|
||||||
g_GraphBuffer[i] = ((long)(g_GraphBuffer[i] - ((max + min) / 2)) * 256) / (max - min);
|
g_GraphBuffer[i] = ((long)(g_GraphBuffer[i] - ((max + min) / 2)) * 256) / (max - min);
|
||||||
//marshmelow: adjusted *1000 to *256 to make +/- 128 so demod commands still work
|
//marshmelow: adjusted *1000 to *256 to make +/- 128 so demod commands still work
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||||
computeSignalProperties(bits, size);
|
computeSignalProperties(bits, size);
|
||||||
|
@ -2254,9 +2254,9 @@ int CmdSave(const char *Cmd) {
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
if (as_wave)
|
if (as_wave)
|
||||||
return saveFileWAVE(filename, g_GraphBuffer, GraphTraceLen);
|
return saveFileWAVE(filename, g_GraphBuffer, g_GraphTraceLen);
|
||||||
else
|
else
|
||||||
return saveFilePM3(filename, g_GraphBuffer, GraphTraceLen);
|
return saveFilePM3(filename, g_GraphBuffer, g_GraphTraceLen);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CmdTimeScale(const char *Cmd) {
|
static int CmdTimeScale(const char *Cmd) {
|
||||||
|
@ -2338,10 +2338,10 @@ static int CmdDirectionalThreshold(const char *Cmd) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Applying up threshold: " _YELLOW_("%i") ", down threshold: " _YELLOW_("%i") "\n", up, down);
|
PrintAndLogEx(INFO, "Applying up threshold: " _YELLOW_("%i") ", down threshold: " _YELLOW_("%i") "\n", up, down);
|
||||||
|
|
||||||
directionalThreshold(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, up, down);
|
directionalThreshold(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, up, down);
|
||||||
|
|
||||||
// set signal properties low/high/mean/amplitude and isnoice detection
|
// set signal properties low/high/mean/amplitude and isnoice detection
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
// set signal properties low/high/mean/amplitude and is_noice detection
|
// set signal properties low/high/mean/amplitude and is_noice detection
|
||||||
computeSignalProperties(bits, size);
|
computeSignalProperties(bits, size);
|
||||||
|
@ -2368,7 +2368,7 @@ static int CmdZerocrossings(const char *Cmd) {
|
||||||
|
|
||||||
int sign = 1, zc = 0, lastZc = 0;
|
int sign = 1, zc = 0, lastZc = 0;
|
||||||
|
|
||||||
for (uint32_t i = 0; i < GraphTraceLen; ++i) {
|
for (uint32_t i = 0; i < g_GraphTraceLen; ++i) {
|
||||||
if (g_GraphBuffer[i] * sign >= 0) {
|
if (g_GraphBuffer[i] * sign >= 0) {
|
||||||
// No change in sign, reproduce the previous sample count.
|
// No change in sign, reproduce the previous sample count.
|
||||||
zc++;
|
zc++;
|
||||||
|
@ -2384,7 +2384,7 @@ static int CmdZerocrossings(const char *Cmd) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||||
computeSignalProperties(bits, size);
|
computeSignalProperties(bits, size);
|
||||||
|
@ -2664,7 +2664,7 @@ static int CmdFSKToNRZ(const char *Cmd) {
|
||||||
|
|
||||||
setClockGrid(0, 0);
|
setClockGrid(0, 0);
|
||||||
g_DemodBufferLen = 0;
|
g_DemodBufferLen = 0;
|
||||||
int ans = FSKToNRZ(g_GraphBuffer, &GraphTraceLen, clk, fc_low, fc_high);
|
int ans = FSKToNRZ(g_GraphBuffer, &g_GraphTraceLen, clk, fc_low, fc_high);
|
||||||
CmdNorm("");
|
CmdNorm("");
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
return ans;
|
return ans;
|
||||||
|
@ -2686,9 +2686,9 @@ static int CmdDataIIR(const char *Cmd) {
|
||||||
uint8_t k = (arg_get_u32_def(ctx, 1, 0) & 0xFF);
|
uint8_t k = (arg_get_u32_def(ctx, 1, 0) & 0xFF);
|
||||||
CLIParserFree(ctx);
|
CLIParserFree(ctx);
|
||||||
|
|
||||||
iceSimple_Filter(g_GraphBuffer, GraphTraceLen, k);
|
iceSimple_Filter(g_GraphBuffer, g_GraphTraceLen, k);
|
||||||
|
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
// set signal properties low/high/mean/amplitude and is_noise detection
|
// set signal properties low/high/mean/amplitude and is_noise detection
|
||||||
computeSignalProperties(bits, size);
|
computeSignalProperties(bits, size);
|
||||||
|
|
|
@ -340,7 +340,7 @@ int CmdHFSniff(const char *Cmd) {
|
||||||
// it reserve memory from the higher end.
|
// it reserve memory from the higher end.
|
||||||
// At the moment, sniff takes all free memory in bigbuff. If this changes,
|
// At the moment, sniff takes all free memory in bigbuff. If this changes,
|
||||||
// we can't start from beginning idx 0 but from that hi-to-start-of-allocated.
|
// we can't start from beginning idx 0 but from that hi-to-start-of-allocated.
|
||||||
uint32_t start = pm3_capabilities.bigbuf_size - retval->len;
|
uint32_t start = g_pm3_capabilities.bigbuf_size - retval->len;
|
||||||
int res = getSamplesEx(start, start, false);
|
int res = getSamplesEx(start, start, false);
|
||||||
if (res != PM3_SUCCESS) {
|
if (res != PM3_SUCCESS) {
|
||||||
PrintAndLogEx(WARNING, "failed to download samples to client");
|
PrintAndLogEx(WARNING, "failed to download samples to client");
|
||||||
|
@ -368,7 +368,7 @@ int handle_hf_plot(void) {
|
||||||
g_GraphBuffer[i] = ((int)buf[i]) - 128;
|
g_GraphBuffer[i] = ((int)buf[i]) - 128;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphTraceLen = FPGA_TRACE_SIZE;
|
g_GraphTraceLen = FPGA_TRACE_SIZE;
|
||||||
|
|
||||||
ShowGraphWindow();
|
ShowGraphWindow();
|
||||||
|
|
||||||
|
|
|
@ -510,7 +510,7 @@ static int CmdHF15Demod(const char *Cmd) {
|
||||||
int max = 0, maxPos = 0;
|
int max = 0, maxPos = 0;
|
||||||
int skip = 4;
|
int skip = 4;
|
||||||
|
|
||||||
if (GraphTraceLen < 1000) {
|
if (g_GraphTraceLen < 1000) {
|
||||||
PrintAndLogEx(FAILED, "Too few samples in GraphBuffer. Need more than 1000");
|
PrintAndLogEx(FAILED, "Too few samples in GraphBuffer. Need more than 1000");
|
||||||
PrintAndLogEx(HINT, "Run " _YELLOW_("`hf 15 samples`") " to collect and download data");
|
PrintAndLogEx(HINT, "Run " _YELLOW_("`hf 15 samples`") " to collect and download data");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
@ -566,7 +566,7 @@ static int CmdHF15Demod(const char *Cmd) {
|
||||||
mask = 0x01;
|
mask = 0x01;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((i + (int)ARRAYLEN(FrameEOF)) >= GraphTraceLen) {
|
if ((i + (int)ARRAYLEN(FrameEOF)) >= g_GraphTraceLen) {
|
||||||
PrintAndLogEx(INFO, "ran off end!");
|
PrintAndLogEx(INFO, "ran off end!");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -367,12 +367,12 @@ int CmdFlexdemod(const char *Cmd) {
|
||||||
#endif
|
#endif
|
||||||
int i, j, start, bit, sum;
|
int i, j, start, bit, sum;
|
||||||
|
|
||||||
int data[GraphTraceLen];
|
int data[g_GraphTraceLen];
|
||||||
memcpy(data, g_GraphBuffer, GraphTraceLen);
|
memcpy(data, g_GraphBuffer, g_GraphTraceLen);
|
||||||
|
|
||||||
size_t size = GraphTraceLen;
|
size_t size = g_GraphTraceLen;
|
||||||
|
|
||||||
for (i = 0; i < GraphTraceLen; ++i)
|
for (i = 0; i < g_GraphTraceLen; ++i)
|
||||||
data[i] = (data[i] < 0) ? -1 : 1;
|
data[i] = (data[i] < 0) ? -1 : 1;
|
||||||
|
|
||||||
for (start = 0; start < size - LONG_WAIT; start++) {
|
for (start = 0; start < size - LONG_WAIT; start++) {
|
||||||
|
@ -419,7 +419,7 @@ int CmdFlexdemod(const char *Cmd) {
|
||||||
|
|
||||||
// iceman, use g_DemodBuffer? blue line?
|
// iceman, use g_DemodBuffer? blue line?
|
||||||
// HACK writing back to graphbuffer.
|
// HACK writing back to graphbuffer.
|
||||||
GraphTraceLen = 32 * 64;
|
g_GraphTraceLen = 32 * 64;
|
||||||
i = 0;
|
i = 0;
|
||||||
for (bit = 0; bit < 64; bit++) {
|
for (bit = 0; bit < 64; bit++) {
|
||||||
|
|
||||||
|
@ -765,7 +765,7 @@ int CmdLFSniff(const char *Cmd) {
|
||||||
|
|
||||||
static void lf_chk_bitstream(void) {
|
static void lf_chk_bitstream(void) {
|
||||||
// convert to bitstream if necessary
|
// convert to bitstream if necessary
|
||||||
for (int i = 0; i < (int)(GraphTraceLen / 2); i++) {
|
for (int i = 0; i < (int)(g_GraphTraceLen / 2); i++) {
|
||||||
if (g_GraphBuffer[i] > 1 || g_GraphBuffer[i] < 0) {
|
if (g_GraphBuffer[i] > 1 || g_GraphBuffer[i] < 0) {
|
||||||
CmdGetBitStream("");
|
CmdGetBitStream("");
|
||||||
PrintAndLogEx(INFO, "converted Graphbuffer to bitstream values (0|1)");
|
PrintAndLogEx(INFO, "converted Graphbuffer to bitstream values (0|1)");
|
||||||
|
@ -776,7 +776,7 @@ static void lf_chk_bitstream(void) {
|
||||||
|
|
||||||
// Uploads g_GraphBuffer to device, in order to be used for LF SIM.
|
// Uploads g_GraphBuffer to device, in order to be used for LF SIM.
|
||||||
int lfsim_upload_gb(void) {
|
int lfsim_upload_gb(void) {
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: Uploading %zu bytes", GraphTraceLen);
|
PrintAndLogEx(DEBUG, "DEBUG: Uploading %zu bytes", g_GraphTraceLen);
|
||||||
|
|
||||||
struct pupload {
|
struct pupload {
|
||||||
uint8_t flag;
|
uint8_t flag;
|
||||||
|
@ -796,9 +796,9 @@ int lfsim_upload_gb(void) {
|
||||||
|
|
||||||
//can send only 512 bits at a time (1 byte sent per bit...)
|
//can send only 512 bits at a time (1 byte sent per bit...)
|
||||||
PrintAndLogEx(INFO, "." NOLF);
|
PrintAndLogEx(INFO, "." NOLF);
|
||||||
for (uint16_t i = 0; i < GraphTraceLen; i += PM3_CMD_DATA_SIZE - 3) {
|
for (uint16_t i = 0; i < g_GraphTraceLen; i += PM3_CMD_DATA_SIZE - 3) {
|
||||||
|
|
||||||
size_t len = MIN((GraphTraceLen - i), PM3_CMD_DATA_SIZE - 3);
|
size_t len = MIN((g_GraphTraceLen - i), PM3_CMD_DATA_SIZE - 3);
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
payload_up.offset = i;
|
payload_up.offset = i;
|
||||||
|
|
||||||
|
@ -848,7 +848,7 @@ int CmdLFSim(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// sanity check
|
// sanity check
|
||||||
if (GraphTraceLen < 20) {
|
if (g_GraphTraceLen < 20) {
|
||||||
PrintAndLogEx(ERR, "No data in Graphbuffer");
|
PrintAndLogEx(ERR, "No data in Graphbuffer");
|
||||||
return PM3_ENODATA;
|
return PM3_ENODATA;
|
||||||
}
|
}
|
||||||
|
@ -862,7 +862,7 @@ int CmdLFSim(const char *Cmd) {
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint16_t gap;
|
uint16_t gap;
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
payload.len = GraphTraceLen;
|
payload.len = g_GraphTraceLen;
|
||||||
payload.gap = gap;
|
payload.gap = gap;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
@ -1245,7 +1245,7 @@ int CmdLFSimBidir(const char *Cmd) {
|
||||||
|
|
||||||
int CmdVchDemod(const char *Cmd) {
|
int CmdVchDemod(const char *Cmd) {
|
||||||
|
|
||||||
if (GraphTraceLen < 4096) {
|
if (g_GraphTraceLen < 4096) {
|
||||||
PrintAndLogEx(DEBUG, "debug; VchDemod - too few samples");
|
PrintAndLogEx(DEBUG, "debug; VchDemod - too few samples");
|
||||||
return PM3_EINVARG;
|
return PM3_EINVARG;
|
||||||
}
|
}
|
||||||
|
@ -1274,7 +1274,7 @@ int CmdVchDemod(const char *Cmd) {
|
||||||
|
|
||||||
// It does us no good to find the sync pattern, with fewer than 2048 samples after it.
|
// It does us no good to find the sync pattern, with fewer than 2048 samples after it.
|
||||||
|
|
||||||
for (i = 0; i < (GraphTraceLen - 2048); i++) {
|
for (i = 0; i < (g_GraphTraceLen - 2048); i++) {
|
||||||
for (j = 0; j < ARRAYLEN(SyncPattern); j++) {
|
for (j = 0; j < ARRAYLEN(SyncPattern); j++) {
|
||||||
sum += g_GraphBuffer[i + j] * SyncPattern[j];
|
sum += g_GraphBuffer[i + j] * SyncPattern[j];
|
||||||
}
|
}
|
||||||
|
@ -1311,11 +1311,11 @@ int CmdVchDemod(const char *Cmd) {
|
||||||
|
|
||||||
// clone
|
// clone
|
||||||
if (strcmp(Cmd, "clone") == 0) {
|
if (strcmp(Cmd, "clone") == 0) {
|
||||||
GraphTraceLen = 0;
|
g_GraphTraceLen = 0;
|
||||||
char *s;
|
char *s;
|
||||||
for (s = bits; *s; s++) {
|
for (s = bits; *s; s++) {
|
||||||
for (j = 0; j < 16; j++) {
|
for (j = 0; j < 16; j++) {
|
||||||
g_GraphBuffer[GraphTraceLen++] = (*s == '1') ? 1 : 0;
|
g_GraphBuffer[g_GraphTraceLen++] = (*s == '1') ? 1 : 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -1402,7 +1402,7 @@ int CmdLFfind(const char *Cmd) {
|
||||||
lf_read(false, 30000);
|
lf_read(false, 30000);
|
||||||
|
|
||||||
size_t min_length = 2000;
|
size_t min_length = 2000;
|
||||||
if (GraphTraceLen < min_length) {
|
if (g_GraphTraceLen < min_length) {
|
||||||
PrintAndLogEx(FAILED, "Data in Graphbuffer was too small.");
|
PrintAndLogEx(FAILED, "Data in Graphbuffer was too small.");
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
}
|
}
|
||||||
|
@ -1690,7 +1690,7 @@ int CmdLFfind(const char *Cmd) {
|
||||||
if (search_unk) {
|
if (search_unk) {
|
||||||
//test unknown tag formats (raw mode)
|
//test unknown tag formats (raw mode)
|
||||||
PrintAndLogEx(INFO, "\nChecking for unknown tags:\n");
|
PrintAndLogEx(INFO, "\nChecking for unknown tags:\n");
|
||||||
int ans = AutoCorrelate(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, 8000, false, false);
|
int ans = AutoCorrelate(g_GraphBuffer, g_GraphBuffer, g_GraphTraceLen, 8000, false, false);
|
||||||
if (ans > 0) {
|
if (ans > 0) {
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Possible auto correlation of %d repeating samples", ans);
|
PrintAndLogEx(INFO, "Possible auto correlation of %d repeating samples", ans);
|
||||||
|
|
|
@ -580,7 +580,7 @@ static int CmdEM410xBrute(const char *Cmd) {
|
||||||
uint16_t len;
|
uint16_t len;
|
||||||
uint16_t gap;
|
uint16_t gap;
|
||||||
} PACKED payload;
|
} PACKED payload;
|
||||||
payload.len = GraphTraceLen;
|
payload.len = g_GraphTraceLen;
|
||||||
payload.gap = 0;
|
payload.gap = 0;
|
||||||
|
|
||||||
clearCommandBuffer();
|
clearCommandBuffer();
|
||||||
|
|
|
@ -2021,18 +2021,18 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
// loop though sample buffer
|
// loop though sample buffer
|
||||||
while (idx < GraphTraceLen) {
|
while (idx < g_GraphTraceLen) {
|
||||||
eop = false;
|
eop = false;
|
||||||
haveData = false;
|
haveData = false;
|
||||||
pwd = false;
|
pwd = false;
|
||||||
|
|
||||||
idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, g_GraphBuffer, &pulseSamples);
|
idx = em4x05_Sniff_GetNextBitStart(idx, g_GraphTraceLen, g_GraphBuffer, &pulseSamples);
|
||||||
pktOffset = idx;
|
pktOffset = idx;
|
||||||
if (pulseSamples >= 10) { // Should be 18 so a bit less to allow for processing
|
if (pulseSamples >= 10) { // Should be 18 so a bit less to allow for processing
|
||||||
|
|
||||||
// Use first bit to get "0" bit samples as a reference
|
// Use first bit to get "0" bit samples as a reference
|
||||||
ZeroWidth = idx;
|
ZeroWidth = idx;
|
||||||
idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, g_GraphBuffer, &pulseSamples);
|
idx = em4x05_Sniff_GetNextBitStart(idx, g_GraphTraceLen, g_GraphBuffer, &pulseSamples);
|
||||||
ZeroWidth = idx - ZeroWidth;
|
ZeroWidth = idx - ZeroWidth;
|
||||||
|
|
||||||
if (ZeroWidth <= 50) {
|
if (ZeroWidth <= 50) {
|
||||||
|
@ -2040,9 +2040,9 @@ int CmdEM4x05Sniff(const char *Cmd) {
|
||||||
memset(bits, 0x00, sizeof(bits));
|
memset(bits, 0x00, sizeof(bits));
|
||||||
bitidx = 0;
|
bitidx = 0;
|
||||||
|
|
||||||
while ((idx < GraphTraceLen) && !eop) {
|
while ((idx < g_GraphTraceLen) && !eop) {
|
||||||
CycleWidth = idx;
|
CycleWidth = idx;
|
||||||
idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, g_GraphBuffer, &pulseSamples);
|
idx = em4x05_Sniff_GetNextBitStart(idx, g_GraphTraceLen, g_GraphBuffer, &pulseSamples);
|
||||||
|
|
||||||
CycleWidth = idx - CycleWidth;
|
CycleWidth = idx - CycleWidth;
|
||||||
if ((CycleWidth > 300) || (CycleWidth < (ZeroWidth - 5))) { // to long or too short
|
if ((CycleWidth > 300) || (CycleWidth < (ZeroWidth - 5))) { // to long or too short
|
||||||
|
|
|
@ -105,7 +105,7 @@ int demodHID(bool verbose) {
|
||||||
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
//raw fsk demod no manchester decoding no start bit finding just get binary from wave
|
||||||
uint32_t hi2 = 0, hi = 0, lo = 0;
|
uint32_t hi2 = 0, hi = 0, lo = 0;
|
||||||
|
|
||||||
uint8_t bits[GraphTraceLen];
|
uint8_t bits[g_GraphTraceLen];
|
||||||
size_t size = getFromGraphBuf(bits);
|
size_t size = getFromGraphBuf(bits);
|
||||||
if (size == 0) {
|
if (size == 0) {
|
||||||
PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID not enough samples"));
|
PrintAndLogEx(DEBUG, "DEBUG: Error - " _RED_("HID not enough samples"));
|
||||||
|
|
|
@ -303,7 +303,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
// worst case with GraphTraceLen=40000 is < 4096
|
// worst case with g_GraphTraceLen=40000 is < 4096
|
||||||
// under normal conditions it's < 2048
|
// under normal conditions it's < 2048
|
||||||
uint8_t data[MAX_GRAPH_TRACE_LEN] = {0};
|
uint8_t data[MAX_GRAPH_TRACE_LEN] = {0};
|
||||||
size_t datasize = getFromGraphBuf(data);
|
size_t datasize = getFromGraphBuf(data);
|
||||||
|
@ -316,7 +316,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
||||||
setClockGrid(0, 0);
|
setClockGrid(0, 0);
|
||||||
g_DemodBufferLen = 0;
|
g_DemodBufferLen = 0;
|
||||||
|
|
||||||
// PrintAndLogEx(NORMAL, "Expecting a bit less than %d raw bits", GraphTraceLen / 32);
|
// PrintAndLogEx(NORMAL, "Expecting a bit less than %d raw bits", g_GraphTraceLen / 32);
|
||||||
// loop through raw signal - since we know it is psk1 rf/32 fc/2 skip every other value (+=2)
|
// loop through raw signal - since we know it is psk1 rf/32 fc/2 skip every other value (+=2)
|
||||||
for (i = 0; i < datasize - 1; i += 2) {
|
for (i = 0; i < datasize - 1; i += 2) {
|
||||||
count += 1;
|
count += 1;
|
||||||
|
@ -350,7 +350,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (rawbit > 0) {
|
if (rawbit > 0) {
|
||||||
PrintAndLogEx(INFO, "Recovered %d raw bits, expected: %zu", rawbit, GraphTraceLen / 32);
|
PrintAndLogEx(INFO, "Recovered %d raw bits, expected: %zu", rawbit, g_GraphTraceLen / 32);
|
||||||
PrintAndLogEx(INFO, "Worst metric (0=best..7=worst): %d at pos %d", worst, worstPos);
|
PrintAndLogEx(INFO, "Worst metric (0=best..7=worst): %d at pos %d", worst, worstPos);
|
||||||
} else {
|
} else {
|
||||||
return PM3_ESOFT;
|
return PM3_ESOFT;
|
||||||
|
@ -476,7 +476,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) {
|
||||||
// Remodulating for tag cloning
|
// Remodulating for tag cloning
|
||||||
// HACK: 2015-01-04 this will have an impact on our new way of seening lf commands (demod)
|
// HACK: 2015-01-04 this will have an impact on our new way of seening lf commands (demod)
|
||||||
// since this changes graphbuffer data.
|
// since this changes graphbuffer data.
|
||||||
GraphTraceLen = 32 * uidlen;
|
g_GraphTraceLen = 32 * uidlen;
|
||||||
i = 0;
|
i = 0;
|
||||||
int phase;
|
int phase;
|
||||||
for (bit = 0; bit < uidlen; bit++) {
|
for (bit = 0; bit < uidlen; bit++) {
|
||||||
|
|
|
@ -2883,7 +2883,7 @@ static int CmdResetRead(const char *Cmd) {
|
||||||
|
|
||||||
if (resp.status == PM3_SUCCESS) {
|
if (resp.status == PM3_SUCCESS) {
|
||||||
|
|
||||||
uint16_t gotsize = pm3_capabilities.bigbuf_size - 1;
|
uint16_t gotsize = g_pm3_capabilities.bigbuf_size - 1;
|
||||||
uint8_t *got = calloc(gotsize, sizeof(uint8_t));
|
uint8_t *got = calloc(gotsize, sizeof(uint8_t));
|
||||||
if (got == NULL) {
|
if (got == NULL) {
|
||||||
PrintAndLogEx(WARNING, "failed to allocate memory");
|
PrintAndLogEx(WARNING, "failed to allocate memory");
|
||||||
|
@ -4043,7 +4043,7 @@ static int CmdT55xxSniff(const char *Cmd) {
|
||||||
|
|
||||||
idx = 0;
|
idx = 0;
|
||||||
// loop though sample buffer
|
// loop though sample buffer
|
||||||
while (idx < GraphTraceLen) {
|
while (idx < g_GraphTraceLen) {
|
||||||
|
|
||||||
int minWidth = 1000;
|
int minWidth = 1000;
|
||||||
int maxWidth = 0;
|
int maxWidth = 0;
|
||||||
|
@ -4059,13 +4059,13 @@ static int CmdT55xxSniff(const char *Cmd) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// find high
|
// find high
|
||||||
while ((idx < GraphTraceLen) && (g_GraphBuffer[idx] < 0)) {
|
while ((idx < g_GraphTraceLen) && (g_GraphBuffer[idx] < 0)) {
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
||||||
// count high samples
|
// count high samples
|
||||||
pulseSamples = 0;
|
pulseSamples = 0;
|
||||||
while ((idx < GraphTraceLen) && (g_GraphBuffer[idx] > 0)) { // last bit seems to be high to zero, but can vary in width..
|
while ((idx < g_GraphTraceLen) && (g_GraphBuffer[idx] > 0)) { // last bit seems to be high to zero, but can vary in width..
|
||||||
pulseSamples++;
|
pulseSamples++;
|
||||||
idx++;
|
idx++;
|
||||||
}
|
}
|
||||||
|
|
|
@ -90,7 +90,7 @@ int demodTI(bool verbose) {
|
||||||
int lowTot = 0, highTot = 0;
|
int lowTot = 0, highTot = 0;
|
||||||
int retval = PM3_ESOFT;
|
int retval = PM3_ESOFT;
|
||||||
|
|
||||||
for (i = 0; i < GraphTraceLen - convLen; i++) {
|
for (i = 0; i < g_GraphTraceLen - convLen; i++) {
|
||||||
lowSum = 0;
|
lowSum = 0;
|
||||||
highSum = 0;
|
highSum = 0;
|
||||||
|
|
||||||
|
@ -108,7 +108,7 @@ int demodTI(bool verbose) {
|
||||||
g_GraphBuffer[i] = (highSum << 16) | lowSum;
|
g_GraphBuffer[i] = (highSum << 16) | lowSum;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < GraphTraceLen - convLen - 16; i++) {
|
for (i = 0; i < g_GraphTraceLen - convLen - 16; i++) {
|
||||||
lowTot = 0;
|
lowTot = 0;
|
||||||
highTot = 0;
|
highTot = 0;
|
||||||
// 16 and 15 are f_s divided by f_l and f_h, rounded
|
// 16 and 15 are f_s divided by f_l and f_h, rounded
|
||||||
|
@ -121,7 +121,7 @@ int demodTI(bool verbose) {
|
||||||
g_GraphBuffer[i] = lowTot - highTot;
|
g_GraphBuffer[i] = lowTot - highTot;
|
||||||
}
|
}
|
||||||
|
|
||||||
GraphTraceLen -= (convLen + 16);
|
g_GraphTraceLen -= (convLen + 16);
|
||||||
|
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
|
||||||
|
|
|
@ -30,42 +30,42 @@ bool IfPm3Present(void) {
|
||||||
bool IfPm3Rdv4Fw(void) {
|
bool IfPm3Rdv4Fw(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return (pm3_capabilities.compiled_with_flash) || (pm3_capabilities.compiled_with_smartcard);
|
return (g_pm3_capabilities.compiled_with_flash) || (g_pm3_capabilities.compiled_with_smartcard);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Flash(void) {
|
bool IfPm3Flash(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
if (!pm3_capabilities.compiled_with_flash)
|
if (!g_pm3_capabilities.compiled_with_flash)
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.hw_available_flash;
|
return g_pm3_capabilities.hw_available_flash;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Smartcard(void) {
|
bool IfPm3Smartcard(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
if (!pm3_capabilities.compiled_with_smartcard)
|
if (!g_pm3_capabilities.compiled_with_smartcard)
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.hw_available_smartcard;
|
return g_pm3_capabilities.hw_available_smartcard;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3FpcUsart(void) {
|
bool IfPm3FpcUsart(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_fpc_usart;
|
return g_pm3_capabilities.compiled_with_fpc_usart;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3FpcUsartHost(void) {
|
bool IfPm3FpcUsartHost(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_fpc_usart_host;
|
return g_pm3_capabilities.compiled_with_fpc_usart_host;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3FpcUsartHostFromUsb(void) {
|
bool IfPm3FpcUsartHostFromUsb(void) {
|
||||||
// true if FPC USART Host support and if talking from USB-CDC interface
|
// true if FPC USART Host support and if talking from USB-CDC interface
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
if (!pm3_capabilities.compiled_with_fpc_usart_host)
|
if (!g_pm3_capabilities.compiled_with_fpc_usart_host)
|
||||||
return false;
|
return false;
|
||||||
return !conn.send_via_fpc_usart;
|
return !conn.send_via_fpc_usart;
|
||||||
}
|
}
|
||||||
|
@ -74,7 +74,7 @@ bool IfPm3FpcUsartDevFromUsb(void) {
|
||||||
// true if FPC USART developer support and if talking from USB-CDC interface
|
// true if FPC USART developer support and if talking from USB-CDC interface
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
if (!pm3_capabilities.compiled_with_fpc_usart_dev)
|
if (!g_pm3_capabilities.compiled_with_fpc_usart_dev)
|
||||||
return false;
|
return false;
|
||||||
return !conn.send_via_fpc_usart;
|
return !conn.send_via_fpc_usart;
|
||||||
}
|
}
|
||||||
|
@ -87,92 +87,92 @@ bool IfPm3FpcUsartFromUsb(void) {
|
||||||
bool IfPm3Lf(void) {
|
bool IfPm3Lf(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_lf;
|
return g_pm3_capabilities.compiled_with_lf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Hitag(void) {
|
bool IfPm3Hitag(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_hitag;
|
return g_pm3_capabilities.compiled_with_hitag;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3EM4x50(void) {
|
bool IfPm3EM4x50(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_em4x50;
|
return g_pm3_capabilities.compiled_with_em4x50;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3EM4x70(void) {
|
bool IfPm3EM4x70(void) {
|
||||||
|
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_em4x70;
|
return g_pm3_capabilities.compiled_with_em4x70;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Hfsniff(void) {
|
bool IfPm3Hfsniff(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_hfsniff;
|
return g_pm3_capabilities.compiled_with_hfsniff;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Hfplot(void) {
|
bool IfPm3Hfplot(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_hfplot;
|
return g_pm3_capabilities.compiled_with_hfplot;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Iso14443a(void) {
|
bool IfPm3Iso14443a(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_iso14443a;
|
return g_pm3_capabilities.compiled_with_iso14443a;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Iso14443b(void) {
|
bool IfPm3Iso14443b(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_iso14443b;
|
return g_pm3_capabilities.compiled_with_iso14443b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Iso14443(void) {
|
bool IfPm3Iso14443(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_iso14443a || pm3_capabilities.compiled_with_iso14443b;
|
return g_pm3_capabilities.compiled_with_iso14443a || g_pm3_capabilities.compiled_with_iso14443b;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Iso15693(void) {
|
bool IfPm3Iso15693(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_iso15693;
|
return g_pm3_capabilities.compiled_with_iso15693;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Felica(void) {
|
bool IfPm3Felica(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_felica;
|
return g_pm3_capabilities.compiled_with_felica;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Legicrf(void) {
|
bool IfPm3Legicrf(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_legicrf;
|
return g_pm3_capabilities.compiled_with_legicrf;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Iclass(void) {
|
bool IfPm3Iclass(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_iclass;
|
return g_pm3_capabilities.compiled_with_iclass;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3NfcBarcode(void) {
|
bool IfPm3NfcBarcode(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_nfcbarcode;
|
return g_pm3_capabilities.compiled_with_nfcbarcode;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IfPm3Lcd(void) {
|
bool IfPm3Lcd(void) {
|
||||||
if (!IfPm3Present())
|
if (!IfPm3Present())
|
||||||
return false;
|
return false;
|
||||||
return pm3_capabilities.compiled_with_lcd;
|
return g_pm3_capabilities.compiled_with_lcd;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -30,7 +30,7 @@
|
||||||
static serial_port sp = NULL;
|
static serial_port sp = NULL;
|
||||||
|
|
||||||
communication_arg_t conn;
|
communication_arg_t conn;
|
||||||
capabilities_t pm3_capabilities;
|
capabilities_t g_pm3_capabilities;
|
||||||
|
|
||||||
static pthread_t communication_thread;
|
static pthread_t communication_thread;
|
||||||
static bool comm_thread_dead = false;
|
static bool comm_thread_dead = false;
|
||||||
|
@ -638,15 +638,15 @@ int TestProxmark(pm3_device *dev) {
|
||||||
return PM3_ETIMEOUT;
|
return PM3_ETIMEOUT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((resp.length != sizeof(pm3_capabilities)) || (resp.data.asBytes[0] != CAPABILITIES_VERSION)) {
|
if ((resp.length != sizeof(g_pm3_capabilities)) || (resp.data.asBytes[0] != CAPABILITIES_VERSION)) {
|
||||||
PrintAndLogEx(ERR, _RED_("Capabilities structure version sent by Proxmark3 is not the same as the one used by the client!"));
|
PrintAndLogEx(ERR, _RED_("Capabilities structure version sent by Proxmark3 is not the same as the one used by the client!"));
|
||||||
PrintAndLogEx(ERR, _RED_("Please flash the Proxmark with the same version as the client."));
|
PrintAndLogEx(ERR, _RED_("Please flash the Proxmark with the same version as the client."));
|
||||||
return PM3_EDEVNOTSUPP;
|
return PM3_EDEVNOTSUPP;
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&pm3_capabilities, resp.data.asBytes, MIN(sizeof(capabilities_t), resp.length));
|
memcpy(&g_pm3_capabilities, resp.data.asBytes, MIN(sizeof(capabilities_t), resp.length));
|
||||||
conn.send_via_fpc_usart = pm3_capabilities.via_fpc;
|
conn.send_via_fpc_usart = g_pm3_capabilities.via_fpc;
|
||||||
conn.uart_speed = pm3_capabilities.baudrate;
|
conn.uart_speed = g_pm3_capabilities.baudrate;
|
||||||
|
|
||||||
PrintAndLogEx(INFO, "Communicating with PM3 over %s%s%s",
|
PrintAndLogEx(INFO, "Communicating with PM3 over %s%s%s",
|
||||||
conn.send_via_fpc_usart ? _YELLOW_("FPC UART") : _YELLOW_("USB-CDC"),
|
conn.send_via_fpc_usart ? _YELLOW_("FPC UART") : _YELLOW_("USB-CDC"),
|
||||||
|
|
|
@ -18,7 +18,7 @@
|
||||||
|
|
||||||
|
|
||||||
int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
size_t GraphTraceLen;
|
size_t g_GraphTraceLen;
|
||||||
|
|
||||||
/* write a manchester bit to the graph
|
/* write a manchester bit to the graph
|
||||||
TODO, verfy that this doesn't overflow buffer (iceman)
|
TODO, verfy that this doesn't overflow buffer (iceman)
|
||||||
|
@ -28,11 +28,11 @@ void AppendGraph(bool redraw, uint16_t clock, int bit) {
|
||||||
uint8_t i;
|
uint8_t i;
|
||||||
//set first half the clock bit (all 1's or 0's for a 0 or 1 bit)
|
//set first half the clock bit (all 1's or 0's for a 0 or 1 bit)
|
||||||
for (i = 0; i < half; ++i)
|
for (i = 0; i < half; ++i)
|
||||||
g_GraphBuffer[GraphTraceLen++] = bit;
|
g_GraphBuffer[g_GraphTraceLen++] = bit;
|
||||||
|
|
||||||
//set second half of the clock bit (all 0's or 1's for a 0 or 1 bit)
|
//set second half of the clock bit (all 0's or 1's for a 0 or 1 bit)
|
||||||
for (; i < clock; ++i)
|
for (; i < clock; ++i)
|
||||||
g_GraphBuffer[GraphTraceLen++] = bit ^ 1;
|
g_GraphBuffer[g_GraphTraceLen++] = bit ^ 1;
|
||||||
|
|
||||||
if (redraw)
|
if (redraw)
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -40,9 +40,9 @@ void AppendGraph(bool redraw, uint16_t clock, int bit) {
|
||||||
|
|
||||||
// clear out our graph window
|
// clear out our graph window
|
||||||
size_t ClearGraph(bool redraw) {
|
size_t ClearGraph(bool redraw) {
|
||||||
size_t gtl = GraphTraceLen;
|
size_t gtl = g_GraphTraceLen;
|
||||||
memset(g_GraphBuffer, 0x00, GraphTraceLen);
|
memset(g_GraphBuffer, 0x00, g_GraphTraceLen);
|
||||||
GraphTraceLen = 0;
|
g_GraphTraceLen = 0;
|
||||||
g_GraphStart = 0;
|
g_GraphStart = 0;
|
||||||
g_GraphStop = 0;
|
g_GraphStop = 0;
|
||||||
|
|
||||||
|
@ -61,12 +61,12 @@ void save_restoreGB(uint8_t saveOpt) {
|
||||||
|
|
||||||
if (saveOpt == GRAPH_SAVE) { //save
|
if (saveOpt == GRAPH_SAVE) { //save
|
||||||
memcpy(SavedGB, g_GraphBuffer, sizeof(g_GraphBuffer));
|
memcpy(SavedGB, g_GraphBuffer, sizeof(g_GraphBuffer));
|
||||||
SavedGBlen = GraphTraceLen;
|
SavedGBlen = g_GraphTraceLen;
|
||||||
GB_Saved = true;
|
GB_Saved = true;
|
||||||
Savedg_GridOffsetAdj = g_GridOffset;
|
Savedg_GridOffsetAdj = g_GridOffset;
|
||||||
} else if (GB_Saved) { //restore
|
} else if (GB_Saved) { //restore
|
||||||
memcpy(g_GraphBuffer, SavedGB, sizeof(g_GraphBuffer));
|
memcpy(g_GraphBuffer, SavedGB, sizeof(g_GraphBuffer));
|
||||||
GraphTraceLen = SavedGBlen;
|
g_GraphTraceLen = SavedGBlen;
|
||||||
g_GridOffset = Savedg_GridOffsetAdj;
|
g_GridOffset = Savedg_GridOffsetAdj;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
|
@ -83,16 +83,16 @@ void setGraphBuf(uint8_t *buff, size_t size) {
|
||||||
for (size_t i = 0; i < size; ++i)
|
for (size_t i = 0; i < size; ++i)
|
||||||
g_GraphBuffer[i] = buff[i] - 128;
|
g_GraphBuffer[i] = buff[i] - 128;
|
||||||
|
|
||||||
GraphTraceLen = size;
|
g_GraphTraceLen = size;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getFromGraphBuf(uint8_t *buff) {
|
size_t getFromGraphBuf(uint8_t *buff) {
|
||||||
if (buff == NULL) return 0;
|
if (buff == NULL) return 0;
|
||||||
if (GraphTraceLen == 0) return 0;
|
if (g_GraphTraceLen == 0) return 0;
|
||||||
|
|
||||||
size_t i;
|
size_t i;
|
||||||
for (i = 0; i < GraphTraceLen; ++i) {
|
for (i = 0; i < g_GraphTraceLen; ++i) {
|
||||||
//trim
|
//trim
|
||||||
if (g_GraphBuffer[i] > 127) g_GraphBuffer[i] = 127;
|
if (g_GraphBuffer[i] > 127) g_GraphBuffer[i] = 127;
|
||||||
if (g_GraphBuffer[i] < -127) g_GraphBuffer[i] = -127;
|
if (g_GraphBuffer[i] < -127) g_GraphBuffer[i] = -127;
|
||||||
|
@ -103,7 +103,7 @@ size_t getFromGraphBuf(uint8_t *buff) {
|
||||||
|
|
||||||
// A simple test to see if there is any data inside Graphbuffer.
|
// A simple test to see if there is any data inside Graphbuffer.
|
||||||
bool HasGraphData(void) {
|
bool HasGraphData(void) {
|
||||||
if (GraphTraceLen == 0) {
|
if (g_GraphTraceLen == 0) {
|
||||||
PrintAndLogEx(NORMAL, "No data available, try reading something first");
|
PrintAndLogEx(NORMAL, "No data available, try reading something first");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -112,7 +112,7 @@ bool HasGraphData(void) {
|
||||||
|
|
||||||
bool isGraphBitstream(void) {
|
bool isGraphBitstream(void) {
|
||||||
// convert to bitstream if necessary
|
// convert to bitstream if necessary
|
||||||
for (int i = 0; i < GraphTraceLen; i++) {
|
for (int i = 0; i < g_GraphTraceLen; i++) {
|
||||||
if (g_GraphBuffer[i] > 1 || g_GraphBuffer[i] < 0) {
|
if (g_GraphBuffer[i] > 1 || g_GraphBuffer[i] < 0) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -125,7 +125,7 @@ void convertGraphFromBitstream(void) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void convertGraphFromBitstreamEx(int hi, int low) {
|
void convertGraphFromBitstreamEx(int hi, int low) {
|
||||||
for (int i = 0; i < GraphTraceLen; i++) {
|
for (int i = 0; i < g_GraphTraceLen; i++) {
|
||||||
if (g_GraphBuffer[i] == hi)
|
if (g_GraphBuffer[i] == hi)
|
||||||
g_GraphBuffer[i] = 127;
|
g_GraphBuffer[i] = 127;
|
||||||
else if (g_GraphBuffer[i] == low)
|
else if (g_GraphBuffer[i] == low)
|
||||||
|
@ -134,7 +134,7 @@ void convertGraphFromBitstreamEx(int hi, int low) {
|
||||||
g_GraphBuffer[i] = 0;
|
g_GraphBuffer[i] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t *bits = calloc(GraphTraceLen, sizeof(uint8_t));
|
uint8_t *bits = calloc(g_GraphTraceLen, sizeof(uint8_t));
|
||||||
if (bits == NULL) {
|
if (bits == NULL) {
|
||||||
PrintAndLogEx(DEBUG, "ERR: convertGraphFromBitstreamEx, failed to allocate memory");
|
PrintAndLogEx(DEBUG, "ERR: convertGraphFromBitstreamEx, failed to allocate memory");
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -39,7 +39,7 @@ bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge);
|
||||||
#define GRAPH_RESTORE 0
|
#define GRAPH_RESTORE 0
|
||||||
|
|
||||||
extern int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
extern int g_GraphBuffer[MAX_GRAPH_TRACE_LEN];
|
||||||
extern size_t GraphTraceLen;
|
extern size_t g_GraphTraceLen;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
|
@ -292,7 +292,7 @@ void SliderWidget::moveEvent(QMoveEvent *event) {
|
||||||
void ProxWidget::applyOperation() {
|
void ProxWidget::applyOperation() {
|
||||||
//printf("ApplyOperation()");
|
//printf("ApplyOperation()");
|
||||||
save_restoreGB(GRAPH_SAVE);
|
save_restoreGB(GRAPH_SAVE);
|
||||||
memcpy(g_GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen);
|
memcpy(g_GraphBuffer, s_Buff, sizeof(int) * g_GraphTraceLen);
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
void ProxWidget::stickOperation() {
|
void ProxWidget::stickOperation() {
|
||||||
|
@ -300,21 +300,21 @@ void ProxWidget::stickOperation() {
|
||||||
//printf("stickOperation()");
|
//printf("stickOperation()");
|
||||||
}
|
}
|
||||||
void ProxWidget::vchange_autocorr(int v) {
|
void ProxWidget::vchange_autocorr(int v) {
|
||||||
int ans = AutoCorrelate(g_GraphBuffer, s_Buff, GraphTraceLen, v, true, false);
|
int ans = AutoCorrelate(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, true, false);
|
||||||
if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans);
|
if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans);
|
||||||
g_useOverlays = true;
|
g_useOverlays = true;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
void ProxWidget::vchange_askedge(int v) {
|
void ProxWidget::vchange_askedge(int v) {
|
||||||
//extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
//extern int AskEdgeDetect(const int *in, int *out, int len, int threshold);
|
||||||
int ans = AskEdgeDetect(g_GraphBuffer, s_Buff, GraphTraceLen, v);
|
int ans = AskEdgeDetect(g_GraphBuffer, s_Buff, g_GraphTraceLen, v);
|
||||||
if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans);
|
if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans);
|
||||||
g_useOverlays = true;
|
g_useOverlays = true;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
void ProxWidget::vchange_dthr_up(int v) {
|
void ProxWidget::vchange_dthr_up(int v) {
|
||||||
int down = opsController->horizontalSlider_dirthr_down->value();
|
int down = opsController->horizontalSlider_dirthr_down->value();
|
||||||
directionalThreshold(g_GraphBuffer, s_Buff, GraphTraceLen, v, down);
|
directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, down);
|
||||||
//printf("vchange_dthr_up(%d)", v);
|
//printf("vchange_dthr_up(%d)", v);
|
||||||
g_useOverlays = true;
|
g_useOverlays = true;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
|
@ -322,7 +322,7 @@ void ProxWidget::vchange_dthr_up(int v) {
|
||||||
void ProxWidget::vchange_dthr_down(int v) {
|
void ProxWidget::vchange_dthr_down(int v) {
|
||||||
//printf("vchange_dthr_down(%d)", v);
|
//printf("vchange_dthr_down(%d)", v);
|
||||||
int up = opsController->horizontalSlider_dirthr_up->value();
|
int up = opsController->horizontalSlider_dirthr_up->value();
|
||||||
directionalThreshold(g_GraphBuffer, s_Buff, GraphTraceLen, v, up);
|
directionalThreshold(g_GraphBuffer, s_Buff, g_GraphTraceLen, v, up);
|
||||||
g_useOverlays = true;
|
g_useOverlays = true;
|
||||||
RepaintGraphWindow();
|
RepaintGraphWindow();
|
||||||
}
|
}
|
||||||
|
@ -681,13 +681,13 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
|
|
||||||
painter.setFont(QFont("Courier New", 10));
|
painter.setFont(QFont("Courier New", 10));
|
||||||
|
|
||||||
if (CursorAPos > GraphTraceLen)
|
if (CursorAPos > g_GraphTraceLen)
|
||||||
CursorAPos = 0;
|
CursorAPos = 0;
|
||||||
if (CursorBPos > GraphTraceLen)
|
if (CursorBPos > g_GraphTraceLen)
|
||||||
CursorBPos = 0;
|
CursorBPos = 0;
|
||||||
if (g_CursorCPos > GraphTraceLen)
|
if (g_CursorCPos > g_GraphTraceLen)
|
||||||
g_CursorCPos = 0;
|
g_CursorCPos = 0;
|
||||||
if (g_CursorDPos > GraphTraceLen)
|
if (g_CursorDPos > g_GraphTraceLen)
|
||||||
g_CursorDPos = 0;
|
g_CursorDPos = 0;
|
||||||
|
|
||||||
QRect plotRect(WIDTH_AXES, 0, width() - WIDTH_AXES, height() - HEIGHT_INFO);
|
QRect plotRect(WIDTH_AXES, 0, width() - WIDTH_AXES, height() - HEIGHT_INFO);
|
||||||
|
@ -700,7 +700,7 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
painter.fillRect(plotRect, BLACK);
|
painter.fillRect(plotRect, BLACK);
|
||||||
|
|
||||||
//init graph variables
|
//init graph variables
|
||||||
setMaxAndStart(g_GraphBuffer, GraphTraceLen, plotRect);
|
setMaxAndStart(g_GraphBuffer, g_GraphTraceLen, plotRect);
|
||||||
|
|
||||||
// center line
|
// center line
|
||||||
int zeroHeight = plotRect.top() + (plotRect.bottom() - plotRect.top()) / 2;
|
int zeroHeight = plotRect.top() + (plotRect.bottom() - plotRect.top()) / 2;
|
||||||
|
@ -710,14 +710,14 @@ void Plot::paintEvent(QPaintEvent *event) {
|
||||||
plotGridLines(&painter, plotRect);
|
plotGridLines(&painter, plotRect);
|
||||||
|
|
||||||
//Start painting graph
|
//Start painting graph
|
||||||
PlotGraph(g_GraphBuffer, GraphTraceLen, plotRect, infoRect, &painter, 0);
|
PlotGraph(g_GraphBuffer, g_GraphTraceLen, plotRect, infoRect, &painter, 0);
|
||||||
if (g_DemodBufferLen > 8) {
|
if (g_DemodBufferLen > 8) {
|
||||||
PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx);
|
PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx);
|
||||||
}
|
}
|
||||||
if (g_useOverlays) {
|
if (g_useOverlays) {
|
||||||
//init graph variables
|
//init graph variables
|
||||||
setMaxAndStart(s_Buff, GraphTraceLen, plotRect);
|
setMaxAndStart(s_Buff, g_GraphTraceLen, plotRect);
|
||||||
PlotGraph(s_Buff, GraphTraceLen, plotRect, infoRect, &painter, 1);
|
PlotGraph(s_Buff, g_GraphTraceLen, plotRect, infoRect, &painter, 1);
|
||||||
}
|
}
|
||||||
// End graph drawing
|
// End graph drawing
|
||||||
|
|
||||||
|
@ -816,7 +816,7 @@ void Plot::Zoom(double factor, uint32_t refX) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Plot::Move(int offset) {
|
void Plot::Move(int offset) {
|
||||||
if (GraphTraceLen == 0) return;
|
if (g_GraphTraceLen == 0) return;
|
||||||
if (offset > 0) { // Move right
|
if (offset > 0) { // Move right
|
||||||
if (g_GraphPixelsPerPoint < 20) {
|
if (g_GraphPixelsPerPoint < 20) {
|
||||||
g_GraphStart += offset;
|
g_GraphStart += offset;
|
||||||
|
@ -869,7 +869,7 @@ void Plot::Trim(void) {
|
||||||
g_DemodStartIdx -= lref;
|
g_DemodStartIdx -= lref;
|
||||||
for (uint32_t i = lref; i < rref; ++i)
|
for (uint32_t i = lref; i < rref; ++i)
|
||||||
g_GraphBuffer[i - lref] = g_GraphBuffer[i];
|
g_GraphBuffer[i - lref] = g_GraphBuffer[i];
|
||||||
GraphTraceLen = rref - lref;
|
g_GraphTraceLen = rref - lref;
|
||||||
g_GraphStart = 0;
|
g_GraphStart = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
//-----------------------------------------------------------------------------
|
//-----------------------------------------------------------------------------
|
||||||
#include "parity.h"
|
#include "parity.h"
|
||||||
|
|
||||||
const uint8_t OddByteParity[256] = {
|
const uint8_t g_OddByteParity[256] = {
|
||||||
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
1, 0, 0, 1, 0, 1, 1, 0, 0, 1, 1, 0, 1, 0, 0, 1,
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
0, 1, 1, 0, 1, 0, 0, 1, 1, 0, 0, 1, 0, 1, 1, 0,
|
||||||
|
|
|
@ -13,14 +13,14 @@
|
||||||
|
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
extern const uint8_t OddByteParity[256];
|
extern const uint8_t g_OddByteParity[256];
|
||||||
|
|
||||||
static inline uint8_t oddparity8(const uint8_t x) {
|
static inline uint8_t oddparity8(const uint8_t x) {
|
||||||
return OddByteParity[x];
|
return g_OddByteParity[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t evenparity8(const uint8_t x) {
|
static inline uint8_t evenparity8(const uint8_t x) {
|
||||||
return !OddByteParity[x];
|
return !g_OddByteParity[x];
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint8_t evenparity16(uint16_t x) {
|
static inline uint8_t evenparity16(uint16_t x) {
|
||||||
|
|
|
@ -199,7 +199,7 @@ typedef struct {
|
||||||
bool hw_available_smartcard : 1;
|
bool hw_available_smartcard : 1;
|
||||||
} PACKED capabilities_t;
|
} PACKED capabilities_t;
|
||||||
#define CAPABILITIES_VERSION 5
|
#define CAPABILITIES_VERSION 5
|
||||||
extern capabilities_t pm3_capabilities;
|
extern capabilities_t g_pm3_capabilities;
|
||||||
|
|
||||||
// For CMD_LF_T55XX_WRITEBL
|
// For CMD_LF_T55XX_WRITEBL
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue