mirror of https://github.com/markqvist/MMDVM.git
Sanity check the ring buffers.
parent
a381387c5c
commit
0c635f5132
|
@ -101,7 +101,7 @@ void CCWIdTX::process()
|
|||
|
||||
uint16_t space = io.getSpace();
|
||||
|
||||
while (space > CYCLE_LENGTH && space <= TX_RINGBUFFER_SIZE) {
|
||||
while (space > CYCLE_LENGTH) {
|
||||
bool b = READ_BIT1(m_poBuffer, m_poPtr);
|
||||
if (b)
|
||||
io.write(TONE, CYCLE_LENGTH);
|
||||
|
|
|
@ -113,7 +113,7 @@ void CDMRTX::process()
|
|||
if (m_poLen > 0U) {
|
||||
uint16_t space = io.getSpace();
|
||||
|
||||
while (space > (4U * DMR_RADIO_SYMBOL_LENGTH) && space <= TX_RINGBUFFER_SIZE) {
|
||||
while (space > (4U * DMR_RADIO_SYMBOL_LENGTH)) {
|
||||
uint8_t c = m_poBuffer[m_poPtr];
|
||||
uint8_t m = m_markBuffer[m_poPtr];
|
||||
m_poPtr++;
|
||||
|
|
|
@ -266,7 +266,7 @@ void CDStarTX::process()
|
|||
if (m_poLen > 0U) {
|
||||
uint16_t space = io.getSpace();
|
||||
|
||||
while (space > (8U * DSTAR_RADIO_BIT_LENGTH) && space <= TX_RINGBUFFER_SIZE) {
|
||||
while (space > (8U * DSTAR_RADIO_BIT_LENGTH)) {
|
||||
uint8_t c = m_poBuffer[m_poPtr++];
|
||||
writeByte(c);
|
||||
|
||||
|
|
13
SampleRB.cpp
13
SampleRB.cpp
|
@ -35,12 +35,19 @@ m_overflow(false)
|
|||
|
||||
uint16_t CSampleRB::getSpace() const
|
||||
{
|
||||
uint16_t n = 0U;
|
||||
|
||||
if (m_tail == m_head)
|
||||
return m_full ? 0U : m_length;
|
||||
n = m_full ? 0U : m_length;
|
||||
else if (m_tail < m_head)
|
||||
return m_length - m_head + m_tail;
|
||||
n = m_length - m_head + m_tail;
|
||||
else
|
||||
return m_tail - m_head;
|
||||
n = m_tail - m_head;
|
||||
|
||||
if (n > m_length)
|
||||
n = 0U;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
uint16_t CSampleRB::getData() const
|
||||
|
|
13
SerialRB.cpp
13
SerialRB.cpp
|
@ -39,12 +39,19 @@ void CSerialRB::reset()
|
|||
|
||||
uint16_t CSerialRB::getSpace() const
|
||||
{
|
||||
uint16_t n = 0U;
|
||||
|
||||
if (m_tail == m_head)
|
||||
return m_full ? 0U : m_length;
|
||||
n = m_full ? 0U : m_length;
|
||||
else if (m_tail < m_head)
|
||||
return m_length - m_head + m_tail;
|
||||
n = m_length - m_head + m_tail;
|
||||
else
|
||||
return m_tail - m_head;
|
||||
n = m_tail - m_head;
|
||||
|
||||
if (n > m_length)
|
||||
n = 0U;
|
||||
|
||||
return n;
|
||||
}
|
||||
|
||||
uint16_t CSerialRB::getData() const
|
||||
|
|
Loading…
Reference in New Issue