Add a playout timer to avoid flooding the modem with data.

This commit is contained in:
Jonathan Naylor 2016-03-31 11:42:12 +01:00
parent f5a6bdc6bb
commit 582775aeed
2 changed files with 17 additions and 0 deletions

View file

@ -103,6 +103,7 @@ m_rxYSFData(1000U, "Modem RX YSF"),
m_txYSFData(1000U, "Modem TX YSF"),
m_statusTimer(1000U, 0U, 250U),
m_inactivityTimer(1000U, 0U, 1500U),
m_playoutTimer(1000U, 0U, 10U),
m_dstarSpace(0U),
m_dmrSpace1(0U),
m_dmrSpace2(0U),
@ -398,6 +399,11 @@ void CModem::clock(unsigned int ms)
}
}
// Only feed data to the modem if the playout timer has expired
m_playoutTimer.clock(ms);
if (!m_playoutTimer.hasExpired())
return;
if (m_dstarSpace > 1U && !m_txDStarData.isEmpty()) {
unsigned char buffer[4U];
m_txDStarData.peek(buffer, 4U);
@ -429,6 +435,8 @@ void CModem::clock(unsigned int ms)
int ret = m_serial.write(m_buffer, len);
if (ret != int(len))
LogWarning("Error when writing D-Star data to the MMDVM");
m_playoutTimer.start();
}
}
@ -444,6 +452,8 @@ void CModem::clock(unsigned int ms)
if (ret != int(len))
LogWarning("Error when writing DMR data to the MMDVM");
m_playoutTimer.start();
m_dmrSpace1--;
}
@ -459,6 +469,8 @@ void CModem::clock(unsigned int ms)
if (ret != int(len))
LogWarning("Error when writing DMR data to the MMDVM");
m_playoutTimer.start();
m_dmrSpace2--;
}
@ -474,6 +486,8 @@ void CModem::clock(unsigned int ms)
if (ret != int(len))
LogWarning("Error when writing YSF data to the MMDVM");
m_playoutTimer.start();
m_ysfSpace--;
}
}
@ -802,6 +816,8 @@ bool CModem::setConfig()
return false;
}
m_playoutTimer.start();
return true;
}

View file

@ -100,6 +100,7 @@ private:
CRingBuffer<unsigned char> m_txYSFData;
CTimer m_statusTimer;
CTimer m_inactivityTimer;
CTimer m_playoutTimer;
unsigned int m_dstarSpace;
unsigned int m_dmrSpace1;
unsigned int m_dmrSpace2;