mcumgr: shell: Change command exit code from rc to ret
This prevents the shell command response code conflicting with the mcumgr response code, which are 2 distinct variable types Signed-off-by: Jamie McCrae <jamie.mccrae@nordicsemi.no>
This commit is contained in:
parent
4ef4944673
commit
41ecd5998f
2 changed files with 20 additions and 2 deletions
|
|
@ -2,7 +2,7 @@
|
|||
# Copyright Nordic Semiconductor ASA 2020-2022. All rights reserved.
|
||||
# SPDX-License-Identifier: Apache-2.0
|
||||
|
||||
config MCUMGR_CMD_SHELL_MGMT
|
||||
menuconfig MCUMGR_CMD_SHELL_MGMT
|
||||
bool "Mcumgr handlers for shell management"
|
||||
depends on SHELL
|
||||
select SHELL_BACKEND_DUMMY
|
||||
|
|
@ -22,3 +22,17 @@ config MCUMGR_CMD_SHELL_MGMT
|
|||
on a stack, by the mcumgr, so enabling MCUMGR_CMD_SHELL_MGMT and
|
||||
changes to the CONFIG_SHELL_CMD_BUFF_SIZE may increase stack size
|
||||
requirements.
|
||||
|
||||
if MCUMGR_CMD_SHELL_MGMT
|
||||
|
||||
config MCUMGR_CMD_SHELL_MGMT_LEGACY_RC_RETURN_CODE
|
||||
bool "Legacy behaviour: Use rc field for shell function return code"
|
||||
help
|
||||
Enabling this options brings back legacy behaviour where the shell
|
||||
return code is returned, incorrectly, in the rc field that was
|
||||
originally designated for returning SMP processing errors. When
|
||||
disabled, there will be an additional ret field which contains the
|
||||
shell command exit code, and rc will be used for SMP processing
|
||||
error codes.
|
||||
|
||||
endif # MCUMGR_CMD_SHELL_MGMT
|
||||
|
|
|
|||
|
|
@ -107,10 +107,14 @@ shell_mgmt_exec(struct mgmt_ctxt *ctxt)
|
|||
cmd_out.value = shell_get_output(&cmd_out.len);
|
||||
|
||||
/* Key="o"; value=<command-output> */
|
||||
/* Key="rc"; value=<status> */
|
||||
/* Key="ret"; value=<status>, or rc if legacy option enabled */
|
||||
ok = zcbor_tstr_put_lit(zse, "o") &&
|
||||
zcbor_tstr_encode(zse, &cmd_out) &&
|
||||
#ifdef CONFIG_MCUMGR_CMD_SHELL_MGMT_LEGACY_RC_RETURN_CODE
|
||||
zcbor_tstr_put_lit(zse, "rc") &&
|
||||
#else
|
||||
zcbor_tstr_put_lit(zse, "ret") &&
|
||||
#endif
|
||||
zcbor_int32_put(zse, rc);
|
||||
|
||||
zcbor_map_end_decode(zsd);
|
||||
|
|
|
|||
Loading…
Reference in a new issue