|
31 | 31 | // FIXME remove this for targets that don't need a CLI. Perhaps use a no-op macro when USE_CLI is not enabled |
32 | 32 | // signal that we're in cli mode |
33 | 33 | bool cliMode = false; |
| 34 | +bool cliExited = false; |
34 | 35 |
|
35 | 36 | #ifdef USE_CLI |
36 | 37 |
|
@@ -3607,6 +3608,24 @@ static void cliExit(const char *cmdName, char *cmdline) |
3607 | 3608 | cliReboot(); |
3608 | 3609 | } |
3609 | 3610 |
|
| 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 | + |
3610 | 3629 | #ifdef USE_GPS |
3611 | 3630 | static void cliGpsPassthrough(const char *cmdName, char *cmdline) |
3612 | 3631 | { |
@@ -4266,6 +4285,18 @@ static void cliSave(const char *cmdName, char *cmdline) |
4266 | 4285 | } |
4267 | 4286 | } |
4268 | 4287 |
|
| 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 | + |
4269 | 4300 | #if defined(USE_CUSTOM_DEFAULTS) |
4270 | 4301 | bool resetConfigToCustomDefaults(void) |
4271 | 4302 | { |
@@ -4723,7 +4754,7 @@ static void cliRateProfilesJson(const char *cmdName) |
4723 | 4754 | static void cliConfig(const char *cmdName, char *cmdline) |
4724 | 4755 | { |
4725 | 4756 | UNUSED(cmdline); |
4726 | | - |
| 4757 | + cliPrintLine("----- CONFIG START -----"); |
4727 | 4758 | cliPrintLine("{"); |
4728 | 4759 | for (uint32_t i = 0; i < valueTableEntryCount; i++) |
4729 | 4760 | { |
@@ -4751,6 +4782,7 @@ static void cliConfig(const char *cmdName, char *cmdline) |
4751 | 4782 | cliPrintf(",\"imuf\":\"%lu\"", imufCurrentVersion); |
4752 | 4783 | #endif |
4753 | 4784 | cliPrintLine("}"); |
| 4785 | + cliPrintLine("----- CONFIG END -----"); |
4754 | 4786 | } |
4755 | 4787 | #endif |
4756 | 4788 |
|
@@ -6785,6 +6817,7 @@ const clicmd_t cmdTable[] = { |
6785 | 6817 | CLI_COMMAND_DEF("escprog", "passthrough esc to serial", "<mode [sk/bl/ki/cc]> <index>", cliEscPassthrough), |
6786 | 6818 | #endif |
6787 | 6819 | CLI_COMMAND_DEF("exit", NULL, NULL, cliExit), |
| 6820 | + CLI_COMMAND_DEF("exit_no_reboot", NULL, NULL, cliExitNoReboot), |
6788 | 6821 | CLI_COMMAND_DEF("feature", "configure features", |
6789 | 6822 | "list\r\n" |
6790 | 6823 | "\t<->[name]", cliFeature), |
@@ -6845,6 +6878,7 @@ const clicmd_t cmdTable[] = { |
6845 | 6878 | CLI_COMMAND_DEF("rxfail", "show/set rx failsafe settings", NULL, cliRxFailsafe), |
6846 | 6879 | CLI_COMMAND_DEF("rxrange", "configure rx channel ranges", NULL, cliRxRange), |
6847 | 6880 | CLI_COMMAND_DEF("save", "save and reboot", NULL, cliSave), |
| 6881 | + CLI_COMMAND_DEF("save_no_reboot", "save without reboot", NULL, cliSaveNoReboot), |
6848 | 6882 | #ifdef USE_SDCARD |
6849 | 6883 | CLI_COMMAND_DEF("sd_info", "sdcard info", NULL, cliSdInfo), |
6850 | 6884 | #endif |
@@ -7113,6 +7147,9 @@ static bool cliProcessCustomDefaults(bool quiet) |
7113 | 7147 |
|
7114 | 7148 | void cliEnter(serialPort_t *serialPort) |
7115 | 7149 | { |
| 7150 | + if (cliExited) { // required for exit_no_reboot |
| 7151 | + return; |
| 7152 | + } |
7116 | 7153 | cliMode = true; |
7117 | 7154 | cliPort = serialPort; |
7118 | 7155 | setPrintfSerialPort(cliPort); |
|
0 commit comments