services/device_mgmt/smp_groups/smp_group_9.html · services/device_mgmt/smp_groups/smp_group_9.rst 공식 원문 ↗

Zephyr 3.7.0 · SMP Groups

SMP Group 9 · Shell Management

Command와 argument array를 SMP로 보내고 shell output과 실행 return code를 response로 받습니다.

Official pathservices/device_mgmt/smp_groups/smp_group_9.html
Source fileservices/device_mgmt/smp_groups/smp_group_9.rst
Source versionZephyr 3.7.0
TranslationFull · reviewed

본문 기준: Zephyr 3.7.0 LTS3 · 이후 유지보수 패치는 별도입니다.

Part 1

요약·해설

argv request, o/ret response와 옛 rc 호환 option을 설명합니다.

Group ID

9

Request

argv[]

Response

o + ret

Part 2

접을 수 있는 영어 원문 전체

영어 원문 전체 펼치기
원문 SHA-256 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
Command IDCommand description
0Shell command line 실행

Shell command line 실행

이 command는 shell에 직접 입력하는 것과 비슷한 방식으로 command line을 실행합니다. 다만 request와 response 모두 SMP를 통해 전달됩니다.

Shell command line 실행 request

Execute command request header는 다음과 같습니다.

Command execute request header
OPGroup IDCommand ID
290

Request의 CBOR data는 다음과 같습니다.

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

Request field의 의미는 다음과 같습니다.

Command execute request field
argvCommand와 argument를 나타내는 string으로 구성된 array입니다.
<cmd>실행할 command입니다.
<arg>Command에 전달할 선택적인 argument입니다.

Shell command line 실행 response

Command line execute response header field는 다음과 같습니다.

Command execute response header
OPGroup IDCommand ID
390

성공한 response의 CBOR data는 다음과 같습니다.

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

Error가 발생하면 CBOR data는 다음 형식입니다.

SMP version 2
{
    (str)"err" : {
        (str)"group"    : (uint)
        (str)"rc"       : (uint)
    }
}
SMP version 1 및 group 기반이 아닌 SMP version 2
{
    (str)"rc"       : (int)
}

Response field의 의미는 다음과 같습니다.

Command execute response field
oCommand output입니다.
retShell command 실행의 return code입니다.
err → groupGroup 기반 error code의 mcumgr_group_t group입니다. SMP version 2를 사용하며 error가 반환될 때만 나타납니다.
err → rcGroup 기반 error code의 index입니다. SMP version 2에서 값이 0이 아닌 error condition일 때만 나타납니다.
rcmcumgr_err_t입니다. SMP version 1에서 값이 0이 아닌 error condition일 때, 또는 SMP version 2에서 SMP error가 발생할 때만 나타납니다.

Source

출처

영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.