-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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
tests: sensors: Emulator Backend API and Generic Test #60394
tests: sensors: Emulator Backend API and Generic Test #60394
Conversation
af26858
to
b94ecc3
Compare
b94ecc3
to
f5bd473
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nits and typos.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM but +1 to Abe's nits.
The sensor driver uses the value 500 to convert bit counts to microgauss values, but it should actually be 1500. Edit the driver unit test to use the macro instead of a magic number. Signed-off-by: Tristan Honscheid <honscheid@google.com>
b6031b7
b6031b7
to
915986a
Compare
|
||
#include <zephyr/drivers/emul.h> | ||
#include <zephyr/drivers/sensor.h> | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a reference to the sensor documentation here
Would that just involve adding .. doxygengroup:: my_new_group_name
below the current last line?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also add a reference to the sensor documentation here
Would that just involve adding
.. doxygengroup:: my_new_group_name
below the current last line?
Yes, that's correct.
6448bc6
915986a
to
6448bc6
Compare
RTIO_DEFINE_WITH_MEMPOOL(sensor_read_rtio_ctx, 1, 1, 1, 64, 4); | ||
|
||
/** Number of test points to use in the generic test. These are automatically generated. */ | ||
#define NUM_EXPECTED_VALS (5) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this a Kconfig in the test?
6448bc6
to
0a938f7
Compare
This PR introduces a backend API to be implemented by sensor emulators that creates a standardized mechanism for setting expected sensor readings in tests. This unlocks the ability to create a generic sensor test that can automatically set expected values in supported sensor emulators and verify them through the existing sensor API. An implementation of this API is provided for the AKM09918C magnetometer. A generic sensor test is also created to exercise this implementation. Observe that this test knows nothing about the AKM09918C; info about supported channels and sample ranges is discovered through the backend API. The test iterates over all devices attached to the virtual I2C and SPI buses in the test binary's device tree, which (theoretically) covers all sensors. Sensors whose emulator does not exist yet or does not support the backend API are skipped. Signed-off-by: Tristan Honscheid <honscheid@google.com>
0a938f7
to
39480f1
Compare
Implement the backend emul API for the ICM42688 motion sensor so it can be automatically tested by the generic sensor test (see zephyrproject-rtos#60394). Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the programmable full-scale accel and gyro ranges. Also fixes an arithmetic bug in the driver that was causing a minor error in the returned readings. Signed-off-by: Tristan Honscheid <honscheid@google.com>
This test was turned off last weekend when a sensor misbehaved and broke the CI, but that issue was resolved in zephyrproject-rtos#61016. This PR turns the test back on. For more info on what this test does, please see zephyrproject-rtos#60394. For more context see also the comments under zephyrproject-rtos#60959 Signed-off-by: Tristan Honscheid <honscheid@google.com>
This test was turned off last weekend when a sensor misbehaved and broke the CI, but that issue was resolved in #61016. This PR turns the test back on. For more info on what this test does, please see #60394. For more context see also the comments under #60959 Signed-off-by: Tristan Honscheid <honscheid@google.com>
This test was turned off last weekend when a sensor misbehaved and broke the CI, but that issue was resolved in zephyrproject-rtos#61016. This PR turns the test back on. For more info on what this test does, please see zephyrproject-rtos#60394. For more context see also the comments under zephyrproject-rtos#60959 Signed-off-by: Tristan Honscheid <honscheid@google.com>
Implement the backend emul API for the ICM42688 motion sensor so it can be automatically tested by the generic sensor test (see #60394). Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the programmable full-scale accel and gyro ranges. Also fixes an arithmetic bug in the driver that was causing a minor error in the returned readings. Signed-off-by: Tristan Honscheid <honscheid@google.com>
This test was turned off last weekend when a sensor misbehaved and broke the CI, but that issue was resolved in zephyrproject-rtos#61016. This PR turns the test back on. For more info on what this test does, please see zephyrproject-rtos#60394. For more context see also the comments under zephyrproject-rtos#60959 Signed-off-by: Tristan Honscheid <honscheid@google.com>
Implement the backend emul API for the ICM42688 motion sensor so it can be automatically tested by the generic sensor test (see zephyrproject-rtos#60394). Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the programmable full-scale accel and gyro ranges. Also fixes an arithmetic bug in the driver that was causing a minor error in the returned readings. Signed-off-by: Tristan Honscheid <honscheid@google.com>
This test was turned off last weekend when a sensor misbehaved and broke the CI, but that issue was resolved in zephyrproject-rtos#61016. This PR turns the test back on. For more info on what this test does, please see zephyrproject-rtos#60394. For more context see also the comments under zephyrproject-rtos#60959 Signed-off-by: Tristan Honscheid <honscheid@google.com>
Implement the backend emul API for the ICM42688 motion sensor so it can be automatically tested by the generic sensor test (see zephyrproject-rtos#60394). Supports all channels (temp, accel XYZ, and gyro XYZ) at each of the programmable full-scale accel and gyro ranges. Also fixes an arithmetic bug in the driver that was causing a minor error in the returned readings. Signed-off-by: Tristan Honscheid <honscheid@google.com>
Note: this PR depends on #60275 You may ignore the bottom 4 commits.
This PR introduces a backend API to be implemented by sensor emulators
that creates a standardized mechanism for setting expected sensor
readings in tests. This unlocks the ability to create a generic sensor
test that can automatically set expected values in supported sensor
emulators and verify them through the existing sensor API. An
implementation of this API is provided for the AKM09918C magnetometer.
A generic sensor test is also created to exercise this implementation.
Observe that this test knows nothing about the AKM09918C; info about
supported channels and sample ranges is discovered through the backend
API. The test iterates over all devices attached to the virtual I2C and
SPI buses in the test binary's device tree, which (theoretically) covers
all sensors. Sensors whose emulator does not exist yet or does not
support the backend API are skipped.