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>
This commit is contained in:
parent
6d0760aa98
commit
67d24b9e42
2 changed files with 50 additions and 19 deletions
|
@ -10,19 +10,49 @@ tests:
|
|||
type: multi_line
|
||||
ordered: false
|
||||
regex:
|
||||
- "I: System started"
|
||||
- "I: Activating filter"
|
||||
- "I: Deactivating filter"
|
||||
- "I: Bypass filter"
|
||||
- "I: Disable bypass filter"
|
||||
- "I: >-- Raw data fetched"
|
||||
- "I: -|- Filtering data"
|
||||
- "I: --> Consuming data: Acc x=0, y=0, z=0"
|
||||
- "I: --> Consuming data: Acc x=2, y=2, z=2"
|
||||
- "I: --> Consuming data: Acc x=4, y=4, z=4"
|
||||
- "I: --> Consuming data: Acc x=6, y=6, z=6"
|
||||
- "I: --> Consuming data: Acc x=7, y=7, z=7"
|
||||
- "I: --> Consuming data: Acc x=8, y=8, z=8"
|
||||
- "I: --> Consuming data: Acc x=9, y=9, z=9"
|
||||
- "I: --> Consuming data: Acc x=10, y=10, z=10"
|
||||
- ".*I: System started, runtime observers statically allocated"
|
||||
- ".*I: Activating filter"
|
||||
- ".*I: Deactivating filter"
|
||||
- ".*I: Bypass filter"
|
||||
- ".*I: Disable bypass filter"
|
||||
- ".*I: >-- Raw data fetched"
|
||||
- ".*I: -|- Filtering data"
|
||||
- ".*I: --> Consuming data: Acc x=0, y=0, z=0"
|
||||
- ".*I: --> Consuming data: Acc x=2, y=2, z=2"
|
||||
- ".*I: --> Consuming data: Acc x=4, y=4, z=4"
|
||||
- ".*I: --> Consuming data: Acc x=6, y=6, z=6"
|
||||
- ".*I: --> Consuming data: Acc x=7, y=7, z=7"
|
||||
- ".*I: --> Consuming data: Acc x=8, y=8, z=8"
|
||||
- ".*I: --> Consuming data: Acc x=9, y=9, z=9"
|
||||
- ".*I: --> Consuming data: Acc x=10, y=10, z=10"
|
||||
tags: zbus
|
||||
extra_configs:
|
||||
- CONFIG_ZBUS_PREFER_DYNAMIC_ALLOCATION=n
|
||||
sample.zbus.runtime_os_registration_dynamic_alloc:
|
||||
min_ram: 16
|
||||
integration_platforms:
|
||||
- qemu_x86
|
||||
arch_exclude: nios2
|
||||
harness: console
|
||||
harness_config:
|
||||
type: multi_line
|
||||
ordered: false
|
||||
regex:
|
||||
- ".*I: System started, runtime observers dynamically allocated"
|
||||
- ".*I: Activating filter"
|
||||
- ".*I: Deactivating filter"
|
||||
- ".*I: Bypass filter"
|
||||
- ".*I: Disable bypass filter"
|
||||
- ".*I: >-- Raw data fetched"
|
||||
- ".*I: -|- Filtering data"
|
||||
- ".*I: --> Consuming data: Acc x=0, y=0, z=0"
|
||||
- ".*I: --> Consuming data: Acc x=2, y=2, z=2"
|
||||
- ".*I: --> Consuming data: Acc x=4, y=4, z=4"
|
||||
- ".*I: --> Consuming data: Acc x=6, y=6, z=6"
|
||||
- ".*I: --> Consuming data: Acc x=7, y=7, z=7"
|
||||
- ".*I: --> Consuming data: Acc x=8, y=8, z=8"
|
||||
- ".*I: --> Consuming data: Acc x=9, y=9, z=9"
|
||||
- ".*I: --> Consuming data: Acc x=10, y=10, z=10"
|
||||
tags: zbus
|
||||
extra_configs:
|
||||
- CONFIG_HEAP_MEM_POOL_SIZE=1024
|
||||
|
|
|
@ -41,14 +41,15 @@ ZBUS_SUBSCRIBER_DEFINE(state_change_sub, 5);
|
|||
|
||||
int main(void)
|
||||
{
|
||||
LOG_INF("System started");
|
||||
LOG_INF("System started, runtime observers %s allocated",
|
||||
IS_ENABLED(CONFIG_ZBUS_RUNTIME_OBSERVERS_NODE_ALLOC_DYNAMIC) ? "dynamically"
|
||||
: "statically");
|
||||
|
||||
const struct zbus_channel *chan;
|
||||
struct zbus_observer_node obs_node;
|
||||
|
||||
while (1) {
|
||||
LOG_INF("Activating filter");
|
||||
zbus_chan_add_obs(&raw_data_chan, &filter_lis, &obs_node, K_MSEC(200));
|
||||
zbus_chan_add_obs(&raw_data_chan, &filter_lis, K_MSEC(200));
|
||||
|
||||
zbus_sub_wait(&state_change_sub, &chan, K_FOREVER);
|
||||
|
||||
|
@ -56,7 +57,7 @@ int main(void)
|
|||
zbus_chan_rm_obs(&raw_data_chan, &filter_lis, K_MSEC(200));
|
||||
|
||||
LOG_INF("Bypass filter");
|
||||
zbus_chan_add_obs(&raw_data_chan, &consumer_sub, &obs_node, K_MSEC(200));
|
||||
zbus_chan_add_obs(&raw_data_chan, &consumer_sub, K_MSEC(200));
|
||||
|
||||
zbus_sub_wait(&state_change_sub, &chan, K_FOREVER);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue