README.rst
1.. zephyr:code-sample:: sensor_batch_processing
2 :name: Sensor batch processing
3 :relevant-api: rtio
4
5 Implement a sensor device using RTIO for asynchronous data processing.
6
7Overview
8********
9
10This sample application demonstrates the use of the :ref:`rtio` framework for
11doing asynchronous operation chains.
12Application uses :ref:`rtio` with mempool API to fetch data from virtual sensor
13and displays it on the console.
14
15Requirements
16************
17
18* A board with flash support or native_sim target
19
20Building and Running
21********************
22
23The sample can be built for most platforms, the following commands build the
24application for the native_sim target.
25
26.. zephyr-app-commands::
27 :zephyr-app: samples/subsys/rtio
28 :board: native_sim
29 :goals: build run
30 :compact:
31
32When running, the output on the console shows the operations of
33submitting for, consuming, and processing the sensor data.
34
35Sample Output
36=============
37
38.. code-block:: console
39
40 *** Booting Zephyr OS build v4.0.0-1260-gbaa49f6f32d5 ***
41 I: Submitting 4 read requests
42 D: sensor@0: buf_len = 16, buf = 0x8056430
43 D: sensor@0: buf_len = 16, buf = 0x8056440
44 D: sensor@0: buf_len = 16, buf = 0x8056450
45 D: sensor@0: buf_len = 16, buf = 0x8056460
46 D: Consumed completion event 0
47 D: Consumed completion event 1
48 D: Consumed completion event 2
49 D: Consumed completion event 3
50 I: Start processing 4 samples
51 D: Sample data:
52 D: 00 01 02 03 04 05 06 07 |........
53 D: 08 09 0a 0b 0c 0d 0e 0f |........
54 D: Sample data:
55 D: 10 11 12 13 14 15 16 17 |........
56 D: 18 19 1a 1b 1c 1d 1e 1f |........
57 D: Sample data:
58 D: 20 21 22 23 24 25 26 27 | !"#$%&'
59 D: 28 29 2a 2b 2c 2d 2e 2f |()*+,-./
60 D: Sample data:
61 D: 30 31 32 33 34 35 36 37 |01234567
62 D: 38 39 3a 3b 3c 3d 3e 3f |89:;<=>?
63 D: sensor@0: buf_len = 16, buf = 0x8056470
64 D: sensor@0: buf_len = 16, buf = 0x8056480
65 D: sensor@0: buf_len = 16, buf = 0x8056490
66 I: Finished processing 4 samples
67 I: Submitting 4 read requests
68 D: sensor@0: buf_len = 16, buf = 0x8056430
69 D: sensor@0: buf_len = 16, buf = 0x8056440
70 D: sensor@0: buf_len = 16, buf = 0x8056450
71 D: sensor@0: buf_len = 16, buf = 0x8056460
72 D: Consumed completion event 0
73 ...
74