Skip to content

Commit 6a975d3

Browse files
mrichonerdCopter
authored andcommitted
Add save_no_reboot, exit_no_reboot, add config command header/footer
1 parent b770dba commit 6a975d3

File tree

1 file changed

+38
-1
lines changed

1 file changed

+38
-1
lines changed

src/main/cli/cli.c

+38-1
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
// FIXME remove this for targets that don't need a CLI. Perhaps use a no-op macro when USE_CLI is not enabled
3232
// signal that we're in cli mode
3333
bool cliMode = false;
34+
bool cliExited = false;
3435

3536
#ifdef USE_CLI
3637

@@ -3607,6 +3608,24 @@ static void cliExit(const char *cmdName, char *cmdline)
36073608
cliReboot();
36083609
}
36093610

3611+
static void cliExitNoReboot(const char *cmdName, char *cmdline)
3612+
{
3613+
UNUSED(cmdName);
3614+
UNUSED(cmdline);
3615+
3616+
cliPrintHashLine("leaving CLI mode, unsaved changes lost");
3617+
cliWriterFlush();
3618+
3619+
*cliBuffer = '\0';
3620+
bufferIndex = 0;
3621+
cliMode = false;
3622+
cliExited = true;
3623+
// incase a motor was left running during motortest, clear it here
3624+
mixerResetDisarmedMotors();
3625+
waitForSerialPortToFinishTransmitting(cliPort);
3626+
motorShutdown();
3627+
}
3628+
36103629
#ifdef USE_GPS
36113630
static void cliGpsPassthrough(const char *cmdName, char *cmdline)
36123631
{
@@ -4266,6 +4285,18 @@ static void cliSave(const char *cmdName, char *cmdline)
42664285
}
42674286
}
42684287

4288+
static void cliSaveNoReboot(const char *cmdName, char *cmdline)
4289+
{
4290+
UNUSED(cmdline);
4291+
4292+
if (tryPrepareSave(cmdName)) {
4293+
writeEEPROM();
4294+
readEEPROM();
4295+
cliPrintHashLine("saving");
4296+
4297+
}
4298+
}
4299+
42694300
#if defined(USE_CUSTOM_DEFAULTS)
42704301
bool resetConfigToCustomDefaults(void)
42714302
{
@@ -4723,7 +4754,7 @@ static void cliRateProfilesJson(const char *cmdName)
47234754
static void cliConfig(const char *cmdName, char *cmdline)
47244755
{
47254756
UNUSED(cmdline);
4726-
4757+
cliPrintLine("----- CONFIG START -----");
47274758
cliPrintLine("{");
47284759
for (uint32_t i = 0; i < valueTableEntryCount; i++)
47294760
{
@@ -4751,6 +4782,7 @@ static void cliConfig(const char *cmdName, char *cmdline)
47514782
cliPrintf(",\"imuf\":\"%lu\"", imufCurrentVersion);
47524783
#endif
47534784
cliPrintLine("}");
4785+
cliPrintLine("----- CONFIG END -----");
47544786
}
47554787
#endif
47564788

@@ -6785,6 +6817,7 @@ const clicmd_t cmdTable[] = {
67856817
CLI_COMMAND_DEF("escprog", "passthrough esc to serial", "<mode [sk/bl/ki/cc]> <index>", cliEscPassthrough),
67866818
#endif
67876819
CLI_COMMAND_DEF("exit", NULL, NULL, cliExit),
6820+
CLI_COMMAND_DEF("exit_no_reboot", NULL, NULL, cliExitNoReboot),
67886821
CLI_COMMAND_DEF("feature", "configure features",
67896822
"list\r\n"
67906823
"\t<->[name]", cliFeature),
@@ -6845,6 +6878,7 @@ const clicmd_t cmdTable[] = {
68456878
CLI_COMMAND_DEF("rxfail", "show/set rx failsafe settings", NULL, cliRxFailsafe),
68466879
CLI_COMMAND_DEF("rxrange", "configure rx channel ranges", NULL, cliRxRange),
68476880
CLI_COMMAND_DEF("save", "save and reboot", NULL, cliSave),
6881+
CLI_COMMAND_DEF("save_no_reboot", "save without reboot", NULL, cliSaveNoReboot),
68486882
#ifdef USE_SDCARD
68496883
CLI_COMMAND_DEF("sd_info", "sdcard info", NULL, cliSdInfo),
68506884
#endif
@@ -7113,6 +7147,9 @@ static bool cliProcessCustomDefaults(bool quiet)
71137147

71147148
void cliEnter(serialPort_t *serialPort)
71157149
{
7150+
if (cliExited) { // required for exit_no_reboot
7151+
return;
7152+
}
71167153
cliMode = true;
71177154
cliPort = serialPort;
71187155
setPrintfSerialPort(cliPort);

0 commit comments

Comments
 (0)