zephyr/samples/subsys/zbus/work_queue
Krzysztof Chruściński fb2d9ecde5 samples: zbus: work_queue: Enable synchronous printk
twister expects regex print from logging used in the sample. Sample
is using minimal logging which does not protect against logs being
interleaved if printed from various contexts. Minimal logging is
just mapping of logging API to printk. Add CONFIG_PRINTK_SYNC to
ensure that printing of each log is synchronous (with lock) and
logs are never interleaved.

Signed-off-by: Krzysztof Chruściński <krzysztof.chruscinski@nordicsemi.no>
2024-07-30 18:27:40 +01:00
..
src
CMakeLists.txt
prj.conf samples: zbus: work_queue: Enable synchronous printk 2024-07-30 18:27:40 +01:00
README.rst doc: zbus: samples: Use new Sphinx extension to document samples 2023-09-11 19:56:57 +02:00
sample.yaml tests: cleanup metadata and filtering 2023-06-13 09:38:27 -04:00

.. zephyr:code-sample:: zbus-work-queue
   :name: Work queue
   :relevant-api: zbus_apis

   Use a work queue to process zbus messages in various ways.

Overview
********
This sample implements an application using zbus to illustrate three different reaction options. First, the observer can react "instantaneously" by using a listener callback. It can schedule a job, pushing that to the system work queue. Last, it can wait and execute that in a subscriber thread.

Building and Running
********************

This project outputs to the console.  It can be built and executed
on QEMU as follows:

.. zephyr-app-commands::
   :zephyr-app: samples/subsys/zbus/work_queue
   :host-os: unix
   :board: qemu_x86
   :goals: run

Sample Output
=============

.. code-block:: console

    I: Sensor msg processed by CALLBACK fh1: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by CALLBACK fh2: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by CALLBACK fh3: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by WORK QUEUE handler dh1: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by WORK QUEUE handler dh2: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by WORK QUEUE handler dh3: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by THREAD handler 1: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by THREAD handler 2: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by THREAD handler 3: temp = 10, press = 1, humidity = 100
    I: Sensor msg processed by CALLBACK fh1: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by CALLBACK fh2: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by CALLBACK fh3: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by WORK QUEUE handler dh1: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by WORK QUEUE handler dh2: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by WORK QUEUE handler dh3: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by THREAD handler 1: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by THREAD handler 2: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by THREAD handler 3: temp = 20, press = 2, humidity = 200
    I: Sensor msg processed by CALLBACK fh1: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by CALLBACK fh2: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by CALLBACK fh3: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by WORK QUEUE handler dh1: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by WORK QUEUE handler dh2: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by WORK QUEUE handler dh3: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by THREAD handler 1: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by THREAD handler 2: temp = 30, press = 3, humidity = 300
    I: Sensor msg processed by THREAD handler 3: temp = 30, press = 3, humidity = 300
    <continues>

Exit QEMU by pressing :kbd:`CTRL+A` :kbd:`x`.