mirror of
https://github.com/apache/nuttx.git
synced 2026-05-29 04:19:37 +08:00
driver/sensor: Solve the busy loop problem caused by sampling problems
Solve the problem that when a user modifies the sampling rate, the difference between the generation and the mainline generation may be greater than the own sampling interval. After this problem occurs, sensor_is_update() will continue to return true, resulting in a busy loop in the upper-layer application, so, need update user generation according to mainline generation. Signed-off-by: dongjiuzhu1 <dongjiuzhu1@xiaomi.com>
This commit is contained in:
committed by
Petro Karashchenko
parent
93b2a3744f
commit
c22646c0d4
@@ -483,6 +483,14 @@ static ssize_t sensor_do_samples(FAR struct sensor_upperhalf_s *upper,
|
|||||||
generation = next_generation;
|
generation = next_generation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (pos - 1 == end && sensor_is_updated(upper, user))
|
||||||
|
{
|
||||||
|
generation = upper->state.generation - user->state.generation +
|
||||||
|
(upper->state.min_interval >> 1);
|
||||||
|
user->state.generation += ROUND_DOWN(generation,
|
||||||
|
user->state.interval);
|
||||||
|
}
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user