Add a watchdog for a crashed host.

This commit is contained in:
Jonathan Naylor 2016-02-02 20:23:37 +00:00
parent 62df65003b
commit c468842e46
3 changed files with 26 additions and 1 deletions

21
IO.cpp
View File

@ -119,7 +119,8 @@ m_ledCount(0U),
m_ledValue(true),
m_dcd(false),
m_overflow(0U),
m_overcount(0U)
m_overcount(0U),
m_watchdog(0U)
{
::memset(m_C4FSKState, 0x00U, 70U * sizeof(q15_t));
::memset(m_GMSKState, 0x00U, 40U * sizeof(q15_t));
@ -208,6 +209,17 @@ void CIO::process()
{
m_ledCount++;
if (m_started) {
// Two seconds timeout
if (m_watchdog >= 48000U) {
if (m_modemState == STATE_DSTAR || m_modemState == STATE_DMR || m_modemState == STATE_YSF) {
if (m_modemState == STATE_DMR)
dmrTX.setStart(false);
m_modemState = STATE_IDLE;
}
m_watchdog = 0U;
}
if (m_ledCount >= 24000U) {
m_ledCount = 0U;
m_ledValue = !m_ledValue;
@ -358,6 +370,8 @@ void CIO::interrupt()
#endif
m_rxBuffer.put(sample, control);
m_watchdog++;
}
void CIO::setDecode(bool dcd)
@ -411,3 +425,8 @@ bool CIO::hasRXOverflow()
return m_rxBuffer.hasOverflowed();
}
void CIO::resetWatchdog()
{
m_watchdog = 0U;
}

4
IO.h
View File

@ -46,6 +46,8 @@ public:
bool hasTXOverflow();
bool hasRXOverflow();
void resetWatchdog();
private:
#if defined(__MBED__)
DigitalOut m_pinPTT;
@ -79,6 +81,8 @@ private:
uint16_t m_overflow;
uint16_t m_overcount;
volatile uint32_t m_watchdog;
};
#endif

View File

@ -98,6 +98,8 @@ void CSerialPort::sendNAK(uint8_t err) const
void CSerialPort::getStatus() const
{
io.resetWatchdog();
uint8_t reply[11U];
// Send all sorts of interesting internal values