Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sensor: sensor_shell: split DXYZ & remove decoding redirection #72841

Draft
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

ycsin
Copy link
Collaborator

@ycsin ycsin commented May 16, 2024

Attempts to fix #72840

Apart from the 3-dimensional data, everything else works.

uart:~$ sensor get sensor@0 0
channel type=0(accel_x) index=0 shift=0 num_samples=1 value=9220133425350000000ns (0.000000)
uart:~$ sensor get sensor@0 1
channel type=1(accel_y) index=0 shift=1 num_samples=1 value=9220133425350000000ns (1.000000)
uart:~$ sensor get sensor@0 2
channel type=2(accel_z) index=0 shift=2 num_samples=1 value=9220133425350000000ns (2.000000)
uart:~$ sensor get sensor@0 3
channel type=0(accel_x) index=0 shift=2 num_samples=1 value=9220133425350000000ns (3.000000)
uart:~$ sensor get sensor@0 4
channel type=4(gyro_x) index=0 shift=3 num_samples=1 value=9220133425350000000ns (4.000000)
uart:~$ sensor get sensor@0 5
channel type=5(gyro_y) index=0 shift=3 num_samples=1 value=9220133425350000000ns (5.000000)
uart:~$ sensor get sensor@0 6
channel type=6(gyro_z) index=0 shift=3 num_samples=1 value=9220133425350000000ns (6.000000)
uart:~$ sensor get sensor@0 7
channel type=4(gyro_x) index=0 shift=3 num_samples=1 value=9220133425350000000ns (7.000000)
uart:~$ sensor get sensor@0 8
channel type=8(magn_x) index=0 shift=4 num_samples=1 value=9220133425350000000ns (8.000000)
uart:~$ sensor get sensor@0 9
channel type=9(magn_y) index=0 shift=4 num_samples=1 value=9220133425350000000ns (9.000000)
uart:~$ sensor get sensor@0 10
channel type=10(magn_z) index=0 shift=4 num_samples=1 value=9220133425350000000ns (10.000000)
uart:~$ sensor get sensor@0 11
channel type=8(magn_x) index=0 shift=4 num_samples=1 value=9220133425350000000ns (11.000000)

@teburd teburd requested a review from yperess May 16, 2024 17:36
@ycsin ycsin changed the title sensor: sensor_shell: split DXYZ & decoding redirection sensor: sensor_shell: split DXYZ & remove decoding redirection May 17, 2024
@ycsin ycsin force-pushed the pr/sensor_shell_chan branch 2 times, most recently from aeec59d to 57a75ac Compare May 17, 2024 04:23
ycsin added 9 commits May 17, 2024 18:36
Should increment `ch.chan_idx` instead of `channel_idx`,
otherwise we will be stucked in the loop forever.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Print something to the shell when the `trig` command
completed successfully.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Add a simple fake sensor driver so that the sample is more fun
for boards without real sensor.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Use pytest to test the shell commands.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
The `SENSOR_CHAN_VSHUNT` was added in zephyrproject-rtos#60717 but was never
added to the `sensor_channel_name[SENSOR_CHAN_COMMON_COUNT]`
table. Since the length of `sensor_channel_name` is fixed to
`SENSOR_CHAN_COMMON_COUNT`, this means that the index at
`SENSOR_CHAN_VSHUNT` points to `NULL`. When we use the
`sensor get` command for anything bigger than
`SENSOR_CHAN_VSHUNT`, we will deref that `NULL` pointer
when we do `strcmp` in the for-loop of `parse_named_int`.

Fix this by defining `SENSOR_CHAN_VSHUNT` in the table.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
If `CONFIG_SENSOR_INFO` is enabled, use the `sensor_info`
section to validate that the argument is a sensor before using,
otherwise the shell command will hang the application.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Update the pytest script to exercise the entire
`sensor_channel_name` table with `parse_named_int()`.

The `gauge_desired_charging_current` is selected because
it is the last one in the table before `all`, `all` is not
used because `sensor get sensor@0 all` doesn't return anything.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
As new channels are added to the `enum sensor_channel`, some
of the newer channel aren't updated in the whitelist of rtio
decoder.

Instead of specifying every channel in the list, do:
1. Verify that the `channel` is valid
2. cherry-pick the channels that require special handling, i.e.
   1. `three_axis_data`
   2. `byte_data`
   3. `uint64_data`
3. handle the remaining `channel` in the default case as
   `q31_data`

to make sure that all channels are handled.

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Add `SENSOR_CHAN_POS_DXYZ` enum, and removed the redirection of
axis to axes so that we can get the axis value correctly, i.e.

```
sensor get <sensor> accel_y
```

Signed-off-by: Yong Cong Sin <ycsin@meta.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

sensor_shell: strange and unexpected output when getting single axis from 3-axis data
1 participant