From 239a8646b221b33c262fa32c9929f4627414cfaf Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sun, 22 Jan 2023 15:38:09 +0000 Subject: [PATCH 1/3] Fix the wrong sample count when bps!=8 --- armsrc/lfsampling.c | 4 +++- client/src/cmddata.c | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index a1ff37356..3844976e1 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -296,7 +296,9 @@ void LFSetupFPGAForADC(int divisor, bool reader_field) { uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, int16_t trigger_threshold, bool verbose, uint32_t sample_size, uint32_t cancel_after, int32_t samples_to_skip, bool ledcontrol) { - initSampleBuffer(&sample_size); + initSampleBuffer(&sample_size); // sample size in bytes + sample_size <<= 3; // sample size in bits + sample_size /= bits_per_sample; // sample count if (g_dbglevel >= DBG_DEBUG) { printSamples(); diff --git a/client/src/cmddata.c b/client/src/cmddata.c index 647c062a4..1ebd4b432 100644 --- a/client/src/cmddata.c +++ b/client/src/cmddata.c @@ -1779,7 +1779,7 @@ int getSamplesEx(uint32_t start, uint32_t end, bool verbose, bool ignore_lf_conf BitstreamOut_t bout = { got, bits_per_sample * n, 0}; uint32_t j = 0; - for (j = 0; j * bits_per_sample < n * 8 && j < n; j++) { + for (j = 0; j * bits_per_sample < n * 8 && j * bits_per_sample < MAX_GRAPH_TRACE_LEN * 8; j++) { uint8_t sample = getByte(bits_per_sample, &bout); g_GraphBuffer[j] = ((int) sample) - 127; } From f4879fdc172f43bf965a29f2420f7c42030e895c Mon Sep 17 00:00:00 2001 From: wh201906 Date: Sun, 22 Jan 2023 15:41:07 +0000 Subject: [PATCH 2/3] Bypass some functions if bps is not 8 --- armsrc/lfsampling.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/armsrc/lfsampling.c b/armsrc/lfsampling.c index 3844976e1..e716fa248 100644 --- a/armsrc/lfsampling.c +++ b/armsrc/lfsampling.c @@ -370,8 +370,12 @@ uint32_t DoAcquisition(uint8_t decimation, uint8_t bits_per_sample, bool avg, in } // Ensure that DC offset removal and noise check is performed for any device-side processing - removeSignalOffset(data.buffer, samples.total_saved); - computeSignalProperties(data.buffer, samples.total_saved); + if (bits_per_sample == 8) + { + // these functions only consider bps==8 + removeSignalOffset(data.buffer, samples.total_saved); + computeSignalProperties(data.buffer, samples.total_saved); + } return data.numbits; } /** From 8218762e86fa9774bd6d4190f350d0f8bea5c5c3 Mon Sep 17 00:00:00 2001 From: Self Not Found Date: Mon, 23 Jan 2023 00:16:29 +0800 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97fa48f5d..978caa8e6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,7 @@ This project uses the changelog in accordance with [keepchangelog](http://keepac - Fixed `trace list -c` - annotation of CRC bytes now is colored or squared if no ansi colors is supported (@iceman1001) - Fixed `trace list -t mf` - now also finds UID if anticollision is partial captured, to be used for mfkey (@iceman1001) - Fixed `make accessrights` on Fedora (@mooey5775) + - Fixed the lf sampling when bits_per_sample is less than 8 (@wh201906) ## [Radium.4.15864][2022-10-29] - Changed `lf indala sim` - now accepts fc / cn (@iceman1001)