Part 1
요약·해설
argv request, o/ret response와 옛 rc 호환 option을 설명합니다.
9
argv[]
o + ret
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
561FAE65B8054921730AD8CB7B3DCF28E810505FA8FF6BDCE13771E542E9276C
.. _mcumgr_smp_group_9:
Shell management
################
Shell management allows passing commands to the shell subsystem over the SMP
protocol.
Shell management group defines following commands:
.. table::
:align: center
+-------------------+-----------------------------------------------+
| ``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 over SMP.
Shell command line execute request
==================================
Execute command request header:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``2`` | ``9`` | ``0`` |
+--------+--------------+----------------+
CBOR data of request:
.. code-block:: none
{
(str)"argv" : [
(str)<cmd>
(str,opt)<arg>
...
]
}
where:
.. table::
:align: center
+-----------------------+---------------------------------------------------+
| "argv" | 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:
.. table::
:align: center
+--------+--------------+----------------+
| ``OP`` | ``Group ID`` | ``Command ID`` |
+========+==============+================+
| ``3`` | ``9`` | ``0`` |
+--------+--------------+----------------+
CBOR data of successful response:
.. code-block:: none
{
(str)"o" : (str)
(str)"ret" : (int)
}
In case of error the CBOR data takes the form:
.. tabs::
.. group-tab:: SMP version 2
.. code-block:: none
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}
.. group-tab:: SMP version 1 (and non-group SMP version 2)
.. code-block:: none
{
(str)"rc" : (int)
}
where:
.. table::
:align: center
+------------------+-------------------------------------------------------------------------+
| "o" | command output. |
+------------------+-------------------------------------------------------------------------+
| "ret" | return code from shell command execution. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "group" | :c:enum:`mcumgr_group_t` group of the group-based error code. Only |
| | appears if an error is returned when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "err" -> "rc" | contains the index of the group-based error code. Only appears if |
| | non-zero (error condition) when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
| "rc" | :c:enum:`mcumgr_err_t` only appears if non-zero (error condition) when |
| | using SMP version 1 or for SMP errors when using SMP version 2. |
+------------------+-------------------------------------------------------------------------+
.. 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 :kconfig:option:`CONFIG_MCUMGR_GRP_SHELL_LEGACY_RC_RETURN_CODE`
Part 3
한국어 전문 번역
Shell management를 사용하면 SMP protocol을 통해 command를 shell subsystem으로 전달할 수 있습니다.
Shell management group은 다음 command를 정의합니다.
| Command ID | Command description |
|---|---|
| 0 | Shell command line 실행 |
Shell command line 실행
이 command는 shell에 직접 입력하는 것과 비슷한 방식으로 command line을 실행합니다. 다만 request와 response 모두 SMP를 통해 전달됩니다.
Shell command line 실행 request
Execute command request header는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 2 | 9 | 0 |
Request의 CBOR data는 다음과 같습니다.
{
(str)"argv" : [
(str)<cmd>
(str,opt)<arg>
...
]
}
Request field의 의미는 다음과 같습니다.
argv | Command와 argument를 나타내는 string으로 구성된 array입니다. |
<cmd> | 실행할 command입니다. |
<arg> | Command에 전달할 선택적인 argument입니다. |
Shell command line 실행 response
Command line execute response header field는 다음과 같습니다.
| OP | Group ID | Command ID |
|---|---|---|
| 3 | 9 | 0 |
성공한 response의 CBOR data는 다음과 같습니다.
{
(str)"o" : (str)
(str)"ret" : (int)
}
Error가 발생하면 CBOR data는 다음 형식입니다.
{
(str)"err" : {
(str)"group" : (uint)
(str)"rc" : (uint)
}
}{
(str)"rc" : (int)
}Response field의 의미는 다음과 같습니다.
o | Command output입니다. |
ret | Shell command 실행의 return code입니다. |
err → group | Group 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다. |
err → rc | Group 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다. |
rc | mcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다. |
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.