From 1df9097e326a221851ba36202cd96f32fc1f4edd Mon Sep 17 00:00:00 2001 From: ProDrone Date: Wed, 13 May 2015 21:16:42 +0200 Subject: [PATCH] Added # to versionstring and strip comments Prepended the version string with a # to avoid the CLI from interpreting the version string as a command when pasting a dump file back (restore in CLI). Strip comments starting with `# comment` from lines. This is to allow adding comments to CLI dumped backup files. For this i have an automated addition of comments and/or manual comments by the user in mind. --- src/main/io/serial_cli.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/main/io/serial_cli.c b/src/main/io/serial_cli.c index f4497417f1..256bb6ac7d 100644 --- a/src/main/io/serial_cli.c +++ b/src/main/io/serial_cli.c @@ -1644,7 +1644,7 @@ static void cliVersion(char *cmdline) { UNUSED(cmdline); - printf("Cleanflight/%s %s %s / %s (%s)", + printf("# Cleanflight/%s %s %s / %s (%s)", targetName, FC_VERSION_STRING, buildDate, @@ -1710,6 +1710,13 @@ void cliProcess(void) clicmd_t target; cliPrint("\r\n"); + // Strip comment starting with # from line + char *p = cliBuffer; + p = strchr(++p, '#'); + if (NULL != p) { + bufferIndex = (uint32_t)(p - cliBuffer); + } + // Strip trailing whitespace while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') { bufferIndex--;