summaryrefslogtreecommitdiff
path: root/libsensors_iio/src/HWSensorBase.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'libsensors_iio/src/HWSensorBase.cpp')
-rw-r--r--libsensors_iio/src/HWSensorBase.cpp10
1 files changed, 9 insertions, 1 deletions
diff --git a/libsensors_iio/src/HWSensorBase.cpp b/libsensors_iio/src/HWSensorBase.cpp
index 24ed9f2..d029114 100644
--- a/libsensors_iio/src/HWSensorBase.cpp
+++ b/libsensors_iio/src/HWSensorBase.cpp
@@ -443,7 +443,15 @@ void HWSensorBaseWithPollrate::WriteDataToPipe()
if (!GetStatusOfHandle(sensor_t_data.handle))
return;
- if (sensor_event.timestamp > (last_data_timestamp + GetDelay())) {
+ /** Actually, the actual ODR would be slightly bigger than the requested,
+ * Eg: for lsm6ds3, real ODR is 26, 52, 104..., so the actual ODR is 104Hz
+ * when 100Hz is requested.
+ * As a result, the reporting time interval between two adjacent events
+ * would be smaller than that from GetDelay().
+ * To guarantee the requested ODR in all cases, the reporting time interval
+ * should be greater than GetDelay()/2.
+ */
+ if (sensor_event.timestamp > (last_data_timestamp + GetDelay() / 2)) {
err = write(android_pipe_fd, &sensor_event, sizeof(sensor_event));
if (err < 0) {
ALOGE("%s: Failed to write sensor data to pipe.", android_name);