From 372fe67da473da47aaab296d7427e0b689ffb787 Mon Sep 17 00:00:00 2001 From: Michal Demin Date: Thu, 15 Jun 2017 22:10:34 +0200 Subject: [PATCH] Make terminal commands executable from within firmware. Signed-off-by: Michal Demin --- Firmware/Chameleon-Mini/Terminal/CommandLine.c | 12 ++++++++++++ Firmware/Chameleon-Mini/Terminal/CommandLine.h | 1 + 2 files changed, 13 insertions(+) diff --git a/Firmware/Chameleon-Mini/Terminal/CommandLine.c b/Firmware/Chameleon-Mini/Terminal/CommandLine.c index e62403b..bd990ee 100644 --- a/Firmware/Chameleon-Mini/Terminal/CommandLine.c +++ b/Firmware/Chameleon-Mini/Terminal/CommandLine.c @@ -389,6 +389,18 @@ static CommandStatusIdType CallCommandFunc( return Status; } +void CommandExecute(const char* command) +{ + uint8_t i; + + for (i = 0; i < ARRAY_COUNT(CommandTable); i++) { + if (strcmp_P(command, CommandTable[i].Command) == 0) { + CallCommandFunc(&CommandTable[i], CHAR_EXEC_MODE, NULL); + break; + } + } +} + static void DecodeCommand(void) { uint8_t i; diff --git a/Firmware/Chameleon-Mini/Terminal/CommandLine.h b/Firmware/Chameleon-Mini/Terminal/CommandLine.h index 3ee0388..097a3ea 100644 --- a/Firmware/Chameleon-Mini/Terminal/CommandLine.h +++ b/Firmware/Chameleon-Mini/Terminal/CommandLine.h @@ -15,6 +15,7 @@ void CommandLineInit(void); bool CommandLineProcessByte(uint8_t Byte); void CommandLineTick(void); +void CommandExecute(const char* command); void CommandLineAppendData(void const * const Buffer, uint16_t Bytes); /* Functions for timeout commands */