From 6b4fe7dd3350d3ba9857372a469d20bc029ba07a Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sun, 10 May 2020 22:08:36 +0200 Subject: [PATCH 1/4] Loop using correct length --- FMControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FMControl.cpp b/FMControl.cpp index 45310ce..4a04e72 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -57,7 +57,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) m_incomingRFAudio.getData(bufferData, bufferLength); // Unpack the serial data into float values. - for (unsigned int i = 0U; i < length; i += 3U) { + for (unsigned int i = 0U; i < bufferLength; i += 3U) { unsigned short sample1 = 0U; unsigned short sample2 = 0U; unsigned int MASK = 0x00000FFFU; From 7bca8578521db2aa39961e7240397b37d2f7d259 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sun, 10 May 2020 22:08:36 +0200 Subject: [PATCH 2/4] Loop using correct length --- FMControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FMControl.cpp b/FMControl.cpp index c1d3fd0..a3a7528 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -62,7 +62,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) m_incomingRFAudio.getData(bufferData, bufferLength); // Unpack the serial data into float values. - for (unsigned int i = 0U; i < length; i += 3U) { + for (unsigned int i = 0U; i < bufferLength; i += 3U) { unsigned short sample1 = 0U; unsigned short sample2 = 0U; unsigned int MASK = 0x00000FFFU; From bc6f832b7d4fd5a4ac228f974ea7a02880301157 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Sun, 10 May 2020 22:08:36 +0200 Subject: [PATCH 3/4] Loop using correct length --- FMControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/FMControl.cpp b/FMControl.cpp index c1d3fd0..a3a7528 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -62,7 +62,7 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) m_incomingRFAudio.getData(bufferData, bufferLength); // Unpack the serial data into float values. - for (unsigned int i = 0U; i < length; i += 3U) { + for (unsigned int i = 0U; i < bufferLength; i += 3U) { unsigned short sample1 = 0U; unsigned short sample2 = 0U; unsigned int MASK = 0x00000FFFU; From cbcbe4c56a4579039fe705dd75d1c91e467f9771 Mon Sep 17 00:00:00 2001 From: Geoffrey Merck Date: Mon, 11 May 2020 18:38:07 +0200 Subject: [PATCH 4/4] Used fixed length array --- FMControl.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/FMControl.cpp b/FMControl.cpp index a3a7528..bc1e0b0 100644 --- a/FMControl.cpp +++ b/FMControl.cpp @@ -22,6 +22,7 @@ #define EMPHASIS_GAIN_DB 0 //Gain needs to be the same for pre an deeemphasis #define RF_AUDIO_SAMP_RATE 8000 +#define FM_AUDIO_BLOCK_SIZE 240 CFMControl::CFMControl(CFMNetwork* network) : m_network(network), @@ -55,10 +56,12 @@ bool CFMControl::writeModem(const unsigned char* data, unsigned int length) m_incomingRFAudio.addData(data + 1U, length - 1U); unsigned int bufferLength = m_incomingRFAudio.dataSize(); + if(bufferLength > 255U) + bufferLength = 255U; if (bufferLength >= 3U) { bufferLength = bufferLength - bufferLength % 3U; //round down to nearest multiple of 3 - unsigned char bufferData[bufferLength]; + unsigned char bufferData[255]; m_incomingRFAudio.getData(bufferData, bufferLength); // Unpack the serial data into float values.