Skip to content

drivers: Delay DBus notifying and method returning until first measurement

Jonas Dreßler requested to merge verdre/iio-sensor-proxy:read-once into master

When claiming a sensor via DBus, there are two possible options:

  1. The sensor is not active, and the client is the first one to claim the sensor. In that case iio-sensor-proxy will initialize the sensor and notify the property on dbus once a first measurement has been done.

  2. The sensor already is active, the client is not the first one to claim the sensor. In that case iio-sensor-proxy will not really do anything.

In case 2), the client can read the sensor property (so eg. ProximityNear) over DBus immediately and the result will be correct. Meanwhile in case 1), the client will read an outdated result (potentially from the last time the sensor was active, or just the default).

Clients have no way of knowing whether they're the first ones to claim a sensor though, so they can only trust iio-sensor-proxy that the DBus properties are always up-to-date. In case 1), this requirement is not met.

To deliver on that promise without drastically changing the API of iio-sensor-proxy, we have to delay with returning the DBus call on the first Claim() of a sensor until we receive a measurement from the sensor, so that the client has a valid measurement to work with right after Claim() returns.

Same thing goes for the case where a sensor is already claimed, but the actual sensor-hardware is not there yet. In this case we need to delay notifying the HasAccelerometer/HasAmbientLight/... DBus properties until the first measurement is received.

Edited by Jonas Dreßler

Merge request reports

Loading