Sensor emulator backend API .
More...
|
static bool | emul_sensor_backend_is_supported (const struct emul *target) |
| Check if a given sensor emulator supports the backend API.
|
|
static int | emul_sensor_backend_set_channel (const struct emul *target, struct sensor_chan_spec ch, const q31_t *value, int8_t shift) |
| Set an expected value for a given channel on a given sensor emulator.
|
|
static int | emul_sensor_backend_get_sample_range (const struct emul *target, struct sensor_chan_spec ch, q31_t *lower, q31_t *upper, q31_t *epsilon, int8_t *shift) |
| Query an emulator for a channel's supported sample value range and tolerance.
|
|
static int | emul_sensor_backend_set_attribute (const struct emul *target, struct sensor_chan_spec ch, enum sensor_attribute attribute, const void *value) |
| Set the emulator's attribute values.
|
|
static int | emul_sensor_backend_get_attribute_metadata (const struct emul *target, struct sensor_chan_spec ch, enum sensor_attribute attribute, q31_t *min, q31_t *max, q31_t *increment, int8_t *shift) |
| Get metadata about an attribute.
|
|
Sensor emulator backend API .
◆ emul_sensor_backend_get_attribute_metadata()
#include <zephyr/drivers/emul_sensor.h>
Get metadata about an attribute.
Information provided by this function includes the minimum/maximum values of the attribute as well as the increment (value per LSB) which can be used as an epsilon when comparing results.
- Parameters
-
[in] | target | Pointer to emulator instance to operate on |
[in] | ch | The channel to request info for. If ch is unsupported, return '-ENOTSUP' |
[in] | attribute | The attribute to request info for. If attribute is unsupported, return '-ENOTSUP' |
[out] | min | The minimum value the attribute can be set to |
[out] | max | The maximum value the attribute can be set to |
[out] | increment | The value that the attribute increases by for every LSB |
[out] | shift | The shift for min , max , and increment |
- Returns
- 0 on SUCCESS
-
< 0 on error
◆ emul_sensor_backend_get_sample_range()
#include <zephyr/drivers/emul_sensor.h>
Query an emulator for a channel's supported sample value range and tolerance.
- Parameters
-
| target | Pointer to emulator instance to operate on |
| ch | The channel to request info for. If ch is unsupported, return -ENOTSUP |
[out] | lower | Minimum supported sample value in SI units, fixed-point format |
[out] | upper | Maximum supported sample value in SI units, fixed-point format |
[out] | epsilon | Tolerance to use comparing expected and actual values to account for rounding and sensor precision issues. This can usually be set to the minimum sample value step size. Uses SI units and fixed-point format. |
[out] | shift | The shift value (scaling factor) associated with lower , upper , and epsilon . |
- Returns
- 0 if successful
-
-ENOTSUP if no backend API or if channel not supported by emul
◆ emul_sensor_backend_is_supported()
static bool emul_sensor_backend_is_supported |
( |
const struct emul * | target | ) |
|
|
inlinestatic |
#include <zephyr/drivers/emul_sensor.h>
Check if a given sensor emulator supports the backend API.
- Parameters
-
target | Pointer to emulator instance to query |
- Returns
- True if supported, false if unsupported or if
target
is NULL.
◆ emul_sensor_backend_set_attribute()
#include <zephyr/drivers/emul_sensor.h>
Set the emulator's attribute values.
- Parameters
-
[in] | target | Pointer to emulator instance to operate on |
[in] | ch | The channel to request info for. If ch is unsupported, return -ENOTSUP |
[in] | attribute | The attribute to set |
[in] | value | the value to use (cast according to the channel/attribute pair) |
- Returns
- 0 is successful
-
< 0 on error
◆ emul_sensor_backend_set_channel()
#include <zephyr/drivers/emul_sensor.h>
Set an expected value for a given channel on a given sensor emulator.
- Parameters
-
target | Pointer to emulator instance to operate on |
ch | Sensor channel to set expected value for |
value | Expected value in fixed-point format using standard SI unit for sensor type |
shift | Shift value (scaling factor) applied to value |
- Returns
- 0 if successful
-
-ENOTSUP if no backend API or if channel not supported by emul
-
-ERANGE if provided value is not in the sensor's supported range