summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaadi Maalem <saadi.maalem@intel.com>2015-09-22 14:06:26 +0800
committerZhengyin Qian <qianzy@google.com>2015-09-29 10:50:14 -0700
commit7973c2ff4cbf36141ffe6d984a0a97f5d045c865 (patch)
treef67573a61dde8db45b5b48f51206a291b2c1995b
parent3b77ab138a9c20edc4d6be12cf4ae7a3709cdf5d (diff)
downloadsensors-7973c2ff4cbf36141ffe6d984a0a97f5d045c865.tar.gz
sensor: fix lsm6ds3 HAL bug which abondons sensor events by mistake
The bug results in less sensor events reported than requested. Change-Id: I61b4e22100d227d1c1e073da5e665dec4cf19943 Tracked-On: https://jira.ndg.intel.com/browse/MARVIN-592 Signed-off-by: Fei Li <feix.f.li@intel.com> Reviewed-on: https://android.intel.com/414386 Reviewed-by: Ledentec, AlexandreX <alexandrex.ledentec@intel.com> Tested-by: Ledentec, AlexandreX <alexandrex.ledentec@intel.com> Reviewed-by: jenkins_ndg <jenkins_ndg@intel.com> Reviewed-by: Tasayco Loarte, VictorX <victorx.tasayco.loarte@intel.com> Reviewed-by: Hadjimegrian, MathieuX <mathieux.hadjimegrian@intel.com> Tested-by: Hadjimegrian, MathieuX <mathieux.hadjimegrian@intel.com> Reviewed-by: Maalem, Saadi <saadi.maalem@intel.com>
-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);