From f1f2389fb401b73d7b0aa6458383c4de360ced9d Mon Sep 17 00:00:00 2001 From: Philippe Teuwen Date: Sat, 21 Aug 2021 17:39:17 +0200 Subject: [PATCH] rename globals GraphBuffer --- client/src/cmdanalyse.c | 6 ++-- client/src/cmddata.c | 62 ++++++++++++++++++++-------------------- client/src/cmdhf.c | 2 +- client/src/cmdhf15.c | 8 +++--- client/src/cmdlf.c | 24 ++++++++-------- client/src/cmdlfcotag.c | 2 +- client/src/cmdlfem410x.c | 2 +- client/src/cmdlfem4x05.c | 6 ++-- client/src/cmdlfguard.c | 2 +- client/src/cmdlfindala.c | 12 ++++---- client/src/cmdlft55xx.c | 4 +-- client/src/cmdlfti.c | 32 ++++++++++----------- client/src/graph.c | 34 +++++++++++----------- client/src/graph.h | 2 +- client/src/proxguiqt.cpp | 16 +++++------ 15 files changed, 107 insertions(+), 107 deletions(-) diff --git a/client/src/cmdanalyse.c b/client/src/cmdanalyse.c index 93c6c36b2..7d09c2820 100644 --- a/client/src/cmdanalyse.c +++ b/client/src/cmdanalyse.c @@ -1049,7 +1049,7 @@ static int CmdAnalyseFoo(const char *Cmd) { if (i & 0x0E00) o |= 0x20; // corr_i_accum[12] | corr_i_accum[11] | corr_i_accum[9], o |= (i & 0x1F0) >> 4; // corr_i_accum[8:4] - GraphBuffer[i] = o; + g_GraphBuffer[i] = o; } for (int i = 0; i < 4095; i++) { @@ -1066,12 +1066,12 @@ static int CmdAnalyseFoo(const char *Cmd) { o |= 0x7f; // corr_i_out <= 8'b01111111; } } - GraphBuffer[i + 5000] = o; + g_GraphBuffer[i + 5000] = o; } for (int i = 0; i < 4095; i++) { int o = i >> 5; - GraphBuffer[i + 10000] = o; + g_GraphBuffer[i + 10000] = o; } RepaintGraphWindow(); diff --git a/client/src/cmddata.c b/client/src/cmddata.c index d2514cff4..4f5a87276 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -329,7 +329,7 @@ int CmdGetBitStream(const char *Cmd) { CmdHpf(""); for (uint32_t i = 0; i < GraphTraceLen; i++) { - GraphBuffer[i] = (GraphBuffer[i] >= 1) ? 1 : 0; + g_GraphBuffer[i] = (g_GraphBuffer[i] >= 1) ? 1 : 0; } RepaintGraphWindow(); return PM3_SUCCESS; @@ -667,9 +667,9 @@ static int CmdBiphaseDecodeRaw(const char *Cmd) { return PM3_SUCCESS; } -// ASK Demod then Biphase decode GraphBuffer samples +// ASK Demod then Biphase decode g_GraphBuffer samples int ASKbiphaseDemod(int offset, int clk, int invert, int maxErr, bool verbose) { - //ask raw demod GraphBuffer first + //ask raw demod g_GraphBuffer first uint8_t bs[MAX_DEMOD_BUF_LEN]; size_t size = getFromGraphBuf(bs); @@ -892,7 +892,7 @@ static int CmdAutoCorr(const char *Cmd) { return PM3_EINVARG; } - AutoCorrelate(GraphBuffer, GraphBuffer, GraphTraceLen, window, updateGrph, true); + AutoCorrelate(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, window, updateGrph, true); return PM3_SUCCESS; } @@ -921,9 +921,9 @@ static int CmdBitsamples(const char *Cmd) { for (size_t j = 0; j < ARRAYLEN(got); j++) { for (uint8_t k = 0; k < 8; k++) { if (got[j] & (1 << (7 - k))) - GraphBuffer[cnt++] = 1; + g_GraphBuffer[cnt++] = 1; else - GraphBuffer[cnt++] = 0; + g_GraphBuffer[cnt++] = 0; } } GraphTraceLen = cnt; @@ -969,7 +969,7 @@ static int CmdDecimate(const char *Cmd) { CLIParserFree(ctx); for (size_t i = 0; i < (GraphTraceLen / n); ++i) - GraphBuffer[i] = GraphBuffer[i * n]; + g_GraphBuffer[i] = g_GraphBuffer[i * n]; GraphTraceLen /= n; PrintAndLogEx(SUCCESS, "decimated by " _GREEN_("%u"), n); @@ -1007,15 +1007,15 @@ static int CmdUndecimate(const char *Cmd) { int count = 0; for (count = 0; count < factor && s_index + count < MAX_GRAPH_TRACE_LEN; count++) { swap[s_index + count] = ( - (double)(factor - count) / (factor - 1)) * GraphBuffer[g_index] + - ((double)count / factor) * GraphBuffer[g_index + 1] + (double)(factor - count) / (factor - 1)) * g_GraphBuffer[g_index] + + ((double)count / factor) * g_GraphBuffer[g_index + 1] ; } s_index += count; g_index++; } - memcpy(GraphBuffer, swap, s_index * sizeof(int)); + memcpy(g_GraphBuffer, swap, s_index * sizeof(int)); GraphTraceLen = s_index; RepaintGraphWindow(); return PM3_SUCCESS; @@ -1040,13 +1040,13 @@ static int CmdGraphShiftZero(const char *Cmd) { CLIParserFree(ctx); for (size_t i = 0; i < GraphTraceLen; i++) { - int shiftedVal = GraphBuffer[i] + shift; + int shiftedVal = g_GraphBuffer[i] + shift; if (shiftedVal > 127) shiftedVal = 127; else if (shiftedVal < -127) shiftedVal = -127; - GraphBuffer[i] = shiftedVal; + g_GraphBuffer[i] = shiftedVal; } CmdNorm(""); return PM3_SUCCESS; @@ -1085,7 +1085,7 @@ static int CmdAskEdgeDetect(const char *Cmd) { CLIParserFree(ctx); PrintAndLogEx(INFO, "using threshold " _YELLOW_("%i"), threshold); - int res = AskEdgeDetect(GraphBuffer, GraphBuffer, GraphTraceLen, threshold); + int res = AskEdgeDetect(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, threshold); RepaintGraphWindow(); return res; } @@ -1684,7 +1684,7 @@ static int CmdHide(const char *Cmd) { return PM3_SUCCESS; } -// zero mean GraphBuffer +// zero mean g_GraphBuffer int CmdHpf(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "data hpf", @@ -1775,7 +1775,7 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose) { uint32_t j = 0; for (j = 0; j * bits_per_sample < n * 8 && j < n; j++) { uint8_t sample = getByte(bits_per_sample, &bout); - GraphBuffer[j] = ((int) sample) - 127; + g_GraphBuffer[j] = ((int) sample) - 127; } GraphTraceLen = j; @@ -1783,7 +1783,7 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose) { } else { for (uint32_t j = 0; j < n; j++) { - GraphBuffer[j] = ((int)got[j]) - 127; + g_GraphBuffer[j] = ((int)got[j]) - 127; } GraphTraceLen = n; } @@ -1995,7 +1995,7 @@ int CmdTuneSamples(const char *Cmd) { // even here, these values has 3% error. uint16_t test1 = 0; for (int i = 0; i < 256; i++) { - GraphBuffer[i] = package->results[i] - 128; + g_GraphBuffer[i] = package->results[i] - 128; test1 += package->results[i]; } @@ -2053,7 +2053,7 @@ static int CmdLoad(const char *Cmd) { GraphTraceLen = 0; char line[80]; while (fgets(line, sizeof(line), f)) { - GraphBuffer[GraphTraceLen] = atoi(line); + g_GraphBuffer[GraphTraceLen] = atoi(line); GraphTraceLen++; if (GraphTraceLen >= MAX_GRAPH_TRACE_LEN) @@ -2099,7 +2099,7 @@ int CmdLtrim(const char *Cmd) { } for (uint32_t i = ds; i < GraphTraceLen; ++i) - GraphBuffer[i - ds] = GraphBuffer[i]; + g_GraphBuffer[i - ds] = g_GraphBuffer[i]; GraphTraceLen -= ds; g_DemodStartIdx -= ds; @@ -2164,7 +2164,7 @@ static int CmdMtrim(const char *Cmd) { GraphTraceLen = stop - start; for (uint32_t i = 0; i < GraphTraceLen; i++) { - GraphBuffer[i] = GraphBuffer[start + i]; + g_GraphBuffer[i] = g_GraphBuffer[start + i]; } return PM3_SUCCESS; @@ -2188,13 +2188,13 @@ int CmdNorm(const char *Cmd) { // Find local min, max for (uint32_t i = 10; i < GraphTraceLen; ++i) { - if (GraphBuffer[i] > max) max = GraphBuffer[i]; - if (GraphBuffer[i] < min) min = GraphBuffer[i]; + if (g_GraphBuffer[i] > max) max = g_GraphBuffer[i]; + if (g_GraphBuffer[i] < min) min = g_GraphBuffer[i]; } if (max != min) { for (uint32_t i = 0; i < GraphTraceLen; ++i) { - GraphBuffer[i] = ((long)(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 } } @@ -2254,9 +2254,9 @@ int CmdSave(const char *Cmd) { CLIParserFree(ctx); if (as_wave) - return saveFileWAVE(filename, GraphBuffer, GraphTraceLen); + return saveFileWAVE(filename, g_GraphBuffer, GraphTraceLen); else - return saveFilePM3(filename, GraphBuffer, GraphTraceLen); + return saveFilePM3(filename, g_GraphBuffer, GraphTraceLen); } static int CmdTimeScale(const char *Cmd) { @@ -2338,7 +2338,7 @@ static int CmdDirectionalThreshold(const char *Cmd) { PrintAndLogEx(INFO, "Applying up threshold: " _YELLOW_("%i") ", down threshold: " _YELLOW_("%i") "\n", up, down); - directionalThreshold(GraphBuffer, GraphBuffer, GraphTraceLen, up, down); + directionalThreshold(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, up, down); // set signal properties low/high/mean/amplitude and isnoice detection uint8_t bits[GraphTraceLen]; @@ -2369,14 +2369,14 @@ static int CmdZerocrossings(const char *Cmd) { int sign = 1, zc = 0, lastZc = 0; for (uint32_t i = 0; i < GraphTraceLen; ++i) { - if (GraphBuffer[i] * sign >= 0) { + if (g_GraphBuffer[i] * sign >= 0) { // No change in sign, reproduce the previous sample count. zc++; - GraphBuffer[i] = lastZc; + g_GraphBuffer[i] = lastZc; } else { // Change in sign, reset the sample count. sign = -sign; - GraphBuffer[i] = lastZc; + g_GraphBuffer[i] = lastZc; if (sign > 0) { lastZc = zc; zc = 0; @@ -2664,7 +2664,7 @@ static int CmdFSKToNRZ(const char *Cmd) { setClockGrid(0, 0); g_DemodBufferLen = 0; - int ans = FSKToNRZ(GraphBuffer, &GraphTraceLen, clk, fc_low, fc_high); + int ans = FSKToNRZ(g_GraphBuffer, &GraphTraceLen, clk, fc_low, fc_high); CmdNorm(""); RepaintGraphWindow(); return ans; @@ -2686,7 +2686,7 @@ static int CmdDataIIR(const char *Cmd) { uint8_t k = (arg_get_u32_def(ctx, 1, 0) & 0xFF); CLIParserFree(ctx); - iceSimple_Filter(GraphBuffer, GraphTraceLen, k); + iceSimple_Filter(g_GraphBuffer, GraphTraceLen, k); uint8_t bits[GraphTraceLen]; size_t size = getFromGraphBuf(bits); diff --git a/client/src/cmdhf.c b/client/src/cmdhf.c index 74481eda2..ac1228404 100644 --- a/client/src/cmdhf.c +++ b/client/src/cmdhf.c @@ -365,7 +365,7 @@ int handle_hf_plot(void) { } for (size_t i = 0; i < FPGA_TRACE_SIZE; i++) { - GraphBuffer[i] = ((int)buf[i]) - 128; + g_GraphBuffer[i] = ((int)buf[i]) - 128; } GraphTraceLen = FPGA_TRACE_SIZE; diff --git a/client/src/cmdhf15.c b/client/src/cmdhf15.c index f53649a30..823439095 100644 --- a/client/src/cmdhf15.c +++ b/client/src/cmdhf15.c @@ -520,7 +520,7 @@ static int CmdHF15Demod(const char *Cmd) { for (i = 0; i < 1000; i++) { int corr = 0; for (j = 0; j < ARRAYLEN(FrameSOF); j += skip) { - corr += FrameSOF[j] * GraphBuffer[i + (j / skip)]; + corr += FrameSOF[j] * g_GraphBuffer[i + (j / skip)]; } if (corr > max) { max = corr; @@ -538,13 +538,13 @@ static int CmdHF15Demod(const char *Cmd) { for (;;) { int corr0 = 0, corr1 = 0, corrEOF = 0; for (j = 0; j < ARRAYLEN(Logic0); j += skip) { - corr0 += Logic0[j] * GraphBuffer[i + (j / skip)]; + corr0 += Logic0[j] * g_GraphBuffer[i + (j / skip)]; } for (j = 0; j < ARRAYLEN(Logic1); j += skip) { - corr1 += Logic1[j] * GraphBuffer[i + (j / skip)]; + corr1 += Logic1[j] * g_GraphBuffer[i + (j / skip)]; } for (j = 0; j < ARRAYLEN(FrameEOF); j += skip) { - corrEOF += FrameEOF[j] * GraphBuffer[i + (j / skip)]; + corrEOF += FrameEOF[j] * g_GraphBuffer[i + (j / skip)]; } // Even things out by the length of the target waveform. corr0 *= 4; diff --git a/client/src/cmdlf.c b/client/src/cmdlf.c index c0ceffbe9..c5e080ac1 100644 --- a/client/src/cmdlf.c +++ b/client/src/cmdlf.c @@ -368,7 +368,7 @@ int CmdFlexdemod(const char *Cmd) { int i, j, start, bit, sum; int data[GraphTraceLen]; - memcpy(data, GraphBuffer, GraphTraceLen); + memcpy(data, g_GraphBuffer, GraphTraceLen); size_t size = GraphTraceLen; @@ -426,7 +426,7 @@ int CmdFlexdemod(const char *Cmd) { int phase = (bits[bit] == 0) ? 0 : 1; for (j = 0; j < 32; j++) { - GraphBuffer[i++] = phase; + g_GraphBuffer[i++] = phase; phase = !phase; } } @@ -766,7 +766,7 @@ int CmdLFSniff(const char *Cmd) { static void lf_chk_bitstream(void) { // convert to bitstream if necessary for (int i = 0; i < (int)(GraphTraceLen / 2); i++) { - if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) { + if (g_GraphBuffer[i] > 1 || g_GraphBuffer[i] < 0) { CmdGetBitStream(""); PrintAndLogEx(INFO, "converted Graphbuffer to bitstream values (0|1)"); break; @@ -774,7 +774,7 @@ static void lf_chk_bitstream(void) { } } -// Uploads 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) { PrintAndLogEx(DEBUG, "DEBUG: Uploading %zu bytes", GraphTraceLen); @@ -803,7 +803,7 @@ int lfsim_upload_gb(void) { payload_up.offset = i; for (uint16_t j = 0; j < len; j++) - payload_up.data[j] = GraphBuffer[i + j]; + payload_up.data[j] = g_GraphBuffer[i + j]; SendCommandNG(CMD_LF_UPLOAD_SIM_SAMPLES, (uint8_t *)&payload_up, sizeof(struct pupload)); WaitForResponse(CMD_LF_UPLOAD_SIM_SAMPLES, &resp); @@ -823,7 +823,7 @@ int lfsim_upload_gb(void) { } //Attempt to simulate any wave in buffer (one bit per output sample) -// converts GraphBuffer to bitstream (based on zero crossings) if needed. +// converts g_GraphBuffer to bitstream (based on zero crossings) if needed. int CmdLFSim(const char *Cmd) { CLIParserContext *ctx; CLIParserInit(&ctx, "lf sim", @@ -1276,7 +1276,7 @@ int CmdVchDemod(const char *Cmd) { for (i = 0; i < (GraphTraceLen - 2048); i++) { for (j = 0; j < ARRAYLEN(SyncPattern); j++) { - sum += GraphBuffer[i + j] * SyncPattern[j]; + sum += g_GraphBuffer[i + j] * SyncPattern[j]; } if (sum > bestCorrel) { bestCorrel = sum; @@ -1293,7 +1293,7 @@ int CmdVchDemod(const char *Cmd) { for (i = 0; i < 2048; i += 8) { sum = 0; for (j = 0; j < 8; j++) - sum += GraphBuffer[bestPos + i + j]; + sum += g_GraphBuffer[bestPos + i + j]; if (sum < 0) bits[i / 8] = '.'; @@ -1315,7 +1315,7 @@ int CmdVchDemod(const char *Cmd) { char *s; for (s = bits; *s; s++) { for (j = 0; j < 16; j++) { - GraphBuffer[GraphTraceLen++] = (*s == '1') ? 1 : 0; + g_GraphBuffer[GraphTraceLen++] = (*s == '1') ? 1 : 0; } } RepaintGraphWindow(); @@ -1379,9 +1379,9 @@ int CmdLFfind(const char *Cmd) { CLIParserInit(&ctx, "lf search", "Read and search for valid known tag. For offline mode, you can `data load` first then search.", "lf search -> try reading data from tag & search for known tag\n" - "lf search -1 -> use data from GraphBuffer & search for known tag\n" + "lf search -1 -> use data from the GraphBuffer & search for known tag\n" "lf search -u -> try reading data from tag & search for known and unknown tag\n" - "lf search -1u -> use data from GraphBuffer & search for known and unknown tag\n" + "lf search -1u -> use data from the GraphBuffer & search for known and unknown tag\n" ); void *argtable[] = { @@ -1690,7 +1690,7 @@ int CmdLFfind(const char *Cmd) { if (search_unk) { //test unknown tag formats (raw mode) PrintAndLogEx(INFO, "\nChecking for unknown tags:\n"); - int ans = AutoCorrelate(GraphBuffer, GraphBuffer, GraphTraceLen, 8000, false, false); + int ans = AutoCorrelate(g_GraphBuffer, g_GraphBuffer, GraphTraceLen, 8000, false, false); if (ans > 0) { PrintAndLogEx(INFO, "Possible auto correlation of %d repeating samples", ans); diff --git a/client/src/cmdlfcotag.c b/client/src/cmdlfcotag.c index ce38cf293..ab964e450 100644 --- a/client/src/cmdlfcotag.c +++ b/client/src/cmdlfcotag.c @@ -20,7 +20,7 @@ static int CmdHelp(const char *Cmd); -// COTAG demod should be able to use GraphBuffer, +// COTAG demod should be able to use g_GraphBuffer, // when data load samples int demodCOTAG(bool verbose) { (void) verbose; // unused so far diff --git a/client/src/cmdlfem410x.c b/client/src/cmdlfem410x.c index 9e607db3b..36e5f813b 100644 --- a/client/src/cmdlfem410x.c +++ b/client/src/cmdlfem410x.c @@ -263,7 +263,7 @@ int AskEm410xDecode(bool verbose, uint32_t *hi, uint64_t *lo) { return PM3_ESOFT; } - //set GraphBuffer for clone or sim command + //set g_GraphBuffer for clone or sim command setDemodBuff(g_DemodBuffer, (size == 40) ? 64 : 128, idx + 1); setClockGrid(g_DemodClock, g_DemodStartIdx + ((idx + 1)*g_DemodClock)); diff --git a/client/src/cmdlfem4x05.c b/client/src/cmdlfem4x05.c index 04d4e1d40..94c7c4d1f 100644 --- a/client/src/cmdlfem4x05.c +++ b/client/src/cmdlfem4x05.c @@ -2026,13 +2026,13 @@ int CmdEM4x05Sniff(const char *Cmd) { haveData = false; pwd = false; - idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, GraphBuffer, &pulseSamples); + idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, g_GraphBuffer, &pulseSamples); pktOffset = idx; 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 ZeroWidth = idx; - idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, GraphBuffer, &pulseSamples); + idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, g_GraphBuffer, &pulseSamples); ZeroWidth = idx - ZeroWidth; if (ZeroWidth <= 50) { @@ -2042,7 +2042,7 @@ int CmdEM4x05Sniff(const char *Cmd) { while ((idx < GraphTraceLen) && !eop) { CycleWidth = idx; - idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, GraphBuffer, &pulseSamples); + idx = em4x05_Sniff_GetNextBitStart(idx, GraphTraceLen, g_GraphBuffer, &pulseSamples); CycleWidth = idx - CycleWidth; if ((CycleWidth > 300) || (CycleWidth < (ZeroWidth - 5))) { // to long or too short diff --git a/client/src/cmdlfguard.c b/client/src/cmdlfguard.c index 10b03b8e0..f40d333f3 100644 --- a/client/src/cmdlfguard.c +++ b/client/src/cmdlfguard.c @@ -29,7 +29,7 @@ static int CmdHelp(const char *Cmd); // attempts to demodulate and identify a G_Prox_II verex/chubb card // WARNING: if it fails during some points it will destroy the g_DemodBuffer data -// but will leave the GraphBuffer intact. +// but will leave the g_GraphBuffer intact. // if successful it will push askraw data back to g_DemodBuffer ready for emulation int demodGuard(bool verbose) { (void) verbose; // unused so far diff --git a/client/src/cmdlfindala.c b/client/src/cmdlfindala.c index 9c0afa71c..3ad10d8d9 100644 --- a/client/src/cmdlfindala.c +++ b/client/src/cmdlfindala.c @@ -253,9 +253,9 @@ static int CmdIndalaDemod(const char *Cmd) { CLIParserInit(&ctx, "lf indala demod", "Tries to PSK demodulate the graphbuffer as Indala", "lf indala demod\n" - "lf indala demod --clock 32 -> demod a Indala tag from GraphBuffer using a clock of RF/32\n" - "lf indala demod --clock 32 -i -> demod a Indala tag from GraphBuffer using a clock of RF/32 and inverting data\n" - "lf indala demod --clock 64 -i --maxerror 0 -> demod a Indala tag from GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors" + "lf indala demod --clock 32 -> demod a Indala tag from the GraphBuffer using a clock of RF/32\n" + "lf indala demod --clock 32 -i -> demod a Indala tag from the GraphBuffer using a clock of RF/32 and inverting data\n" + "lf indala demod --clock 64 -i --maxerror 0 -> demod a Indala tag from the GraphBuffer using a clock of RF/64, inverting data and allowing 0 demod errors" ); void *argtable[] = { @@ -286,7 +286,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) { "This is uses a alternative way to demodulate and was used from the beginning in the Pm3 client.\n" "It's now considered obsolete but remains because it has sometimes its advantages.", "lf indala altdemod\n" - "lf indala altdemod --long -> demod a Indala tag from GraphBuffer as 224 bit long format" + "lf indala altdemod --long -> demod a Indala tag from the GraphBuffer as 224 bit long format" ); void *argtable[] = { @@ -486,7 +486,7 @@ static int CmdIndalaDemodAlt(const char *Cmd) { phase = 1; } for (j = 0; j < 32; j++) { - GraphBuffer[i++] = phase; + g_GraphBuffer[i++] = phase; phase = !phase; } } @@ -797,7 +797,7 @@ static int CmdIndalaClone(const char *Cmd) { static command_t CommandTable[] = { {"help", CmdHelp, AlwaysAvailable, "This help"}, - {"demod", CmdIndalaDemod, AlwaysAvailable, "Demodulate an Indala tag (PSK1) from GraphBuffer"}, + {"demod", CmdIndalaDemod, AlwaysAvailable, "Demodulate an Indala tag (PSK1) from the GraphBuffer"}, {"altdemod", CmdIndalaDemodAlt, AlwaysAvailable, "Alternative method to demodulate samples for Indala 64 bit UID (option '224' for 224 bit)"}, {"reader", CmdIndalaReader, IfPm3Lf, "Read an Indala tag from the antenna"}, {"clone", CmdIndalaClone, IfPm3Lf, "Clone Indala tag to T55x7 or Q5/T5555"}, diff --git a/client/src/cmdlft55xx.c b/client/src/cmdlft55xx.c index db4ec0122..02fb9073f 100644 --- a/client/src/cmdlft55xx.c +++ b/client/src/cmdlft55xx.c @@ -4059,13 +4059,13 @@ static int CmdT55xxSniff(const char *Cmd) { } // find high - while ((idx < GraphTraceLen) && (GraphBuffer[idx] < 0)) { + while ((idx < GraphTraceLen) && (g_GraphBuffer[idx] < 0)) { idx++; } // count high samples pulseSamples = 0; - while ((idx < GraphTraceLen) && (GraphBuffer[idx] > 0)) { // last bit seems to be high to zero, but can vary in width.. + while ((idx < GraphTraceLen) && (g_GraphBuffer[idx] > 0)) { // last bit seems to be high to zero, but can vary in width.. pulseSamples++; idx++; } diff --git a/client/src/cmdlfti.c b/client/src/cmdlfti.c index 3e8138332..78363c964 100644 --- a/client/src/cmdlfti.c +++ b/client/src/cmdlfti.c @@ -95,17 +95,17 @@ int demodTI(bool verbose) { highSum = 0; for (j = 0; j < lowLen; j++) { - lowSum += LowTone[j] * GraphBuffer[i + j]; + lowSum += LowTone[j] * g_GraphBuffer[i + j]; } for (j = 0; j < highLen; j++) { - highSum += HighTone[j] * GraphBuffer[i + j]; + highSum += HighTone[j] * g_GraphBuffer[i + j]; } lowSum = abs((100 * lowSum) / lowLen); highSum = abs((100 * highSum) / highLen); lowSum = (lowSum < 0) ? -lowSum : lowSum; highSum = (highSum < 0) ? -highSum : highSum; - GraphBuffer[i] = (highSum << 16) | lowSum; + g_GraphBuffer[i] = (highSum << 16) | lowSum; } for (i = 0; i < GraphTraceLen - convLen - 16; i++) { @@ -113,12 +113,12 @@ int demodTI(bool verbose) { highTot = 0; // 16 and 15 are f_s divided by f_l and f_h, rounded for (j = 0; j < 16; j++) { - lowTot += (GraphBuffer[i + j] & 0xffff); + lowTot += (g_GraphBuffer[i + j] & 0xffff); } for (j = 0; j < 15; j++) { - highTot += (GraphBuffer[i + j] >> 16); + highTot += (g_GraphBuffer[i + j] >> 16); } - GraphBuffer[i] = lowTot - highTot; + g_GraphBuffer[i] = lowTot - highTot; } GraphTraceLen -= (convLen + 16); @@ -143,11 +143,11 @@ int demodTI(bool verbose) { int dec = 0; // searching 17 consecutive lows for (j = 0; j < 17 * lowLen; j++) { - dec -= GraphBuffer[i + j]; + dec -= g_GraphBuffer[i + j]; } // searching 7 consecutive highs for (; j < 17 * lowLen + 6 * highLen; j++) { - dec += GraphBuffer[i + j]; + dec += g_GraphBuffer[i + j]; } if (dec > max) { max = dec; @@ -157,8 +157,8 @@ int demodTI(bool verbose) { // place a marker in the buffer to visually aid location // of the start of sync - GraphBuffer[maxPos] = 800; - GraphBuffer[maxPos + 1] = -800; + g_GraphBuffer[maxPos] = 800; + g_GraphBuffer[maxPos + 1] = -800; // advance pointer to start of actual data stream (after 16 pre and 8 start bits) maxPos += 17 * lowLen; @@ -166,8 +166,8 @@ int demodTI(bool verbose) { // place a marker in the buffer to visually aid location // of the end of sync - GraphBuffer[maxPos] = 800; - GraphBuffer[maxPos + 1] = -800; + g_GraphBuffer[maxPos] = 800; + g_GraphBuffer[maxPos + 1] = -800; PrintAndLogEx(DEBUG, "actual data bits start at sample %d", maxPos); PrintAndLogEx(DEBUG, "length %d/%d", highLen, lowLen); @@ -180,10 +180,10 @@ int demodTI(bool verbose) { for (i = 0; i < ARRAYLEN(bits) - 1; i++) { int high = 0, low = 0; for (j = 0; j < lowLen; j++) { - low -= GraphBuffer[maxPos + j]; + low -= g_GraphBuffer[maxPos + j]; } for (j = 0; j < highLen; j++) { - high += GraphBuffer[maxPos + j]; + high += g_GraphBuffer[maxPos + j]; } if (high > low) { @@ -203,8 +203,8 @@ int demodTI(bool verbose) { shift3 >>= 1; // place a marker in the buffer between bits to visually aid location - GraphBuffer[maxPos] = 800; - GraphBuffer[maxPos + 1] = -800; + g_GraphBuffer[maxPos] = 800; + g_GraphBuffer[maxPos + 1] = -800; } RepaintGraphWindow(); diff --git a/client/src/graph.c b/client/src/graph.c index c42b0d193..e603a2b8e 100644 --- a/client/src/graph.c +++ b/client/src/graph.c @@ -17,7 +17,7 @@ #include "cmddata.h" //for g_debugmode -int GraphBuffer[MAX_GRAPH_TRACE_LEN]; +int g_GraphBuffer[MAX_GRAPH_TRACE_LEN]; size_t GraphTraceLen; /* write a manchester bit to the graph @@ -28,11 +28,11 @@ void AppendGraph(bool redraw, uint16_t clock, int bit) { uint8_t i; //set first half the clock bit (all 1's or 0's for a 0 or 1 bit) for (i = 0; i < half; ++i) - GraphBuffer[GraphTraceLen++] = bit; + g_GraphBuffer[GraphTraceLen++] = bit; //set second half of the clock bit (all 0's or 1's for a 0 or 1 bit) for (; i < clock; ++i) - GraphBuffer[GraphTraceLen++] = bit ^ 1; + g_GraphBuffer[GraphTraceLen++] = bit ^ 1; if (redraw) RepaintGraphWindow(); @@ -41,7 +41,7 @@ void AppendGraph(bool redraw, uint16_t clock, int bit) { // clear out our graph window size_t ClearGraph(bool redraw) { size_t gtl = GraphTraceLen; - memset(GraphBuffer, 0x00, GraphTraceLen); + memset(g_GraphBuffer, 0x00, GraphTraceLen); GraphTraceLen = 0; g_GraphStart = 0; g_GraphStop = 0; @@ -52,7 +52,7 @@ size_t ClearGraph(bool redraw) { return gtl; } -// option '1' to save GraphBuffer any other to restore +// option '1' to save g_GraphBuffer any other to restore void save_restoreGB(uint8_t saveOpt) { static int SavedGB[MAX_GRAPH_TRACE_LEN]; static size_t SavedGBlen = 0; @@ -60,12 +60,12 @@ void save_restoreGB(uint8_t saveOpt) { static int Savedg_GridOffsetAdj = 0; if (saveOpt == GRAPH_SAVE) { //save - memcpy(SavedGB, GraphBuffer, sizeof(GraphBuffer)); + memcpy(SavedGB, g_GraphBuffer, sizeof(g_GraphBuffer)); SavedGBlen = GraphTraceLen; GB_Saved = true; Savedg_GridOffsetAdj = g_GridOffset; } else if (GB_Saved) { //restore - memcpy(GraphBuffer, SavedGB, sizeof(GraphBuffer)); + memcpy(g_GraphBuffer, SavedGB, sizeof(g_GraphBuffer)); GraphTraceLen = SavedGBlen; g_GridOffset = Savedg_GridOffsetAdj; RepaintGraphWindow(); @@ -81,7 +81,7 @@ void setGraphBuf(uint8_t *buff, size_t size) { size = MAX_GRAPH_TRACE_LEN; for (size_t i = 0; i < size; ++i) - GraphBuffer[i] = buff[i] - 128; + g_GraphBuffer[i] = buff[i] - 128; GraphTraceLen = size; RepaintGraphWindow(); @@ -94,9 +94,9 @@ size_t getFromGraphBuf(uint8_t *buff) { size_t i; for (i = 0; i < GraphTraceLen; ++i) { //trim - if (GraphBuffer[i] > 127) GraphBuffer[i] = 127; - if (GraphBuffer[i] < -127) GraphBuffer[i] = -127; - buff[i] = (uint8_t)(GraphBuffer[i] + 128); + if (g_GraphBuffer[i] > 127) g_GraphBuffer[i] = 127; + if (g_GraphBuffer[i] < -127) g_GraphBuffer[i] = -127; + buff[i] = (uint8_t)(g_GraphBuffer[i] + 128); } return i; } @@ -113,7 +113,7 @@ bool HasGraphData(void) { bool isGraphBitstream(void) { // convert to bitstream if necessary for (int i = 0; i < GraphTraceLen; i++) { - if (GraphBuffer[i] > 1 || GraphBuffer[i] < 0) { + if (g_GraphBuffer[i] > 1 || g_GraphBuffer[i] < 0) { return false; } } @@ -126,12 +126,12 @@ void convertGraphFromBitstream(void) { void convertGraphFromBitstreamEx(int hi, int low) { for (int i = 0; i < GraphTraceLen; i++) { - if (GraphBuffer[i] == hi) - GraphBuffer[i] = 127; - else if (GraphBuffer[i] == low) - GraphBuffer[i] = -127; + if (g_GraphBuffer[i] == hi) + g_GraphBuffer[i] = 127; + else if (g_GraphBuffer[i] == low) + g_GraphBuffer[i] = -127; else - GraphBuffer[i] = 0; + g_GraphBuffer[i] = 0; } uint8_t *bits = calloc(GraphTraceLen, sizeof(uint8_t)); diff --git a/client/src/graph.h b/client/src/graph.h index fa99b336f..e79c55972 100644 --- a/client/src/graph.h +++ b/client/src/graph.h @@ -38,7 +38,7 @@ bool fskClocks(uint8_t *fc1, uint8_t *fc2, uint8_t *rf1, int *firstClockEdge); #define GRAPH_SAVE 1 #define GRAPH_RESTORE 0 -extern int GraphBuffer[MAX_GRAPH_TRACE_LEN]; +extern int g_GraphBuffer[MAX_GRAPH_TRACE_LEN]; extern size_t GraphTraceLen; #ifdef __cplusplus diff --git a/client/src/proxguiqt.cpp b/client/src/proxguiqt.cpp index f882023f2..f8b3016b8 100644 --- a/client/src/proxguiqt.cpp +++ b/client/src/proxguiqt.cpp @@ -292,7 +292,7 @@ void SliderWidget::moveEvent(QMoveEvent *event) { void ProxWidget::applyOperation() { //printf("ApplyOperation()"); save_restoreGB(GRAPH_SAVE); - memcpy(GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen); + memcpy(g_GraphBuffer, s_Buff, sizeof(int) * GraphTraceLen); RepaintGraphWindow(); } void ProxWidget::stickOperation() { @@ -300,21 +300,21 @@ void ProxWidget::stickOperation() { //printf("stickOperation()"); } void ProxWidget::vchange_autocorr(int v) { - int ans = AutoCorrelate(GraphBuffer, s_Buff, GraphTraceLen, v, true, false); + int ans = AutoCorrelate(g_GraphBuffer, s_Buff, GraphTraceLen, v, true, false); if (g_debugMode) printf("vchange_autocorr(w:%d): %d\n", v, ans); g_useOverlays = true; RepaintGraphWindow(); } void ProxWidget::vchange_askedge(int v) { //extern int AskEdgeDetect(const int *in, int *out, int len, int threshold); - int ans = AskEdgeDetect(GraphBuffer, s_Buff, GraphTraceLen, v); + int ans = AskEdgeDetect(g_GraphBuffer, s_Buff, GraphTraceLen, v); if (g_debugMode) printf("vchange_askedge(w:%d)%d\n", v, ans); g_useOverlays = true; RepaintGraphWindow(); } void ProxWidget::vchange_dthr_up(int v) { int down = opsController->horizontalSlider_dirthr_down->value(); - directionalThreshold(GraphBuffer, s_Buff, GraphTraceLen, v, down); + directionalThreshold(g_GraphBuffer, s_Buff, GraphTraceLen, v, down); //printf("vchange_dthr_up(%d)", v); g_useOverlays = true; RepaintGraphWindow(); @@ -322,7 +322,7 @@ void ProxWidget::vchange_dthr_up(int v) { void ProxWidget::vchange_dthr_down(int v) { //printf("vchange_dthr_down(%d)", v); int up = opsController->horizontalSlider_dirthr_up->value(); - directionalThreshold(GraphBuffer, s_Buff, GraphTraceLen, v, up); + directionalThreshold(g_GraphBuffer, s_Buff, GraphTraceLen, v, up); g_useOverlays = true; RepaintGraphWindow(); } @@ -700,7 +700,7 @@ void Plot::paintEvent(QPaintEvent *event) { painter.fillRect(plotRect, BLACK); //init graph variables - setMaxAndStart(GraphBuffer, GraphTraceLen, plotRect); + setMaxAndStart(g_GraphBuffer, GraphTraceLen, plotRect); // center line int zeroHeight = plotRect.top() + (plotRect.bottom() - plotRect.top()) / 2; @@ -710,7 +710,7 @@ void Plot::paintEvent(QPaintEvent *event) { plotGridLines(&painter, plotRect); //Start painting graph - PlotGraph(GraphBuffer, GraphTraceLen, plotRect, infoRect, &painter, 0); + PlotGraph(g_GraphBuffer, GraphTraceLen, plotRect, infoRect, &painter, 0); if (showDemod && g_DemodBufferLen > 8) { PlotDemod(g_DemodBuffer, g_DemodBufferLen, plotRect, infoRect, &painter, 2, g_DemodStartIdx); } @@ -868,7 +868,7 @@ void Plot::Trim(void) { } g_DemodStartIdx -= lref; for (uint32_t i = lref; i < rref; ++i) - GraphBuffer[i - lref] = GraphBuffer[i]; + g_GraphBuffer[i - lref] = g_GraphBuffer[i]; GraphTraceLen = rref - lref; g_GraphStart = 0; }