This is the documentation for the latest (main) development branch of Zephyr. If you are looking for the documentation of previous releases, use the drop-down menu on the left and select the desired version.

Shell management

Shell management allows to pass commands to shell subsystem with use of SMP protocol.

Shell management group defines following commands:

Command ID

Command description

0

Shell command line execute

Shell command line execute

The command allows to execute command line in a similar way to typing it into a shell, but both a request and a response are transported with use of SMP.

Shell command line execute request

Execute command request header:

OP

Group ID

Command ID

2

9

0

CBOR data of request:

{
    (str)"argv"     : [
        (str)<cmd>
        (str,opt)<arg>
        ...
    ]
}

where:

“argv”

is array consisting of strings representing command and its arguments

<cmd>

command to be executed

<arg>

optional arguments to command

Shell command line execute response

Command line execute response header fields:

OP

Group ID

Command ID

3

9

0

CBOR data of successful response:

{
    (str)"o"            : (str)
    (str)"ret"          : (int)
}

In case of error the CBOR data takes form:

{
    (str)"rc"           : (int)
}

where:

“rc”

Status/error codes in responses (only present if an error occurred)

“o”

command output

“ret”

return code from shell command execution

In case when “rc” is not 0, success, the other fields will not appear.

Note

In older versions of Zephyr, “rc” was used for both the mcumgr status code and shell command execution return code, this legacy behaviour can be restored by enabling CONFIG_MCUMGR_CMD_SHELL_MGMT_LEGACY_RC_RETURN_CODE