-
Notifications
You must be signed in to change notification settings - Fork 2.1k
sys/runtime_config: add runtime configuration #22092
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
LasseRosenow
wants to merge
99
commits into
RIOT-OS:master
Choose a base branch
from
LasseRosenow:pr-runtime-configuration-registry-core
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
99 commits
Select commit
Hold shift + click to select a range
1cf15fc
sys/registry: add runtime config registry core
LasseRosenow a181b44
examples: add registry_core example
LasseRosenow fdb64fa
Example: Fix readme and make static
LasseRosenow 84acaa1
Remove guards and rename indices to ids
LasseRosenow 19f606f
Apply suggestions from code review
LasseRosenow a8899e9
Update examples/advanced/registry/registry_core/main.c
LasseRosenow cf78c9e
Update sys/include/registry.h
LasseRosenow c379121
Apply suggestions from code review
LasseRosenow e10c66b
Fix doxygen modules
LasseRosenow 99b6354
Fix compilation errors
LasseRosenow a05fb4f
Document registry_apply_cb_scope_t
LasseRosenow d46d812
registry_instance_t => registry_schema_instance_t
LasseRosenow 3a9ee36
Rename "user" in documentation to "consumer"
LasseRosenow ff85ad3
Add description field to registry_schema_instance_t
LasseRosenow a13fbb2
Improve documentation and rename mapping to get_parameter_value_from_…
LasseRosenow 4e51e40
Add autogen and fix doxygen groups
LasseRosenow 0fe8b8a
Update sys/include/registry.h
LasseRosenow 81931b9
Fix makefiles
LasseRosenow 5584698
Remove makefile.include
LasseRosenow 782014d
Remove useless guards in schema c files
LasseRosenow 3b7854c
Improve apply_callback
LasseRosenow 2f4ddef
Add basic doc WIP
LasseRosenow 438e32a
Apply suggestions from code review
LasseRosenow 23f0208
Mark function as _ static
LasseRosenow 6661ecb
Apply suggestions from code review
LasseRosenow ca93e97
Fix
LasseRosenow 0012d43
Update sys/registry/registry.c
LasseRosenow 02147fe
Fix
LasseRosenow 4c20b3d
Fix Kconfig
LasseRosenow c40bec5
Fix util
LasseRosenow dafe60f
Fix string format white space
LasseRosenow 428b22a
Use fmt.h in util.c
LasseRosenow f05c9f8
Fix util.c overflow
LasseRosenow 5da6fa4
Fix rgb-led description
LasseRosenow ee87700
Fix schema description fields
LasseRosenow 2977a4c
Fix debug include and define order
LasseRosenow 7b96dcc
Fix comment for memcpy
LasseRosenow fe34b9f
add auto_init priority define
LasseRosenow 33fa046
Fix doc
LasseRosenow 163899c
Add tests
LasseRosenow 08e36af
Cleanup tests
LasseRosenow 4202adc
Fix documentation
LasseRosenow 76a846b
Fix static tests
LasseRosenow ad0ff3f
Improve documentation
LasseRosenow 6556394
Improve doc
LasseRosenow d61c699
Fix static test
LasseRosenow a342161
Improve doc
LasseRosenow d66606a
Fix documentation
LasseRosenow 223d8e6
Rename "registry" to "runtime_config"
LasseRosenow cd0b64f
Fix
LasseRosenow f1dafd1
Fix
LasseRosenow 3181834
Improve documentation
LasseRosenow 80abe32
Apply suggestions from code review
LasseRosenow 104a5e4
Fix doc
LasseRosenow 8351aae
Fix
LasseRosenow 8ed2ed6
Apply suggestions from code review
LasseRosenow faa6840
Clean
LasseRosenow 3837945
Fix looooooong liiiiiines
LasseRosenow f7437e3
Fix more old style comments
LasseRosenow c576421
Rename opaque => bytes
LasseRosenow b4f76c2
Improve doc
LasseRosenow 90851da
Update sys/runtime_config/runtime_config.c
LasseRosenow 4ff4e3c
Format
LasseRosenow 5991db6
Improve documentation
LasseRosenow 7534ffd
Improve doc
LasseRosenow 313a167
Add documentation of missing features
LasseRosenow 413f911
Fix images
LasseRosenow 8538b2a
Improve doc
LasseRosenow 4f90b2f
Merge doc.md with runtime_config.h
LasseRosenow 69c9d82
sys/runtime_config: fix namespace description
LasseRosenow 7a0852f
sys/runtime_config: Remove wrong const and fix castings
LasseRosenow 26fd28f
sys/runtime_config: refactor tree_traversal_depth calculation and use…
LasseRosenow 3b452bf
tests: fix rename
LasseRosenow b67b636
Rename "Runtime config" to "Runtime configuration"
LasseRosenow 6b393bb
examples/runtime_config: use pointer instead of copying struct
LasseRosenow e91822d
sys/runtime_config: prefix RUNTIME_CONFIG_UTIL_FORMAT_FLOAT_PRECISION…
LasseRosenow 6a3acca
sys/runtime_config: make util.c more readable
LasseRosenow a31f21a
sys/runtime_config: Add float precision macro to kconfig
LasseRosenow 3721346
sys/runtime_config: rename config macros to be prefixed with CONFIG_
LasseRosenow 0bf7ffd
sys/runtime_config: fix doc.md security warning
LasseRosenow f652556
test/runtime_config: mark files as autogenerated
LasseRosenow 2d9e780
Update sys/runtime_config/doc.md
LasseRosenow dc75328
Update sys/runtime_config/doc.md
LasseRosenow ed3685b
Update sys/runtime_config/doc.md
LasseRosenow e081f61
sys/runtime_config: doc: mark config managers as not yet existing
LasseRosenow c805af9
Merge branch 'pr-runtime-configuration-registry-core' of github.com:L…
LasseRosenow bff7aa2
sys/runtime_config: Improve docs
LasseRosenow 90682ba
sys/runtime_config: improve docs
LasseRosenow 9253b1b
sys/runtime_config: mark input values as not NULL
LasseRosenow e528421
sys/runtime_config: Replace remaining "config" with "configuration" a…
LasseRosenow 5c59fcc
doc: fix runtime_config images
LasseRosenow d80b375
Fix
LasseRosenow 55e77cb
Fix
LasseRosenow 10e27ae
Remove unused error code
LasseRosenow 9abf919
sys/runtime_config: rename _export to _traverse_config_tree
LasseRosenow ba8e488
fix
LasseRosenow 3043d2f
Fix
LasseRosenow 3e656fb
Fix errors in tests
LasseRosenow ec324e6
Fix float test
LasseRosenow File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
examples/advanced/runtime_config/runtime_config_core/Makefile
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| # name of the application | ||
| APPLICATION = runtime_config_example_core | ||
|
|
||
| # If no BOARD is found in the environment, use this default: | ||
| BOARD ?= native | ||
|
|
||
| # This has to be the absolute path to the RIOT base directory: | ||
| RIOTBASE ?= $(CURDIR)/../../../.. | ||
|
|
||
| # required modules | ||
| # enable board_led schema (sys/board_led) of the Runtime configuration module | ||
| USEMODULE += runtime_config_namespace_sys_board_led | ||
| # enable the ztimer to turn the led on and off every second | ||
| USEMODULE += ztimer_sec | ||
|
|
||
| # Comment this out to disable code in RIOT that does safety checking | ||
| # which is not needed in a production environment but helps in the | ||
| # development process: | ||
| DEVELHELP ?= 1 | ||
|
|
||
| # Change this to 0 show compiler invocation lines by default: | ||
| QUIET ?= 1 | ||
|
|
||
| include $(RIOTBASE)/Makefile.include |
14 changes: 14 additions & 0 deletions
14
examples/advanced/runtime_config/runtime_config_core/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Runtime Configuration Core | ||
|
|
||
| This application demonstrates the most basic usage of the `Runtime configuration` module. | ||
| It implements a BOARD LED schema and continuously changes its value every second. | ||
|
|
||
| ## Usage | ||
|
|
||
| Simply build and flash the application for your target board: | ||
|
|
||
| ```shell | ||
| BOARD=YOUR_BOARD_NAME_HERE make flash term | ||
| ``` | ||
|
|
||
| Now you should see the terminal continuously print out different LED states. |
106 changes: 106 additions & 0 deletions
106
examples/advanced/runtime_config/runtime_config_core/main.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| /* | ||
| * SPDX-FileCopyrightText: 2023-2026 Lasse Rosenow <lasse.rosenow@haw-hamburg.de> | ||
| * SPDX-FileCopyrightText: 2023-2026 HAW Hamburg | ||
| * SPDX-License-Identifier: LGPL-2.1-only | ||
| */ | ||
|
|
||
| /** | ||
| * @ingroup examples | ||
| * @{ | ||
| * | ||
| * @file | ||
| * @brief Runtime configuration core minimal example application to demonstrate | ||
| * how to use the "Runtime configuration" module without any of its extensions. | ||
| * | ||
| * @author Lasse Rosenow <lasse.rosenow@haw-hamburg.de> | ||
| * | ||
| * @} | ||
| */ | ||
|
|
||
| #include <string.h> | ||
| #include <stdio.h> | ||
| #include <unistd.h> | ||
|
|
||
| #include "periph_cpu.h" | ||
| #include "led.h" | ||
| #include "board.h" | ||
| #include "runtime_config.h" | ||
| #include "runtime_config/namespace/sys.h" | ||
| #include "runtime_config/namespace/sys/board_led.h" | ||
| #include "ztimer.h" | ||
|
|
||
| /* This callback gets called, when new configurations shall be applied. | ||
| * If interacting with configurations of drivers then this callback should be | ||
| * implemented by the driver itself. For custom application logic, we need to | ||
| * define this for ourselves. */ | ||
| static runtime_config_error_t board_led_instance_apply_cb( | ||
| const runtime_config_group_or_parameter_id_t *group_or_parameter_id, | ||
| const runtime_config_schema_instance_t *instance) | ||
| { | ||
| const runtime_config_sys_board_led_instance_t *instance_data = (const runtime_config_sys_board_led_instance_t *)instance->data; | ||
|
|
||
| /* Either apply all parameters of the instance or only the given parameter. | ||
| * For a single LED there is no difference as it only has one parameter. */ | ||
| if ((group_or_parameter_id == NULL) || | ||
| (*group_or_parameter_id == RUNTIME_CONFIG_SYS_BOARD_LED_ENABLED)) { | ||
| /* Get the correct field from the instance_data variable */ | ||
| bool led_state = instance_data->enabled; | ||
| /* Turn the LED on or off depending on the led_state */ | ||
| if (led_state == true) { | ||
| /* This is the apply_cb function of instance 0, so we toggle LED 0 as well */ | ||
|
mguetschow marked this conversation as resolved.
|
||
| LED_ON(0); | ||
|
mguetschow marked this conversation as resolved.
|
||
| } | ||
| else { | ||
| LED_OFF(0); | ||
| } | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
|
|
||
| /* This belongs into the BOARD or Driver for example */ | ||
| static runtime_config_sys_board_led_instance_t board_led_instance_data = { | ||
| .enabled = 0, | ||
| }; | ||
|
|
||
| static runtime_config_schema_instance_t board_led_instance = { | ||
| .data = &board_led_instance_data, | ||
| .apply_cb = &board_led_instance_apply_cb, | ||
| }; | ||
|
|
||
| /* This belongs into our main application */ | ||
| int main(void) | ||
| { | ||
| runtime_config_init(); | ||
|
|
||
| /* init schemas */ | ||
| runtime_config_add_schema_instance(&runtime_config_sys_board_led, &board_led_instance); | ||
|
|
||
| bool board_led_enabled = false; | ||
|
|
||
| while (true) { | ||
| /* Invert the BOARD LED, to make it turn on and off on each subsequent cycle */ | ||
| board_led_enabled = !board_led_enabled; | ||
|
|
||
| /* Create runtime_config_node_t for the board_led_parameter */ | ||
| const runtime_config_node_t parameter_node = { | ||
| .type = RUNTIME_CONFIG_NODE_PARAMETER, | ||
| .value.parameter = { | ||
| .instance = &board_led_instance, | ||
| .parameter = &runtime_config_sys_board_led_enabled, | ||
| }, | ||
| }; | ||
|
|
||
| /* Set new runtime configuration value */ | ||
| runtime_config_set(¶meter_node, &board_led_enabled, sizeof(board_led_enabled)); | ||
|
|
||
| /* Apply the runtime configuration value to change the LED state | ||
| * (in this case calls the apply_cb function: "board_led_instance_apply_cb") */ | ||
| runtime_config_apply(¶meter_node); | ||
|
|
||
| /* Sleep for 1 second and then do it again*/ | ||
| ztimer_sleep(ZTIMER_SEC, 1); | ||
| } | ||
|
|
||
| return 0; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.