Add parsing and handling of help command

This commit is contained in:
BlackMark 2020-04-01 02:41:09 +02:00
parent af35388505
commit a33a764b1d

View File

@ -3,6 +3,8 @@
#include <ctype.h>
#include <stdint.h>
#include <avr/pgmspace.h>
#include "flash/flash.hpp"
#define ENDL F("\r\n")
@ -49,6 +51,7 @@ class Terminal {
if (m_serial.peek(inputByte) && (inputByte == '\r' || inputByte == '\n')) {
m_serial.rxByte(inputByte);
}
m_serial << ENDL;
handleInput = true;
break;
}
@ -63,7 +66,7 @@ class Terminal {
if (handleInput) {
parseInput();
m_inputSize = 0;
m_serial << ENDL << F("$ ");
m_serial << F("$ ");
}
}
@ -74,7 +77,18 @@ class Terminal {
static char m_inputBuffer[INPUT_BUFFER_SIZE];
static uint16_t m_inputSize;
static void parseInput() {}
static void parseInput()
{
if (m_inputSize && strncmp_P(m_inputBuffer, reinterpret_cast<const char *>(F("help")), m_inputSize) == 0) {
printHelp();
}
}
static void printHelp()
{
m_serial << F("Help: ") << ENDL;
m_serial << F("help .: print this help message") << ENDL;
}
};
template <class Uart>