Merge pull request #890 from ProDrone/cli_processing_mod_1
Some mods to CLI command interpretation and output
This commit is contained in:
commit
19be109189
|
@ -1645,7 +1645,7 @@ static void cliVersion(char *cmdline)
|
||||||
{
|
{
|
||||||
UNUSED(cmdline);
|
UNUSED(cmdline);
|
||||||
|
|
||||||
printf("Cleanflight/%s %s %s / %s (%s)",
|
printf("# Cleanflight/%s %s %s / %s (%s)",
|
||||||
targetName,
|
targetName,
|
||||||
FC_VERSION_STRING,
|
FC_VERSION_STRING,
|
||||||
buildDate,
|
buildDate,
|
||||||
|
@ -1711,14 +1711,21 @@ void cliProcess(void)
|
||||||
clicmd_t target;
|
clicmd_t target;
|
||||||
cliPrint("\r\n");
|
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
|
// Strip trailing whitespace
|
||||||
while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') {
|
while (bufferIndex > 0 && cliBuffer[bufferIndex - 1] == ' ') {
|
||||||
bufferIndex--;
|
bufferIndex--;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Process non-empty lines
|
||||||
|
if (bufferIndex > 0) {
|
||||||
cliBuffer[bufferIndex] = 0; // null terminate
|
cliBuffer[bufferIndex] = 0; // null terminate
|
||||||
|
|
||||||
if (cliBuffer[0] != '#') {
|
|
||||||
target.name = cliBuffer;
|
target.name = cliBuffer;
|
||||||
target.param = NULL;
|
target.param = NULL;
|
||||||
|
|
||||||
|
@ -1727,10 +1734,10 @@ void cliProcess(void)
|
||||||
cmd->func(cliBuffer + strlen(cmd->name) + 1);
|
cmd->func(cliBuffer + strlen(cmd->name) + 1);
|
||||||
else
|
else
|
||||||
cliPrint("Unknown command, try 'help'");
|
cliPrint("Unknown command, try 'help'");
|
||||||
|
bufferIndex = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
memset(cliBuffer, 0, sizeof(cliBuffer));
|
memset(cliBuffer, 0, sizeof(cliBuffer));
|
||||||
bufferIndex = 0;
|
|
||||||
|
|
||||||
// 'exit' will reset this flag, so we don't need to print prompt again
|
// 'exit' will reset this flag, so we don't need to print prompt again
|
||||||
if (!cliMode)
|
if (!cliMode)
|
||||||
|
|
Loading…
Reference in New Issue