From c74b374636554b47b6b0b2c3a5a529e0cd050a1d Mon Sep 17 00:00:00 2001 From: Andy CA6JAU Date: Sun, 20 Aug 2017 12:24:12 -0300 Subject: [PATCH] Adding watchdog to host serial port --- IO.cpp | 4 ++++ IO.h | 3 ++- SerialPort.cpp | 9 +++++++++ 3 files changed, 15 insertions(+), 1 deletion(-) diff --git a/IO.cpp b/IO.cpp index b6882a4..1a93dbb 100644 --- a/IO.cpp +++ b/IO.cpp @@ -266,3 +266,7 @@ void CIO::resetWatchdog() m_watchdog = 0U; } +uint32_t CIO::getWatchdog() +{ + return m_watchdog; +} diff --git a/IO.h b/IO.h index 429fd1f..a7ae6d6 100644 --- a/IO.h +++ b/IO.h @@ -81,7 +81,8 @@ public: void interrupt2(void); #endif void resetWatchdog(void); - + uint32_t getWatchdog(void); + #if defined(BIDIR_DATA_PIN) void Data_dir_out(bool dir); #endif diff --git a/SerialPort.cpp b/SerialPort.cpp index 535059c..6a20f45 100644 --- a/SerialPort.cpp +++ b/SerialPort.cpp @@ -406,6 +406,10 @@ void CSerialPort::process() m_ptr = 1U; m_len = 0U; } + else { + m_ptr = 0U; + m_len = 0U; + } } else if (m_ptr == 1U) { // Handle the frame length m_len = m_buffer[m_ptr] = c; @@ -645,6 +649,11 @@ void CSerialPort::process() } } + if (io.getWatchdog() >= 48000U) { + m_ptr = 0U; + m_len = 0U; + } + #if defined(SERIAL_REPEATER) || defined(SERIAL_REPEATER_USART1) // Drain any incoming serial data while (availableInt(3U))