Skip to content

Commit 67d24b9

Browse files
rodrigopexkartben
authored andcommitted
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 <rodrigopex@gmail.com>
1 parent 6d0760a commit 67d24b9

File tree

2 files changed

+50
-19
lines changed

2 files changed

+50
-19
lines changed

samples/subsys/zbus/runtime_obs_registration/sample.yaml

Lines changed: 45 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,49 @@ tests:
1010
type: multi_line
1111
ordered: false
1212
regex:
13-
- "I: System started"
14-
- "I: Activating filter"
15-
- "I: Deactivating filter"
16-
- "I: Bypass filter"
17-
- "I: Disable bypass filter"
18-
- "I: >-- Raw data fetched"
19-
- "I: -|- Filtering data"
20-
- "I: --> Consuming data: Acc x=0, y=0, z=0"
21-
- "I: --> Consuming data: Acc x=2, y=2, z=2"
22-
- "I: --> Consuming data: Acc x=4, y=4, z=4"
23-
- "I: --> Consuming data: Acc x=6, y=6, z=6"
24-
- "I: --> Consuming data: Acc x=7, y=7, z=7"
25-
- "I: --> Consuming data: Acc x=8, y=8, z=8"
26-
- "I: --> Consuming data: Acc x=9, y=9, z=9"
27-
- "I: --> Consuming data: Acc x=10, y=10, z=10"
13+
- ".*I: System started, runtime observers statically allocated"
14+
- ".*I: Activating filter"
15+
- ".*I: Deactivating filter"
16+
- ".*I: Bypass filter"
17+
- ".*I: Disable bypass filter"
18+
- ".*I: >-- Raw data fetched"
19+
- ".*I: -|- Filtering data"
20+
- ".*I: --> Consuming data: Acc x=0, y=0, z=0"
21+
- ".*I: --> Consuming data: Acc x=2, y=2, z=2"
22+
- ".*I: --> Consuming data: Acc x=4, y=4, z=4"
23+
- ".*I: --> Consuming data: Acc x=6, y=6, z=6"
24+
- ".*I: --> Consuming data: Acc x=7, y=7, z=7"
25+
- ".*I: --> Consuming data: Acc x=8, y=8, z=8"
26+
- ".*I: --> Consuming data: Acc x=9, y=9, z=9"
27+
- ".*I: --> Consuming data: Acc x=10, y=10, z=10"
2828
tags: zbus
29+
extra_configs:
30+
- CONFIG_ZBUS_PREFER_DYNAMIC_ALLOCATION=n
31+
sample.zbus.runtime_os_registration_dynamic_alloc:
32+
min_ram: 16
33+
integration_platforms:
34+
- qemu_x86
35+
arch_exclude: nios2
36+
harness: console
37+
harness_config:
38+
type: multi_line
39+
ordered: false
40+
regex:
41+
- ".*I: System started, runtime observers dynamically allocated"
42+
- ".*I: Activating filter"
43+
- ".*I: Deactivating filter"
44+
- ".*I: Bypass filter"
45+
- ".*I: Disable bypass filter"
46+
- ".*I: >-- Raw data fetched"
47+
- ".*I: -|- Filtering data"
48+
- ".*I: --> Consuming data: Acc x=0, y=0, z=0"
49+
- ".*I: --> Consuming data: Acc x=2, y=2, z=2"
50+
- ".*I: --> Consuming data: Acc x=4, y=4, z=4"
51+
- ".*I: --> Consuming data: Acc x=6, y=6, z=6"
52+
- ".*I: --> Consuming data: Acc x=7, y=7, z=7"
53+
- ".*I: --> Consuming data: Acc x=8, y=8, z=8"
54+
- ".*I: --> Consuming data: Acc x=9, y=9, z=9"
55+
- ".*I: --> Consuming data: Acc x=10, y=10, z=10"
56+
tags: zbus
57+
extra_configs:
58+
- CONFIG_HEAP_MEM_POOL_SIZE=1024

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

Lines changed: 5 additions & 4 deletions
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)