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