From 28262ca5fbffabc2e9cbbbe2158435298ca0e3f0 Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 21 Jul 2024 14:20:48 +0200 Subject: [PATCH 1/4] More Sonar bug fixes --- ft8/ft8.cpp | 3 ++ ft8/libldpc.cpp | 4 +-- plugins/channelrx/demodadsb/adsbdemodsink.h | 4 +-- .../channelrx/demoddatv/ldpctool/encoder.h | 7 ++++- .../demoddatv/ldpctool/layered_decoder.h | 21 ++++++++++++- .../demoddatv/ldpctool/ldpc_tool.cpp | 30 ++++++++++++------- .../radioastronomy/radioastronomy.cpp | 10 +++---- .../mod802.15.4/ieee_802_15_4_macframe.h | 3 ++ scriptsapi/superscanner.py | 4 +-- sdrbase/dsp/sigmffilerecord.cpp | 4 +-- sdrbase/dsp/wfir.cpp | 6 ++++ wdsp/cfcomp.cpp | 1 - wdsp/emnr.cpp | 2 +- wdsp/fir.cpp | 10 +++++++ wdsp/resample.cpp | 4 +-- wdsp/resamplef.cpp | 4 +-- 16 files changed, 85 insertions(+), 32 deletions(-) diff --git a/ft8/ft8.cpp b/ft8/ft8.cpp index d0b96478b..31d77ff0d 100644 --- a/ft8/ft8.cpp +++ b/ft8/ft8.cpp @@ -2006,6 +2006,9 @@ void FT8::soft_decode_mags(FT8Params& params, const std::vector TYPE(0) ? a : TYPE(0); } public: - LDPCEncoder() : initialized(false) + LDPCEncoder() : + N(2), + K(1), + R(1), + initialized(false) { } + void init(LDPCInterface *it) { if (initialized) diff --git a/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h b/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h index e5867a980..a7cdee3c7 100644 --- a/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h +++ b/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h @@ -77,6 +77,7 @@ public: template class LDPCDecoder { +private: TYPE *bnl, *pty, *inp, *out; uint16_t *pos; uint8_t *cnc; @@ -89,6 +90,7 @@ class LDPCDecoder for (int i = 0; i < LT; ++i) bnl[i] = alg.zero(); } + bool bad(TYPE *data, TYPE *parity, int blocks) { for (int i = 0; i < q; ++i) { @@ -107,6 +109,7 @@ class LDPCDecoder } return false; } + void update(TYPE *data, TYPE *parity) { TYPE *bl = bnl; @@ -135,10 +138,26 @@ class LDPCDecoder } } } + public: - LDPCDecoder() : initialized(false) + LDPCDecoder() : + bnl(nullptr), + pty(nullptr), + inp(nullptr), + out(nullptr), + pos(nullptr), + cnc(nullptr), + M(0), + N(0), + K(0), + R(0), + q(0), + CNL(0), + LT(0), + initialized(false) { } + void init(LDPCInterface *it) { if (initialized) { diff --git a/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp b/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp index fee0a1730..eebc9b24a 100644 --- a/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp +++ b/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp @@ -124,16 +124,18 @@ int main(int argc, char **argv) // DVB-S2 MODCOD definitions static const char *mc_tabnames[2][32] = { // [shortframes][modcod] - {// Normal frames - 0, "B1", "B2", "B3", "B4", "B5", "B6", "B7", - "B8", "B9", "B10", "B11", "B5", "B6", "B7", "B9", - "B10", "B11", "B6", "B7", "B8", "B9", "B10", "B11", - "B7", "B8", "B8", "B10", "B11", 0, 0, 0}, - {// Short frames - 0, "C1", "C2", "C3", "C4", "C5", "C6", "C7", - "C8", "C9", "C10", 0, "C5", "C6", "C7", "C9", - "C10", 0, "C6", "C7", "C8", "C9", "C10", 0, - "C7", "C8", "C8", "C10", 0, 0, 0, 0}}; + {// Normal frames + 0, "B1", "B2", "B3", "B4", "B5", "B6", "B7", + "B8", "B9", "B10", "B11", "B5", "B6", "B7", "B9", + "B10", "B11", "B6", "B7", "B8", "B9", "B10", "B11", + "B7", "B8", "B8", "B10", "B11", 0, 0, 0 + }, + {// Short frames + 0, "C1", "C2", "C3", "C4", "C5", "C6", "C7", + "C8", "C9", "C10", 0, "C5", "C6", "C7", "C9", + "C10", 0, "C6", "C7", "C8", "C9", "C10", 0, + "C7", "C8", "C8", "C10", 0, 0, 0, 0 + }}; const char *tabname = mc_tabnames[shortframes][modcod]; if (!tabname) @@ -188,8 +190,16 @@ int main(int argc, char **argv) int blocks = j + ldpctool::SIMD_WIDTH > BLOCKS ? BLOCKS - j : ldpctool::SIMD_WIDTH; for (int n = 0; n < blocks; ++n) + { for (int i = 0; i < CODE_LEN; ++i) + { + if (((j + n) * CODE_LEN + i) >= BLOCKS * CODE_LEN) { + break; + } + reinterpret_cast(simd + i)[n] = code[(j + n) * CODE_LEN + i]; + } + } int count = decode(simd, simd + DATA_LEN, max_trials, blocks); num_decodes++; diff --git a/plugins/channelrx/radioastronomy/radioastronomy.cpp b/plugins/channelrx/radioastronomy/radioastronomy.cpp index 2254f7401..db300c5a4 100644 --- a/plugins/channelrx/radioastronomy/radioastronomy.cpp +++ b/plugins/channelrx/radioastronomy/radioastronomy.cpp @@ -155,14 +155,12 @@ RadioAstronomy::~RadioAstronomy() m_deviceAPI->removeChannelSinkAPI(this); m_deviceAPI->removeChannelSink(this); - if (m_basebandSink->isRunning()) { + if ((m_basebandSink->isRunning()) || (m_worker->isRunning())) { stop(); } - delete m_basebandSink; - if (m_worker->isRunning()) { - stop(); - } - delete m_worker; + + m_worker->deleteLater(); + m_basebandSink->deleteLater(); } void RadioAstronomy::setDeviceAPI(DeviceAPI *deviceAPI) diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h b/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h index 3cd8ff614..e9e456195 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h @@ -60,6 +60,9 @@ struct IEEE_802_15_4_MacFrame IEEE_802_15_4_MacFrame() { + m_destShortAddress = 0; + m_sourceShortAddress = 0; + if (false) { // Example ACK frame diff --git a/scriptsapi/superscanner.py b/scriptsapi/superscanner.py index 7c8cedc64..d85793480 100644 --- a/scriptsapi/superscanner.py +++ b/scriptsapi/superscanner.py @@ -14,7 +14,7 @@ except ImportError: import _thread as thread import time -from datetime import datetime +from datetime import datetime, timezone from optparse import OptionParser import sdrangel @@ -50,7 +50,7 @@ class SuperScannerAPIError(SuperScannerError): # ====================================================================== def log_with_timestamp(message): - t = datetime.utcnow() + t = datetime.now(timezone.utc) print(f'{t.isoformat()} {message}') # ====================================================================== diff --git a/sdrbase/dsp/sigmffilerecord.cpp b/sdrbase/dsp/sigmffilerecord.cpp index 885d5875a..301b6d080 100644 --- a/sdrbase/dsp/sigmffilerecord.cpp +++ b/sdrbase/dsp/sigmffilerecord.cpp @@ -143,7 +143,7 @@ void SigMFFileRecord::setFileName(const QString& fileName) } m_initialBytesCount = (uint64_t) m_sampleFile.size(); m_sampleStart = m_initialBytesCount / ((1<= N + 2) { + break; + } + WinCoeff[j] = 1.0; + } } // This will set the gain of the window to 1. Only the Flattop window has unity gain by design. diff --git a/wdsp/cfcomp.cpp b/wdsp/cfcomp.cpp index ea6efd4db..9b93f8abe 100644 --- a/wdsp/cfcomp.cpp +++ b/wdsp/cfcomp.cpp @@ -117,7 +117,6 @@ void CFCOMP::calc_comp (CFCOMP *a) a->G[i] = sary[3 * i + 1]; a->E[i] = sary[3 * i + 2]; } - delete[] (sary); a->fp[0] = 0.0; a->fp[a->nfreqs + 1] = fmax; a->gp[0] = a->G[0]; diff --git a/wdsp/emnr.cpp b/wdsp/emnr.cpp index 14d9d2388..d54c0357c 100644 --- a/wdsp/emnr.cpp +++ b/wdsp/emnr.cpp @@ -230,7 +230,7 @@ void EMNR::interpM (double* res, double x, int nvals, double* xvals, double* yva } else { - int idx = 0; + int idx = 1; double xllow, xlhigh, frac; while ((x >= xvals[idx]) && (idx < nvals - 1)) diff --git a/wdsp/fir.cpp b/wdsp/fir.cpp index e7a404b01..269694c36 100644 --- a/wdsp/fir.cpp +++ b/wdsp/fir.cpp @@ -317,10 +317,15 @@ float *FIR::fir_read (int N, const char *filename, int rtype, float scale) void FIR::analytic (int N, float* in, float* out) { + if (N < 1) { + return; + } + int i; double inv_N = 1.0 / (double) N; double two_inv_N = 2.0 * inv_N; float* x = new float[N * 2]; // (float *) malloc0 (N * sizeof (complex)); + fftwf_plan pfor = fftwf_plan_dft_1d ( N, (fftwf_complex *) in, @@ -328,6 +333,7 @@ void FIR::analytic (int N, float* in, float* out) FFTW_FORWARD, FFTW_PATIENT ); + fftwf_plan prev = fftwf_plan_dft_1d ( N, (fftwf_complex *) x, @@ -335,20 +341,24 @@ void FIR::analytic (int N, float* in, float* out) FFTW_BACKWARD, FFTW_PATIENT ); + fftwf_execute (pfor); x[0] *= inv_N; x[1] *= inv_N; + for (i = 1; i < N / 2; i++) { x[2 * i + 0] *= two_inv_N; x[2 * i + 1] *= two_inv_N; } + x[N + 0] *= inv_N; x[N + 1] *= inv_N; memset (&x[N + 2], 0, (N - 2) * sizeof (float)); fftwf_execute (prev); fftwf_destroy_plan (prev); fftwf_destroy_plan (pfor); + delete[] x; } diff --git a/wdsp/resample.cpp b/wdsp/resample.cpp index ac66017a1..02ba5b4b9 100644 --- a/wdsp/resample.cpp +++ b/wdsp/resample.cpp @@ -60,8 +60,8 @@ void RESAMPLE::calc_resample (RESAMPLE *a) a->L = a->out_rate / x; a->M = a->in_rate / x; - a->L <= 0 ? 1 : a->L; - a->M <= 0 ? 1 : a->M; + a->L = a->L <= 0 ? 1 : a->L; + a->M = a->M <= 0 ? 1 : a->M; if (a->in_rate < a->out_rate) min_rate = a->in_rate; diff --git a/wdsp/resamplef.cpp b/wdsp/resamplef.cpp index 41624abdc..a79330f23 100644 --- a/wdsp/resamplef.cpp +++ b/wdsp/resamplef.cpp @@ -64,8 +64,8 @@ RESAMPLEF* RESAMPLEF::create_resampleF ( int run, int size, float* in, float* ou a->L = out_rate / x; a->M = in_rate / x; - a->L <= 0 ? 1 : a->L; - a->M <= 0 ? 1 : a->M; + a->L = a->L <= 0 ? 1 : a->L; + a->M = a->M <= 0 ? 1 : a->M; if (in_rate < out_rate) min_rate = in_rate; From 189d5a6a01298168f174f2ac2954c58500fc535b Mon Sep 17 00:00:00 2001 From: f4exb Date: Sun, 21 Jul 2024 23:15:32 +0200 Subject: [PATCH 2/4] More Sonar fixes --- ft8/ft8.cpp | 7 ++-- .../channelrx/demoddatv/ldpctool/encoder.h | 12 +++---- .../demoddatv/ldpctool/layered_decoder.h | 35 ++++++++----------- .../demoddatv/ldpctool/ldpc_tool.cpp | 12 +++---- .../mod802.15.4/ieee_802_15_4_macframe.h | 7 ++-- 5 files changed, 30 insertions(+), 43 deletions(-) diff --git a/ft8/ft8.cpp b/ft8/ft8.cpp index 31d77ff0d..b11c09604 100644 --- a/ft8/ft8.cpp +++ b/ft8/ft8.cpp @@ -1949,8 +1949,8 @@ void FT8::soft_decode_mags(FT8Params& params, const std::vector zeroi(zoX*zoY); + std::vector onei(zoX*zoY); for (int biti = 0; biti < nbSymbolBits; biti++) { @@ -2006,9 +2006,6 @@ void FT8::soft_decode_mags(FT8Params& params, const std::vector class LDPCEncoder { LDPCInterface *ldpc; - int N, K, R; - bool initialized; + int N = 2; + int K = 1; + int R = 1; + bool initialized = false; TYPE one() { @@ -43,11 +45,7 @@ class LDPCEncoder return b < TYPE(0) ? -a : b > TYPE(0) ? a : TYPE(0); } public: - LDPCEncoder() : - N(2), - K(1), - R(1), - initialized(false) + LDPCEncoder() { } diff --git a/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h b/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h index a7cdee3c7..d8762c77e 100644 --- a/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h +++ b/plugins/channelrx/demoddatv/ldpctool/layered_decoder.h @@ -78,12 +78,21 @@ template class LDPCDecoder { private: - TYPE *bnl, *pty, *inp, *out; - uint16_t *pos; - uint8_t *cnc; + TYPE *bnl = nullptr; + TYPE *pty = nullptr; + TYPE *inp = nullptr; + TYPE *out = nullptr; + uint16_t *pos = nullptr; + uint8_t *cnc = nullptr; ALG alg; - int M, N, K, R, q, CNL, LT; - bool initialized; + int M = 0; + int N = 0; + int K = 0; + int R = 0; + int q = 0; + int CNL = 0; + int LT = 0; + bool initialized = false; void reset() { @@ -140,21 +149,7 @@ private: } public: - LDPCDecoder() : - bnl(nullptr), - pty(nullptr), - inp(nullptr), - out(nullptr), - pos(nullptr), - cnc(nullptr), - M(0), - N(0), - K(0), - R(0), - q(0), - CNL(0), - LT(0), - initialized(false) + LDPCDecoder() { } diff --git a/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp b/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp index eebc9b24a..7b1b54952 100644 --- a/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp +++ b/plugins/channelrx/demoddatv/ldpctool/ldpc_tool.cpp @@ -125,16 +125,16 @@ int main(int argc, char **argv) // DVB-S2 MODCOD definitions static const char *mc_tabnames[2][32] = { // [shortframes][modcod] {// Normal frames - 0, "B1", "B2", "B3", "B4", "B5", "B6", "B7", + nullptr, "B1", "B2", "B3", "B4", "B5", "B6", "B7", "B8", "B9", "B10", "B11", "B5", "B6", "B7", "B9", "B10", "B11", "B6", "B7", "B8", "B9", "B10", "B11", - "B7", "B8", "B8", "B10", "B11", 0, 0, 0 + "B7", "B8", "B8", "B10", "B11", nullptr, nullptr, nullptr }, {// Short frames - 0, "C1", "C2", "C3", "C4", "C5", "C6", "C7", - "C8", "C9", "C10", 0, "C5", "C6", "C7", "C9", - "C10", 0, "C6", "C7", "C8", "C9", "C10", 0, - "C7", "C8", "C8", "C10", 0, 0, 0, 0 + nullptr, "C1", "C2", "C3", "C4", "C5", "C6", "C7", + "C8", "C9", "C10", nullptr, "C5", "C6", "C7", "C9", + "C10", nullptr, "C6", "C7", "C8", "C9", "C10", nullptr, + "C7", "C8", "C8", "C10", nullptr, nullptr, nullptr, nullptr }}; const char *tabname = mc_tabnames[shortframes][modcod]; diff --git a/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h b/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h index e9e456195..2e141edae 100644 --- a/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h +++ b/plugins/channeltx/mod802.15.4/ieee_802_15_4_macframe.h @@ -50,19 +50,16 @@ struct IEEE_802_15_4_MacFrame uint16_t m_frameControl; uint8_t m_sequenceNumber; uint16_t m_destPANID; - uint16_t m_destShortAddress; + uint16_t m_destShortAddress = 0; ieee_802_15_4_address m_destAddress; uint16_t m_sourcePANID; - uint16_t m_sourceShortAddress; + uint16_t m_sourceShortAddress = 0; ieee_802_15_4_address m_sourceAddress; uint8_t m_payload[IEEE_802_15_4_MAC_PAYLOAD_MAX_LENGTH]; uint8_t m_payloadLength; IEEE_802_15_4_MacFrame() { - m_destShortAddress = 0; - m_sourceShortAddress = 0; - if (false) { // Example ACK frame From 3799746ac0b399dd800b9f783542782331af0b52 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 22 Jul 2024 00:34:26 +0200 Subject: [PATCH 3/4] More Sonar fixes (2) --- ft8/ft8.cpp | 4 ++++ plugins/channelrx/demoddatv/ldpctool/encoder.h | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/ft8/ft8.cpp b/ft8/ft8.cpp index b11c09604..aa9d09b97 100644 --- a/ft8/ft8.cpp +++ b/ft8/ft8.cpp @@ -1938,6 +1938,10 @@ void FT8::soft_decode(const FFTEngine::ffts_t &c79, float ll174[]) // void FT8::soft_decode_mags(FT8Params& params, const std::vector>& mags_, int nbSymbolBits, float ll174[]) { + if (nbSymbolBits > 16) { + return; + } + std::vector> mags = convert_to_snr_gen(params, nbSymbolBits, mags_); // statistics to decide soft probabilities. // distribution of strongest tones, and diff --git a/plugins/channelrx/demoddatv/ldpctool/encoder.h b/plugins/channelrx/demoddatv/ldpctool/encoder.h index fc1e07788..2c8fbd7bd 100644 --- a/plugins/channelrx/demoddatv/ldpctool/encoder.h +++ b/plugins/channelrx/demoddatv/ldpctool/encoder.h @@ -30,7 +30,7 @@ namespace ldpctool { template class LDPCEncoder { - LDPCInterface *ldpc; + LDPCInterface *ldpc = nullptr; int N = 2; int K = 1; int R = 1; From 0a9a2ba13654754b2fe9daec55ff1df669de7173 Mon Sep 17 00:00:00 2001 From: f4exb Date: Mon, 22 Jul 2024 04:25:43 +0200 Subject: [PATCH 4/4] More Sonar fixes (3) --- ft8/ft8.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ft8/ft8.cpp b/ft8/ft8.cpp index aa9d09b97..7f50613ee 100644 --- a/ft8/ft8.cpp +++ b/ft8/ft8.cpp @@ -1938,7 +1938,7 @@ void FT8::soft_decode(const FFTEngine::ffts_t &c79, float ll174[]) // void FT8::soft_decode_mags(FT8Params& params, const std::vector>& mags_, int nbSymbolBits, float ll174[]) { - if (nbSymbolBits > 16) { + if ((nbSymbolBits > 16) || (nbSymbolBits < 1)) { return; }