Sensor Shell Module Sample
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:
# From the root of the zephyr repository west build -b reel_board samples/sensor/sensor_shell west flash
Shell Module Command Help
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):
uart:~$ sensor get [email protected] 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 [email protected] accel_z channel idx=2 accel_z = 9.959878 uart:~$ sensor get [email protected] 2 channel idx=2 accel_z = 9.959878
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
uart:~$ sensor info device name: [email protected], vendor: Avago Technologies, model: apds9960, friendly name: (null) device name: [email protected], vendor: NXP Semiconductors, model: fxos8700, friendly name: (null) device name: [email protected], vendor: Texas Instruments, model: hdc, friendly name: (null) device name: [email protected], vendor: Nordic Semiconductor, model: nrf-temp, friendly name: (null)