From d9d5227af9cd91b47d021affae923e3d8acbf387 Mon Sep 17 00:00:00 2001 From: Dominic Clifton Date: Thu, 18 Sep 2014 00:46:42 +0100 Subject: [PATCH] Ignore CLI commands that are prefixed with # (comments) --- src/main/io/serial_cli.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index 1ba749986..77cdf7c38 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -1189,14 +1189,16 @@ void cliProcess(void) cliPrint("\r\n"); cliBuffer[bufferIndex] = 0; // null terminate - target.name = cliBuffer; - target.param = NULL; + if (cliBuffer[0] != '#') { + target.name = cliBuffer; + target.param = NULL; - cmd = bsearch(&target, cmdTable, CMD_COUNT, sizeof cmdTable[0], cliCompare); - if (cmd) - cmd->func(cliBuffer + strlen(cmd->name) + 1); - else - cliPrint("Unknown command, try 'help'"); + cmd = bsearch(&target, cmdTable, CMD_COUNT, sizeof cmdTable[0], cliCompare); + if (cmd) + cmd->func(cliBuffer + strlen(cmd->name) + 1); + else + cliPrint("Unknown command, try 'help'"); + } memset(cliBuffer, 0, sizeof(cliBuffer)); bufferIndex = 0; @@ -1204,6 +1206,7 @@ void cliProcess(void) // 'exit' will reset this flag, so we don't need to print prompt again if (!cliMode) return; + cliPrompt(); } else if (c == 127) { // backspace