zephyr/samples/sensor/sensor_shell
Torsten Rasmussen 407b49b35c cmake: use find_package to locate Zephyr
Using find_package to locate Zephyr.

Old behavior was to use $ENV{ZEPHYR_BASE} for inclusion of boiler plate
code.

Whenever an automatic run of CMake happend by the build system / IDE
then it was required that ZEPHYR_BASE was defined.
Using ZEPHYR_BASE only to locate the Zephyr package allows CMake to
cache the base variable and thus allowing subsequent invocation even
if ZEPHYR_BASE is not set in the environment.

It also removes the risk of strange build results if a user switchs
between different Zephyr based project folders and forgetting to reset
ZEPHYR_BASE before running ninja / make.

Signed-off-by: Torsten Rasmussen <Torsten.Rasmussen@nordicsemi.no>
2020-03-27 16:23:46 +01:00
..
boards samples/subsys/shell: Introduce Sensor Shell module 2019-12-19 15:54:04 -05:00
src samples/subsys/shell: Introduce Sensor Shell module 2019-12-19 15:54:04 -05:00
CMakeLists.txt cmake: use find_package to locate Zephyr 2020-03-27 16:23:46 +01:00
prj.conf samples/subsys/shell: Introduce Sensor Shell module 2019-12-19 15:54:04 -05:00
README.rst samples/subsys/shell: Introduce Sensor Shell module 2019-12-19 15:54:04 -05:00
sample.yaml samples: sensor: fix test identifier 2019-12-20 10:35:13 -05:00

.. _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:

.. code-block:: console

         cmake -DBOARD=reel_board


.. zephyr-app-commands::
   :zephyr-app: samples/subsys/shell/sensor_module
   :goals: run


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

.. code-block:: console

         sensor - Sensor commands
         Options:
                 -h, --help  :Show command help.
         Subcommands:
                 get            :<device_name> [chanel_idx]
                 list           :List configured sensors
                 list_channels  :<device_name>

**list**: lists all the initialized devices on the system.

Output example (reel_board):

.. code-block:: console

         uart:~$ sensor list
         devices:
         - clk_k32src
         - clk_m16src
         - UART_0
         - ENTROPY_0
         - GPIO_0
         - GPIO_1
         - I2C_0
         - APDS9960
         - MMA8652FC
         - HDC1008

**list_channels**: lists the supported channels (index and name) for a given
sensor device name.

Output example (reel_board):

.. code-block:: console

         uart:~$ sensor list_channels MMA8652FC
         idx=0 name=accel_x
         idx=1 name=accel_y
         idx=2 name=accel_z
         idx=3 name=accel_xyz

.. 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.

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

Output example (reel_board):

.. code-block:: console

         uart:~$ sensor get MMA8652FC
         channel idx=0 accel_x =  -1.379061
         channel idx=1 accel_y =   1.991975
         channel idx=2 accel_z =  -9.576807
         channel idx=3 accel_xyz =  -1.379061
         channel idx=3 accel_xyz =   1.991975
         channel idx=3 accel_xyz =  -9.576807

.. 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.