Part 1
요약·해설
Settings initialization, handler registration, direct/subtree load와 persistent storage export를 다룹니다.
alpha · alpha/beta
Persistent key-value
Load · Save · Delete
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
202FAFA5966FBAE1D4FB57FD5A81E9626739C8CCF58B2C41187D3530A4C77BDA
.. zephyr:code-sample:: settings
:name: Settings API
:relevant-api: settings settings_rt settings_name_proc
Load and save configuration values using the settings API.
Overview
********
This is a simple application demonstrating use of the settings runtime
configuration module. In this application some configuration values are loaded
from persistent storage and exported to persistent storage using different
settings method. The example shows how to implement module handlers, how to
register them.
Requirements
************
* A board with settings support, for instance: nrf52840dk/nrf52840
* Or qemu_x86 target
Building and Running
********************
This sample can be found under :zephyr_file:`samples/subsys/settings` in
the Zephyr tree.
The sample can be build for several platforms, the following commands build the
application for the qemu_x86.
.. zephyr-app-commands::
:zephyr-app: samples/subsys/settings
:host-os: unix
:board: qemu_x86
:goals: run
:compact:
After running the image to the board the output on the console shows the
settings manipulation messages.
Sample Output
=============
.. code-block:: console
***** Booting Zephyr OS build v2.1.0-rc1-123-g41091eb1d5e0 *****
*** Settings usage example ***
settings subsys initialization: OK.
subtree <alpha> handler registered: OK
subtree <alpha/beta> has static handler
##############
# iteration 0
##############
=================================================
basic load and save using registered handlers
load all key-value pairs using registered handlers
loading all settings under <beta> handler is done
loading all settings under <alpha> handler is done
save <alpha/beta/voltage> key directly: OK.
load <alpha/beta> key-value pairs using registered handlers
<alpha/beta/voltage> = -3025
loading all settings under <beta> handler is done
save all key-value pairs using registered handlers
export keys under <beta> handler
export keys under <alpha> handler
load all key-value pairs using registered handlers
export keys under <beta> handler
export keys under <alpha> handler
=================================================
loading subtree to destination provided by the caller
direct load: <alpha/length/2>
direct load: <alpha/length/1>
direct load: <alpha/length>
direct.length = 100
direct.length_1 = 41
direct.length_2 = 59
=================================================
Delete a key-value pair
immediate load: OK.
<alpha/length> value exist in the storage
delete <alpha/length>: OK.
Can't to load the <alpha/length> value as expected
=================================================
Service a key-value pair without dedicated handlers
<gamma> = 0 (default)
save <gamma> key directly: OK.
...
Part 3
한국어 전문 번역
개요
Settings runtime configuration module 사용법을 보여 주는 간단한 application입니다. 여러 configuration value를 persistent storage에서 load하고, 서로 다른 settings method를 사용해 다시 persistent storage로 export합니다. Module handler를 구현하고 등록하는 방법도 보여 줍니다.
요구 사항
nrf52840dk/nrf52840처럼 settings를 지원하는 board- 또는
qemu_x86target
빌드 및 실행
Sample은 Zephyr tree의 samples/subsys/settings에 있습니다. 여러 platform에서 build할 수 있으며 다음 command는 qemu_x86에서 application을 build하고 실행합니다.
west build -b qemu_x86 samples/subsys/settings
west build -t run
Console output은 settings subsystem 초기화, static·registered handler, direct save/load, subtree load, key delete와 handler 없는 key service를 순서대로 보여 줍니다.
샘플 출력
먼저 alpha handler를 등록하고 alpha/beta static handler를 확인합니다. Registered handler로 전체 key-value pair를 load한 뒤 alpha/beta/voltage를 직접 저장하고 다시 읽어 -3025를 확인합니다.
다음에는 handler가 export한 모든 key를 저장·load하고, caller가 제공한 destination으로 alpha/length subtree와 하위 key를 직접 읽습니다. Base length 100과 하위 값 41·59가 표시됩니다.
Immediate load로 alpha/length가 존재함을 확인한 뒤 삭제하고 더는 load되지 않는지 검증합니다. 마지막에는 dedicated handler가 없는 gamma key의 기본값 0을 읽고 direct save합니다.
***** Booting Zephyr OS build v2.1.0-rc1-123-g41091eb1d5e0 *****
*** Settings usage example ***
settings subsys initialization: OK.
subtree <alpha> handler registered: OK
subtree <alpha/beta> has static handler
##############
# iteration 0
##############
=================================================
basic load and save using registered handlers
load all key-value pairs using registered handlers
loading all settings under <beta> handler is done
loading all settings under <alpha> handler is done
save <alpha/beta/voltage> key directly: OK.
load <alpha/beta> key-value pairs using registered handlers
<alpha/beta/voltage> = -3025
loading all settings under <beta> handler is done
save all key-value pairs using registered handlers
export keys under <beta> handler
export keys under <alpha> handler
load all key-value pairs using registered handlers
export keys under <beta> handler
export keys under <alpha> handler
=================================================
loading subtree to destination provided by the caller
direct load: <alpha/length/2>
direct load: <alpha/length/1>
direct load: <alpha/length>
direct.length = 100
direct.length_1 = 41
direct.length_2 = 59
=================================================
Delete a key-value pair
immediate load: OK.
<alpha/length> value exist in the storage
delete <alpha/length>: OK.
Can't to load the <alpha/length> value as expected
=================================================
Service a key-value pair without dedicated handlers
<gamma> = 0 (default)
save <gamma> key directly: OK.
...
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.