Skip to content

Commit e924879

Browse files
diegosueironashif
authored andcommitted
samples/subsys/shell: Introduce Sensor Shell module
Adds the Sensor Shell module sample app. Signed-off-by: Diego Sueiro <[email protected]> Signed-off-by: Anas Nashif <[email protected]>
1 parent 93e1560 commit e924879

File tree

6 files changed

+135
-0
lines changed

6 files changed

+135
-0
lines changed
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# SPDX-License-Identifier: Apache-2.0
2+
3+
cmake_minimum_required(VERSION 3.8.2)
4+
macro(set_conf_file)
5+
if(EXISTS ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf)
6+
set(CONF_FILE "prj.conf ${APPLICATION_SOURCE_DIR}/boards/${BOARD}.conf")
7+
else()
8+
set(CONF_FILE "prj.conf")
9+
endif()
10+
endmacro()
11+
12+
include($ENV{ZEPHYR_BASE}/cmake/app/boilerplate.cmake NO_POLICY_SCOPE)
13+
project(sensor_shell)
14+
15+
FILE(GLOB app_sources src/*.c)
16+
target_sources(app PRIVATE ${app_sources})
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
.. _sensor_shell_sample:
2+
3+
Sensor Shell Module Sample
4+
##########################
5+
6+
Overview
7+
********
8+
This is a simple shell module to get data from sensors presented in the system.
9+
10+
Building and Running
11+
********************
12+
13+
Build the sample app by choosing the target board that has sensors drivers
14+
enabled, for example:
15+
16+
.. code-block:: console
17+
18+
cmake -DBOARD=reel_board
19+
20+
21+
.. zephyr-app-commands::
22+
:zephyr-app: samples/subsys/shell/sensor_module
23+
:goals: run
24+
25+
26+
Shell Module Command Help
27+
=========================
28+
29+
.. code-block:: console
30+
31+
sensor - Sensor commands
32+
Options:
33+
-h, --help :Show command help.
34+
Subcommands:
35+
get :<device_name> [chanel_idx]
36+
list :List configured sensors
37+
list_channels :<device_name>
38+
39+
**list**: lists all the initialized devices on the system.
40+
41+
Output example (reel_board):
42+
43+
.. code-block:: console
44+
45+
uart:~$ sensor list
46+
devices:
47+
- clk_k32src
48+
- clk_m16src
49+
- UART_0
50+
- ENTROPY_0
51+
- GPIO_0
52+
- GPIO_1
53+
- I2C_0
54+
- APDS9960
55+
- MMA8652FC
56+
- HDC1008
57+
58+
**list_channels**: lists the supported channels (index and name) for a given
59+
sensor device name.
60+
61+
Output example (reel_board):
62+
63+
.. code-block:: console
64+
65+
uart:~$ sensor list_channels MMA8652FC
66+
idx=0 name=accel_x
67+
idx=1 name=accel_y
68+
idx=2 name=accel_z
69+
idx=3 name=accel_xyz
70+
71+
.. note:: A valid sensor device name should be passed otherwise you will get an
72+
undefined behavior like hardware exception. This happens because the shell
73+
subsystem runs in supervisor mode where API callbacks are not checked before
74+
being called.
75+
76+
**get**: prints all the sensor channels data for a given sensor device name.
77+
Optionally, a single channel index can be passed to be printed out.
78+
79+
Output example (reel_board):
80+
81+
.. code-block:: console
82+
83+
uart:~$ sensor get MMA8652FC
84+
channel idx=0 accel_x = -1.379061
85+
channel idx=1 accel_y = 1.991975
86+
channel idx=2 accel_z = -9.576807
87+
channel idx=3 accel_xyz = -1.379061
88+
channel idx=3 accel_xyz = 1.991975
89+
channel idx=3 accel_xyz = -9.576807
90+
91+
.. note:: A valid sensor device name should be passed otherwise you will get an
92+
undefined behavior like hardware exception. This happens because the shell
93+
subsystem runs in supervisor mode where API callbacks are not checked before
94+
being called.
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
CONFIG_APDS9960=y
2+
CONFIG_FXOS8700=y
3+
CONFIG_TI_HDC=y
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
CONFIG_SHELL=y
2+
CONFIG_BOOT_BANNER=n
3+
CONFIG_SENSOR=y
4+
CONFIG_SENSOR_SHELL=y
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
sample:
2+
name: Shell Sensor Module Sample
3+
tests:
4+
test:
5+
filter: ( CONFIG_UART_CONSOLE and CONFIG_SERIAL_SUPPORT_INTERRUPT )
6+
tags: shell
7+
harness: keyboard
8+
min_ram: 20
9+
min_flash: 33
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
/*
2+
* Copyright (c) 2018 Diego Sueiro
3+
*
4+
* SPDX-License-Identifier: Apache-2.0
5+
*/
6+
7+
#include <logging/log.h>
8+
9+
LOG_MODULE_REGISTER(app);

0 commit comments

Comments
 (0)