Skip to content

Commit

Permalink
doc: document config min/max specifier
Browse files Browse the repository at this point in the history
Signed-off-by: Markus Klotzbuecher <mk@mkio.de>
  • Loading branch information
kmarkus committed Nov 24, 2019
1 parent 5541ba7 commit 7bad67d
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
3 changes: 3 additions & 0 deletions API_Changes.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ This file tracks user visible API changes.

## Unreleased

- config: add `min`/`max` specifiers for introducing constraints such
as optional or mandatory configs.

- struct ubx_block: added attributes variable (`attrs`) and defined
first block attributes (`BLOCK_ATTR_TRIGGER` and
`BLOCK_ATTR_ACTIVE`). These will be used by tools such as
Expand Down
38 changes: 38 additions & 0 deletions docs/user/developing_blocks.rst
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,44 @@ type “struct random_config”.
**Note:**: custom types like ``struct random_config`` must be registered
with the system. (see section “declaring types”)

To reduce boilerplate validation code in blocks, ``min`` and ``max``
attributes can be used to define permitted length of configuratio
values. For example:

.. code:: c
ubx_config_t rnd_config[] = {
{ .name="min_max_config", .type_name = "struct random_config", .min=1, .max=1 },
{ NULL },
};
Would require that this block must be configured with exactly one
``struct random_config`` value. Checking will take place before the
transition to `inactive` (i.e. before ``init``).

In fewer cases, configuration takes place in state ``inactive`` and
must be checked before the transition to ``active``. That can be
achieve by defining the config attribute ``CONFIG_ATTR_CHECKLATE``.

Legal values of ``min`` and ``max`` are summarized below:

+-----+----------------+------------------------+
| min | max | result |
+=====+================+========================+
| 0 | 0 | no checking (disabled) |
+-----+----------------+------------------------+
| 0 | 1 | optional config |
+-----+----------------+------------------------+
| 1 | 1 | mandatory config |
+-----+----------------+------------------------+
| 0 | CONFIG_LEN_MAX | zero to many |
+-----+----------------+------------------------+
| 1 | undefined | zero to many |
+-----+----------------+------------------------+
| N | N | exactly N |
+-----+----------------+------------------------+


Declaring ports
---------------

Expand Down

0 comments on commit 7bad67d

Please sign in to comment.