diff --git a/fantemp/terminal.hpp b/fantemp/terminal.hpp index 77d00e6..2b6c796 100644 --- a/fantemp/terminal.hpp +++ b/fantemp/terminal.hpp @@ -95,8 +95,6 @@ class Terminal { if (handleInput) { parseInput(); - m_inputSize = 0; - m_serial << F("$ "); } if (m_state == State::MONITOR && --m_monitorDelayCounter == 0) { @@ -127,23 +125,29 @@ class Terminal { if (m_inputSize) { if (m_inputBuffer[m_inputSize - 1] == CTRL_C) { handleCtrlC(); - } else if (substringEquals(m_inputBuffer, detail::HELP_CMD, m_inputSize)) { - printHelp(); - } else if (substringEquals(m_inputBuffer, detail::SHOW_CMD, m_inputSize)) { - showState(); - } else if (substringEquals(m_inputBuffer, detail::CURVE_CMD, m_inputSize)) { - printCurve(); - } else if (substringEquals(m_inputBuffer, detail::MONITOR_CMD, m_inputSize)) { - m_state = State::MONITOR; - m_monitorDelayCounter = MONITOR_DELAY; - } else if (substringEquals(m_inputBuffer, detail::BOOTLOADER_CMD, m_inputSize)) { - handleBootloader(); - } else if (substringEquals(m_inputBuffer, detail::VERSION_CMD, m_inputSize)) { - printVersion(); - } else { - printUnknown(); + } else if (m_state == State::NONE) { + if (substringEquals(m_inputBuffer, detail::HELP_CMD, m_inputSize)) { + printHelp(); + } else if (substringEquals(m_inputBuffer, detail::SHOW_CMD, m_inputSize)) { + showState(); + } else if (substringEquals(m_inputBuffer, detail::CURVE_CMD, m_inputSize)) { + printCurve(); + } else if (substringEquals(m_inputBuffer, detail::MONITOR_CMD, m_inputSize)) { + m_state = State::MONITOR; + m_monitorDelayCounter = MONITOR_DELAY; + } else if (substringEquals(m_inputBuffer, detail::BOOTLOADER_CMD, m_inputSize)) { + handleBootloader(); + } else if (substringEquals(m_inputBuffer, detail::VERSION_CMD, m_inputSize)) { + printVersion(); + } else { + printUnknown(); + } } } + + m_inputSize = 0; + if (m_state == State::NONE) + m_serial << F("$ "); } static void handleCtrlC()