From aab90f0fc0956b02d511bdfc7ca986f26f829d10 Mon Sep 17 00:00:00 2001 From: BlackMark Date: Wed, 1 Apr 2020 05:07:12 +0200 Subject: [PATCH] Add ctrl + c handler --- fantemp/terminal.hpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fantemp/terminal.hpp b/fantemp/terminal.hpp index 280f39e..d310b42 100644 --- a/fantemp/terminal.hpp +++ b/fantemp/terminal.hpp @@ -89,7 +89,9 @@ class Terminal { static void parseInput() { if (m_inputSize) { - if (strncmp_P(m_inputBuffer, reinterpret_cast(HELP_CMD), m_inputSize) == 0) { + if (m_inputBuffer[m_inputSize - 1] == CTRL_C) { + handleCtrlC(); + } else if (strncmp_P(m_inputBuffer, reinterpret_cast(HELP_CMD), m_inputSize) == 0) { printHelp(); } else if (strncmp_P(m_inputBuffer, reinterpret_cast(SHOW_CMD), m_inputSize) == 0) { showState(); @@ -101,6 +103,11 @@ class Terminal { } } + static void handleCtrlC() + { + m_serial << F("Abort!") << ENDL; + } + static void printHelp() { m_serial << F("FanTemp command overview: ") << ENDL;