|
| 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. |
0 commit comments