From 746d915bf9e16b120179a1771b0937c85a67ec81 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Thu, 11 Jun 2020 12:14:36 +0100 Subject: [PATCH] Rescale one of the filters for the MMDVM sample rate. --- AX25Demodulator.cpp | 11 ++++++----- AX25RX.cpp | 29 ++++++++++++++++------------- 2 files changed, 22 insertions(+), 18 deletions(-) diff --git a/AX25Demodulator.cpp b/AX25Demodulator.cpp index 4e635af..692a63a 100644 --- a/AX25Demodulator.cpp +++ b/AX25Demodulator.cpp @@ -122,6 +122,7 @@ bool CAX25Demodulator::process(const q15_t* samples, uint8_t length, CAX25Frame& } else { result = HDLC(NRZI(bit)); if (result) { + // Copy the frame data. ::memcpy(frame.m_data, m_frame.m_data, AX25_MAX_PACKET_LEN); frame.m_length = frame.m_length; frame.m_fcs = m_frame.m_fcs; @@ -187,8 +188,6 @@ bool CAX25Demodulator::PLL(bool input) bool CAX25Demodulator::HDLC(bool b) { - bool result = false; - if (m_hdlcOnes == 5U) { if (b) { // flag byte @@ -197,7 +196,7 @@ bool CAX25Demodulator::HDLC(bool b) // bit stuffing... m_hdlcFlag = false; m_hdlcOnes = 0U; - return result; + return false; } } @@ -211,9 +210,11 @@ bool CAX25Demodulator::HDLC(bool b) m_hdlcOnes = 0U; if (m_hdlcFlag) { + bool result = false; + switch (m_hdlcBuffer) { case 0x7E: - if (m_frame.m_length > 0U) { + if (m_frame.m_length > 2U) { result = m_frame.checkCRC(); if (!result) m_frame.m_length = 0U; @@ -262,6 +263,6 @@ bool CAX25Demodulator::HDLC(bool b) break; } - return result; + return false; } diff --git a/AX25RX.cpp b/AX25RX.cpp index de20709..c138333 100644 --- a/AX25RX.cpp +++ b/AX25RX.cpp @@ -60,7 +60,7 @@ float32_t dB3[] = { /* * Generated with Scipy Filter, 152 coefficients, 1100-2300Hz bandpass, - * Hann window, starting and ending 0 value coefficients removed. + * Hann window. * * np.array( * firwin2(152, @@ -79,19 +79,22 @@ float32_t dB3[] = { */ const uint32_t FILTER_LEN = 132U; -// XXX This is for the wrong sample rate q15_t FILTER_COEFFS[] = { - 4, 0, -5, -10, -13, -12, -9, -4, -2, -4, -12, -26, - -41, -52, -51, -35, -3, 39, 83, 117, 131, 118, 83, 36, - -6, -32, -30, -3, 36, 67, 66, 19, -74, -199, -323, -408, - -421, -344, -187, 17, 218, 364, 417, 369, 247, 106, 14, 26, - 166, 407, 676, 865, 866, 605, 68, -675, -1484, -2171, -2547, -2471, --1895, -882, 394, 1692, 2747, 3337, 3337, 2747, 1692, 394, -882, -1895, --2471, -2547, -2171, -1484, -675, 68, 605, 866, 865, 676, 407, 166, - 26, 14, 106, 247, 369, 417, 364, 218, 17, -187, -344, -421, - -408, -323, -199, -74, 19, 66, 67, 36, -3, -30, -32, -6, - 36, 83, 118, 131, 117, 83, 39, -3, -35, -51, -52, -41, - -26, -12, -4, -2, -4, -9, -12, -13, -10, -5, 0, 4}; + 0, 5, 12, 18, 21, 19, 11, -2, -15, + -25, -27, -21, -11, -3, -5, -19, -43, -69, + -83, -73, -35, 27, 98, 155, 180, 163, 109, + 39, -20, -45, -26, 23, 74, 89, 39, -81, + -247, -407, -501, -480, -334, -92, 175, 388, 479, + 429, 275, 99, 5, 68, 298, 626, 913, 994, + 740, 115, -791, -1770, -2544, -2847, -2509, -1527, -76, + 1518, 2875, 3653, 3653, 2875, 1518, -76, -1527, -2509, + -2847, -2544, -1770, -791, 115, 740, 994, 913, 626, + 298, 68, 5, 99, 275, 429, 479, 388, 175, + -92, -334, -480, -501, -407, -247, -81, 39, 89, + 74, 23, -26, -45, -20, 39, 109, 163, 180, + 155, 98, 27, -35, -73, -83, -69, -43, -19, + -5, -3, -11, -21, -27, -25, -15, -2, 11, + 19, 21, 18, 12, 5, 0}; CAX25RX::CAX25RX() : m_filter(),