Skip to content

Commit 77d6b27

Browse files
committed
samples: zbus: Adjust runtime observers sample
Reverse the changes the affected API and add adjust the sample to the new dynamic and static variations. Signed-off-by: Rodrigo Peixoto <[email protected]>
1 parent 33996ab commit 77d6b27

File tree

2 files changed

+34
-5
lines changed

2 files changed

+34
-5
lines changed

samples/subsys/zbus/runtime_obs_registration/sample.yaml

+29-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ tests:
1111
type: multi_line
1212
ordered: false
1313
regex:
14-
- "I: System started"
14+
- "I: System started. Runtime observers statically allocated"
1515
- "I: Activating filter"
1616
- "I: Deactivating filter"
1717
- "I: Bypass filter"
@@ -27,3 +27,31 @@ tests:
2727
- "I: --> Consuming data: Acc x=9, y=9, z=9"
2828
- "I: --> Consuming data: Acc x=10, y=10, z=10"
2929
tags: zbus
30+
sample.zbus.runtime_os_registration_dynamic_alloc:
31+
min_ram: 16
32+
integration_platforms:
33+
- qemu_x86
34+
arch_exclude: nios2
35+
harness: console
36+
harness_config:
37+
type: multi_line
38+
ordered: false
39+
regex:
40+
- "I: System started. Runtime observers dynamically allocated"
41+
- "I: Activating filter"
42+
- "I: Deactivating filter"
43+
- "I: Bypass filter"
44+
- "I: Disable bypass filter"
45+
- "I: >-- Raw data fetched"
46+
- "I: -|- Filtering data"
47+
- "I: --> Consuming data: Acc x=0, y=0, z=0"
48+
- "I: --> Consuming data: Acc x=2, y=2, z=2"
49+
- "I: --> Consuming data: Acc x=4, y=4, z=4"
50+
- "I: --> Consuming data: Acc x=6, y=6, z=6"
51+
- "I: --> Consuming data: Acc x=7, y=7, z=7"
52+
- "I: --> Consuming data: Acc x=8, y=8, z=8"
53+
- "I: --> Consuming data: Acc x=9, y=9, z=9"
54+
- "I: --> Consuming data: Acc x=10, y=10, z=10"
55+
tags: zbus
56+
extra_configs:
57+
- CONFIG_HEAP_MEM_POOL_SIZE=1024

samples/subsys/zbus/runtime_obs_registration/src/main.c

+5-4
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,23 @@ ZBUS_SUBSCRIBER_DEFINE(state_change_sub, 5);
4141

4242
int main(void)
4343
{
44-
LOG_INF("System started");
44+
LOG_INF("System started. Runtime observers %s allocated",
45+
IS_ENABLED(CONFIG_ZBUS_RUNTIME_OBSERVERS_NODE_ALLOC_DYNAMIC) ? "dynamically"
46+
: "statically");
4547

4648
const struct zbus_channel *chan;
47-
struct zbus_observer_node obs_node;
4849

4950
while (1) {
5051
LOG_INF("Activating filter");
51-
zbus_chan_add_obs(&raw_data_chan, &filter_lis, &obs_node, K_MSEC(200));
52+
zbus_chan_add_obs(&raw_data_chan, &filter_lis, K_MSEC(200));
5253

5354
zbus_sub_wait(&state_change_sub, &chan, K_FOREVER);
5455

5556
LOG_INF("Deactivating filter");
5657
zbus_chan_rm_obs(&raw_data_chan, &filter_lis, K_MSEC(200));
5758

5859
LOG_INF("Bypass filter");
59-
zbus_chan_add_obs(&raw_data_chan, &consumer_sub, &obs_node, K_MSEC(200));
60+
zbus_chan_add_obs(&raw_data_chan, &consumer_sub, K_MSEC(200));
6061

6162
zbus_sub_wait(&state_change_sub, &chan, K_FOREVER);
6263

0 commit comments

Comments
 (0)