You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: doc/reference/kernel/other/event_manager.rst
+24-28Lines changed: 24 additions & 28 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -7,7 +7,7 @@ Event Manager
7
7
:local:
8
8
:depth: 2
9
9
10
-
The Event Manager is a piece of software that supports development of consistent, modular, event-based application.
10
+
The Event Manager is a piece of software that supports development of consistent, modular, event-based applications.
11
11
In an event-based application, parts of the application functionality are separated into isolated modules that communicate with each other using events.
12
12
Events are submitted by modules and other modules can subscribe and react to them.
13
13
The Event Manager acts as coordinator of the event-based communication.
@@ -35,33 +35,25 @@ Modules
35
35
Modules are separate source files that can subscribe to every defined event.
36
36
You can use events for communication between modules.
37
37
38
-
There is no limitation as to how many modules each module can subscribe to.
38
+
There is no limitation as to how many events each module can subscribe to.
39
39
An application can have as many modules as required.
40
40
41
-
The Event Manager provides API for subscribing modules to a specific events defined in the application.
42
-
When a module is subscribing to a specific event, it is called a listener module.
41
+
The Event Manager provides an API for subscribing modules to specific events defined in the application.
42
+
When a module subscribes to a specific event, it is called a listener module.
43
43
Every listener is identified by a unique name.
44
44
45
45
.. _event_manager_configuration:
46
46
47
47
Configuration
48
48
*************
49
49
50
-
To use Event Manager, you must enable the following Kconfig options:
50
+
To use Event Manager, enable it using the :kconfig:`CONFIG_EVENT_MANAGER` Kconfig option and initialize it in your :file:`main.c` file.
51
+
Initializing the Event Manager allows it to handle submitted events and deliver them to modules that subscribe to the specified event type.
51
52
52
-
* :kconfig:`CONFIG_EVENT_MANAGER` - This option enables the Event Manager.
53
-
* :kconfig:`CONFIG_LINKER_ORPHAN_SECTION_PLACE` - This option enables orphan memory sections used by the Event Manager.
54
-
Set this option to suppress warnings and errors.
55
-
56
-
Initializing the Event Manager
57
-
==============================
58
-
59
-
You must initialize the Event Manager in your :file:`main.c` file.
60
-
Initializing the Event Manger allows it to handle submitted events and deliver them to modules that subscribe to the specified event type.
61
-
62
-
To initialize the Event Manager, complete the following steps:
53
+
Complete the following steps:
63
54
64
-
1. Include :file:`event_manager.h` in your :file:`main.c` file.
55
+
1. Enable the :kconfig:`CONFIG_EVENT_MANAGER` Kconfig option.
56
+
#. Include :file:`event_manager.h` in your :file:`main.c` file.
65
57
#. Call :c:func:`event_manager_init()`.
66
58
67
59
.. _event_manager_implementing_events:
@@ -90,17 +82,17 @@ To create a header file for the event type you want to define:
90
82
91
83
.. code-block:: c
92
84
93
-
#include event_manager.h
85
+
#include <event_manager/event_manager.h>
94
86
95
-
#. Define the new event type by creating a structure that contains :c:struct:`event_header` ``header`` as the first field.
87
+
#. Define the new event type by creating a structure that contains an :c:struct:`event_header` named ``header`` as the first field.
96
88
#. Optionally, add additional custom data fields to the structure.
97
89
#. Declare the event type with the :c:macro:`EVENT_TYPE_DECLARE` macro, passing the name of the created structure as an argument.
98
90
99
91
The following code example shows a header file for the event type :c:struct:`sample_event`:
100
92
101
93
.. code-block:: c
102
94
103
-
#include <event_manager.h>
95
+
#include <event_manager/event_manager.h>
104
96
105
97
struct sample_event {
106
98
struct event_header header;
@@ -116,11 +108,11 @@ The following code example shows a header file for the event type :c:struct:`sam
116
108
In some use cases, the length of the data associated with an event may vary.
117
109
You can use the :c:macro:`EVENT_TYPE_DYNDATA_DECLARE` macro instead of :c:macro:`EVENT_TYPE_DECLARE` to declare an event type with variable data size.
118
110
In such case, add the data with the variable size as the last member of the event structure.
119
-
For example, you can add the variable size data to a previously defined event by applying the following change to the code:
111
+
For example, you can add variable sized data to the previously defined event by applying the following change to the code:
120
112
121
113
.. code-block:: c
122
114
123
-
#include <event_manager.h>
115
+
#include <event_manager/event_manager.h>
124
116
125
117
struct sample_event {
126
118
struct event_header header;
@@ -134,7 +126,7 @@ For example, you can add the variable size data to a previously defined event by
134
126
135
127
EVENT_TYPE_DYNDATA_DECLARE(sample_event);
136
128
137
-
In this example, the :c:struct:`event_dyndata` contains the following information:
129
+
In this example, the :c:struct:`event_dyndata` structure contains the following information:
138
130
139
131
* A zero-length array that is used as a buffer with variable size (:c:member:`event_dyndata.data`).
140
132
* A number representing the size of the buffer (:c:member:`event_dyndata.size`).
@@ -146,7 +138,7 @@ To create a source file for the event type you defined in the header file:
146
138
147
139
1. Include the header file for the new event type in your source file.
148
140
#. Define the event type with the :c:macro:`EVENT_TYPE_DEFINE` macro.
149
-
Passing the name of the event type as declared in the header and the additional parameters.
141
+
Pass the name of the event type as declared in the header along with additional parameters.
150
142
For example, you can provide a function that fills a buffer with a string version of the event data (used for logging).
151
143
152
144
The following code example shows a source file for the event type ``sample_event``:
@@ -160,15 +152,19 @@ The following code example shows a source file for the event type ``sample_event
log_sample_event, /* Function logging event data. */
170
163
NULL); /* No event info provided. */
171
164
165
+
.. note::
166
+
There is a deprecated way of logging Event Manager events by writing string to the provided buffer which is supported until NCS2.0.
167
+
172
168
Submitting an event
173
169
===================
174
170
@@ -311,7 +307,7 @@ Tracing hooks
311
307
312
308
Event Manager provides tracing hooks that you can use at run time to get information about Event Manager initialization, event submission, and event execution.
313
309
The hooks are provided as weak functions.
314
-
You can override them for interacting with custom profiler or for other purposes.
310
+
You can override them for interacting with a custom profiler or for other purposes.
315
311
316
312
The following weak functions are provided by Event Manager as hooks:
317
313
@@ -330,7 +326,7 @@ Shell integration
330
326
331
327
Shell integration is available to display additional information and to dynamically enable or disable logging for given event types.
332
328
333
-
The Event Manager is integrated with :ref:`shell_api` module.
329
+
The Event Manager is integrated with Zephyr's :ref:`shell_api` module.
334
330
When the shell is turned on, an additional subcommand set (:command:`event_manager`) is added.
335
331
336
332
This subcommand set contains the following commands:
@@ -354,7 +350,7 @@ This subcommand set contains the following commands:
0 commit comments