From c0941c4856f150d47df6e338864db5c9d1d7a020 Mon Sep 17 00:00:00 2001 From: Jonathan Naylor Date: Sun, 2 Apr 2017 13:48:40 +0100 Subject: [PATCH] Add TX Delay buffer protection. --- DMRDMOTX.cpp | 5 ++++- DMRDMOTX.h | 2 +- DStarTX.cpp | 3 +++ P25TX.cpp | 3 +++ YSFTX.cpp | 3 +++ 5 files changed, 14 insertions(+), 2 deletions(-) diff --git a/DMRDMOTX.cpp b/DMRDMOTX.cpp index c30f50e..b0175c8 100644 --- a/DMRDMOTX.cpp +++ b/DMRDMOTX.cpp @@ -166,7 +166,10 @@ uint8_t CDMRDMOTX::getSpace() const void CDMRDMOTX::setTXDelay(uint8_t delay) { - m_txDelay = 240U + uint16_t(delay) * 12U; // 200ms + tx delay + m_txDelay = 600U + uint16_t(delay) * 12U; // 500ms + tx delay + + if (m_txDelay > 1200U) + m_txDelay = 1200U; } void CDMRDMOTX::createCACH(uint8_t* buffer, uint8_t slotIndex) diff --git a/DMRDMOTX.h b/DMRDMOTX.h index 022ecd0..98ffdb0 100644 --- a/DMRDMOTX.h +++ b/DMRDMOTX.h @@ -42,7 +42,7 @@ private: CSerialRB m_fifo; arm_fir_interpolate_instance_q15 m_modFilter; q15_t m_modState[16U]; // blockSize + phaseLength - 1, 4 + 9 - 1 plus some spare - uint8_t m_poBuffer[800U]; + uint8_t m_poBuffer[1200U]; uint16_t m_poLen; uint16_t m_poPtr; uint32_t m_txDelay; diff --git a/DStarTX.cpp b/DStarTX.cpp index 4f81574..92fb6d5 100644 --- a/DStarTX.cpp +++ b/DStarTX.cpp @@ -434,6 +434,9 @@ void CDStarTX::writeByte(uint8_t c) void CDStarTX::setTXDelay(uint8_t delay) { m_txDelay = 300U + uint16_t(delay) * 6U; // 250ms + tx delay + + if (m_txDelay > 600U) + m_txDelay = 600U; } uint8_t CDStarTX::getSpace() const diff --git a/P25TX.cpp b/P25TX.cpp index 8f92b3c..7edbeb5 100644 --- a/P25TX.cpp +++ b/P25TX.cpp @@ -166,6 +166,9 @@ void CP25TX::writeByte(uint8_t c) void CP25TX::setTXDelay(uint8_t delay) { m_txDelay = 600U + uint16_t(delay) * 12U; // 500ms + tx delay + + if (m_txDelay > 1200U) + m_txDelay = 1200U; } uint8_t CP25TX::getSpace() const diff --git a/YSFTX.cpp b/YSFTX.cpp index d1c5d76..ab3f953 100644 --- a/YSFTX.cpp +++ b/YSFTX.cpp @@ -152,6 +152,9 @@ void CYSFTX::writeByte(uint8_t c) void CYSFTX::setTXDelay(uint8_t delay) { m_txDelay = 600U + uint16_t(delay) * 12U; // 500ms + tx delay + + if (m_txDelay > 1200U) + m_txDelay = 1200U; } uint8_t CYSFTX::getSpace() const