From ae26cca46f0a268d8eae3b061aa8f45f0d742468 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niccol=C3=B2=20Izzo?= Date: Sun, 9 Jan 2022 15:48:49 +0100 Subject: [PATCH] Remove SPS Now M17_SAPLES_PER_SYMBOL is computed dinamically from sample rate. TG-81 --- openrtx/include/protocols/M17/M17Demodulator.h | 4 ++-- platform/targets/MD-3x0/hwconfig.h | 2 +- platform/targets/Module17/hwconfig.h | 2 +- platform/targets/linux/hwconfig.h | 2 +- tests/unit/M17_demodulator.cpp | 9 ++++----- 5 files changed, 9 insertions(+), 10 deletions(-) diff --git a/openrtx/include/protocols/M17/M17Demodulator.h b/openrtx/include/protocols/M17/M17Demodulator.h index da8b68bc..dcd3b06b 100644 --- a/openrtx/include/protocols/M17/M17Demodulator.h +++ b/openrtx/include/protocols/M17/M17Demodulator.h @@ -99,12 +99,12 @@ private: * our input buffer contains half M17 frame. */ // TODO: Select correct RRC filter according to sample rate - static constexpr size_t M17_RX_SAMPLE_RATE = 24000; + static constexpr size_t M17_SYMBOL_RATE = 4800; static constexpr size_t M17_FRAME_SAMPLES_24K = 960; static constexpr size_t M17_FRAME_SYMBOLS = 192; static constexpr size_t M17_SYNCWORD_SYMBOLS = 8; static constexpr size_t M17_CONV_THRESHOLD = 50000; - static constexpr size_t M17_SAMPLES_PER_SYMBOL = M17_SPS; + static constexpr size_t M17_SAMPLES_PER_SYMBOL = M17_RX_SAMPLE_RATE / M17_SYMBOL_RATE; static constexpr size_t M17_INPUT_BUF_SIZE = M17_FRAME_SAMPLES_24K / 2; static constexpr size_t M17_FRAME_BYTES = M17_FRAME_SYMBOLS / 4; static constexpr float conv_stats_alpha = 0.0001f; diff --git a/platform/targets/MD-3x0/hwconfig.h b/platform/targets/MD-3x0/hwconfig.h index 2de8d66f..e5c89879 100644 --- a/platform/targets/MD-3x0/hwconfig.h +++ b/platform/targets/MD-3x0/hwconfig.h @@ -140,6 +140,6 @@ #define GPS_DATA GPIOD,9 /* M17 demodulation */ -#define M17_SPS 5 +#define M17_RX_SAMPLE_RATE 24000 #endif diff --git a/platform/targets/Module17/hwconfig.h b/platform/targets/Module17/hwconfig.h index 722091cc..3e374c97 100644 --- a/platform/targets/Module17/hwconfig.h +++ b/platform/targets/Module17/hwconfig.h @@ -84,6 +84,6 @@ #define SOFTPOT_TX 0x2F /* M17 demodulation */ -#define M17_SPS 5 +#define M17_RX_SAMPLE_RATE 24000 #endif diff --git a/platform/targets/linux/hwconfig.h b/platform/targets/linux/hwconfig.h index 12d0b97d..2f43d7b2 100644 --- a/platform/targets/linux/hwconfig.h +++ b/platform/targets/linux/hwconfig.h @@ -56,4 +56,4 @@ #define PTT_SW "PTT_SW",11 /* M17 demodulation */ -#define M17_SPS 10 +#define M17_RX_SAMPLE_RATE 48000 diff --git a/tests/unit/M17_demodulator.cpp b/tests/unit/M17_demodulator.cpp index 8e4c8ddd..52502103 100644 --- a/tests/unit/M17_demodulator.cpp +++ b/tests/unit/M17_demodulator.cpp @@ -92,7 +92,7 @@ int main() fprintf(output_csv_1, "Input,RRCSignal,LSFConvolution,FrameConvolution,Stddev\n"); // Test convolution m17Demodulator.resetCorrelationStats(); - for(unsigned i = 0; i < baseband_samples - m17Demodulator.M17_SYNCWORD_SYMBOLS * M17_SPS; i++) + for(unsigned i = 0; i < baseband_samples - m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL; i++) { int32_t lsf_conv = m17Demodulator.convolution(i, @@ -125,7 +125,7 @@ int main() int expected_syncword = 0; fscanf(syncword_ref, "%d\n", &expected_syncword); syncword = m17Demodulator.nextFrameSync(offset); - offset = syncword.index + m17Demodulator.M17_SYNCWORD_SYMBOLS * M17_SPS; + offset = syncword.index + m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL; //printf("%d\n", syncword.index); if (syncword.index != expected_syncword) { @@ -147,14 +147,14 @@ int main() syncword = { -1, false }; m17Demodulator.resetCorrelationStats(); syncword = m17Demodulator.nextFrameSync(offset); - for(unsigned i = 0; i < baseband_samples - m17Demodulator.M17_SYNCWORD_SYMBOLS * M17_SPS; i++) + for(unsigned i = 0; i < baseband_samples - m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL; i++) { if ((int) i == syncword.index + 2) { if (syncword.lsf) detect = -40000; else detect = 40000; - syncword = m17Demodulator.nextFrameSync(syncword.index + m17Demodulator.M17_SYNCWORD_SYMBOLS * M17_SPS); + syncword = m17Demodulator.nextFrameSync(syncword.index + m17Demodulator.M17_SYNCWORD_SYMBOLS * m17Demodulator.M17_SAMPLES_PER_SYMBOL); } else if (((int) i % 10) == ((syncword.index + 2) % 10)) { m17Demodulator.updateQuantizationStats(i); symbol = m17Demodulator.quantize(i) * 10000; @@ -228,7 +228,6 @@ int main() } printf("Failed decoding %d/%d bytes!\n", failed_bytes, total_bytes); - // TODO: keep aside end of last buffer and use at beginning of the next buffer // TODO: when stream is over pad with zeroes to avoid corrupting the last symbols m17Demodulator.baseband = old_baseband;