zephyr/samples/sensor/sensor_shell
Tristan Honscheid dc9bd3afe3 sensors: Create `sensor trig` subcommand
This PR relocates the sensor trigger sample application from the
`sensor_shell` sample to a subcommand in the actual sensor shell. The
subcommand has a UI for enabling a given trigger on a given sensor.
A built-in handler for the data_ready trigger is included that prints
the latest data to the log. Currently, only `SENSOR_TRIG_DATA_READY` is
supported but the groundwork is there to add others. Tested on a
`tdk_robokit1` board.

Signed-off-by: Tristan Honscheid <honscheid@google.com>
2023-05-27 05:33:11 -04:00
..
boards board: Adds MIMXRT1062-FMURT6 board support package 2023-05-18 14:08:06 -05:00
include sensor_shell: Update to new sensor_read API 2023-05-26 11:04:54 -05:00
src sensors: Create `sensor trig` subcommand 2023-05-27 05:33:11 -04:00
CMakeLists.txt sensors: Create `sensor trig` subcommand 2023-05-27 05:33:11 -04:00
Kconfig sensors: Create `sensor trig` subcommand 2023-05-27 05:33:11 -04:00
README.rst
prj.conf sensor_shell: Update to new sensor_read API 2023-05-26 11:04:54 -05:00
sample.yaml

README.rst

.. _sensor_shell_sample:

Sensor Shell Module Sample
##########################

Overview
********
This is a simple shell module to get data from sensors presented in the system.

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

Build the sample app by choosing the target board that has sensors drivers
enabled, for example:

.. zephyr-app-commands::
   :zephyr-app: samples/sensor/sensor_shell
   :board: reel_board
   :goals: build flash

Shell Module Command Help
=========================

.. code-block:: console

   sensor - Sensor commands
   Subcommands:
     get   :Get sensor data. Channel names are optional. All channels are read when
            no channels are provided. Syntax:
            <device_name> <channel name 0> .. <channel name N>
     info  :Get sensor info, such as vendor and model name, for all sensors.


**get**: prints all the sensor channels data for a given sensor device name.
Optionally, a single channel name or index can be passed to be printed out. The
device name and channel name are autocompleted.

Output example (reel_board):

.. code-block:: console

   uart:~$ sensor get mma8652fc@1d
   channel idx=0 accel_x =   0.000000
   channel idx=1 accel_y =   0.268150
   channel idx=2 accel_z =   9.959878
   channel idx=3 accel_xyz x =   0.000000 y =   0.268150 z =   9.959878

   uart:~$ sensor get mma8652fc@1d accel_z
   channel idx=2 accel_z =   9.959878

   uart:~$ sensor get mma8652fc@1d 2
   channel idx=2 accel_z =   9.959878

.. note::
   A valid sensor device name should be passed otherwise you will get an
   undefined behavior like hardware exception. This happens because the shell
   subsystem runs in supervisor mode where API callbacks are not checked before
   being called.

**info**: prints vendor, model, and friendly name information for all sensors.
This command depends on enabling :kconfig:option:`CONFIG_SENSOR_INFO`.

.. code-block:: console

   uart:~$ sensor info
   device name: apds9960@39, vendor: Avago Technologies, model: apds9960, friendly name: (null)
   device name: mma8652fc@1d, vendor: NXP Semiconductors, model: fxos8700, friendly name: (null)
   device name: ti_hdc@43, vendor: Texas Instruments, model: hdc, friendly name: (null)
   device name: temp@4000c000, vendor: Nordic Semiconductor, model: nrf-temp, friendly name: (null)