diff options
author | Saadi Maalem <saadi.maalem@intel.com> | 2015-10-09 20:44:49 +0800 |
---|---|---|
committer | Zhengyin Qian <qianzy@google.com> | 2015-10-09 16:21:04 -0700 |
commit | d230af7b63bc3f1f572bd8ed18f770cf71eb61b4 (patch) | |
tree | fe30dd24ed17993abe4e946fb1bf7798e9202c98 | |
parent | beeb640acb2b303f6157ad5da904847fc3fcd73c (diff) | |
download | sensors-d230af7b63bc3f1f572bd8ed18f770cf71eb61b4.tar.gz |
sensor: fix lsm6ds3 HAL bug for more accurate sampling rate
fix the bug for all HW/SW sensors
Change-Id: Idc9809f55a3f3fe3171beb8b2bb55962a08d7b6b
Tracked-On: https://jira.ndg.intel.com/browse/MARVIN-882
Signed-off-by: Fei Li <feix.f.li@intel.com>
Reviewed-on: https://android.intel.com/421790
Reviewed-by: jenkins_ndg <jenkins_ndg@intel.com>
Reviewed-by: Ledentec, AlexandreX <alexandrex.ledentec@intel.com>
Reviewed-by: Tasayco Loarte, VictorX <victorx.tasayco.loarte@intel.com>
-rw-r--r-- | libsensors_iio/src/HWSensorBase.cpp | 10 | ||||
-rw-r--r-- | libsensors_iio/src/SWSensorBase.cpp | 2 |
2 files changed, 2 insertions, 10 deletions
diff --git a/libsensors_iio/src/HWSensorBase.cpp b/libsensors_iio/src/HWSensorBase.cpp index e569c2a..43f7fbb 100644 --- a/libsensors_iio/src/HWSensorBase.cpp +++ b/libsensors_iio/src/HWSensorBase.cpp @@ -446,15 +446,7 @@ void HWSensorBaseWithPollrate::WriteDataToPipe() if (!GetStatusOfHandle(sensor_t_data.handle)) return; - /** 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)) { + if (sensor_event.timestamp >= (last_data_timestamp + real_pollrate)) { err = write(android_pipe_fd, &sensor_event, sizeof(sensor_event)); if (err < 0) { ALOGE("%s: Failed to write sensor data to pipe.", android_name); diff --git a/libsensors_iio/src/SWSensorBase.cpp b/libsensors_iio/src/SWSensorBase.cpp index 320752e..0acd26d 100644 --- a/libsensors_iio/src/SWSensorBase.cpp +++ b/libsensors_iio/src/SWSensorBase.cpp @@ -136,7 +136,7 @@ void SWSensorBaseWithPollrate::WriteDataToPipe() if (!GetStatusOfHandle(sensor_t_data.handle)) return; - if (sensor_event.timestamp > (last_data_timestamp + GetDelay())) { + if (sensor_event.timestamp >= (last_data_timestamp + real_pollrate)) { err = write(android_pipe_fd, &sensor_event, sizeof(sensor_event)); if (err < 0) { ALOGE("%s: Failed to write sensor data to pipe.", android_name); |