Support polling/non-compensated magnetometers
I would like to get the compass exposed to Geoclue on this device, but iio-sensor-proxy doesn't appear to be finding it.
The device is the LIS3MDL, using the st_sensors_i2c driver:
$ lsmod | grep st
:
st_sensors_i2c 16384 1 st_magn_i2c
st_magn 20480 1 st_magn_i2c
st_sensors 24576 3 st_magn_i2c,st_magn
industrialio_triggered_buffer 16384 2 inv_mpu6050,st_magn
kfifo_buf 16384 1 industrialio_triggered_buffer
$ uname -a
:
Linux mobian 5.7-pinephone #5.7.0+pinephone5 SMP PREEMPT Mon Jul 6 15:28:18 CEST 2020 aarch64 GNU/Linux
I am able to read the raw output directly from sysfs with e.g. cat /sys/bus/iio/devices/iio:device3/in_magn_x_raw
.
The relevant $ udevadm info --export-db
:
N: iio:device3
L: 0
E: DEVPATH=/devices/platform/soc/1c2b000.i2c/i2c-1/1-001e/iio:device3
E: SUBSYSTEM=iio
E: DEVNAME=/dev/iio:device3
E: DEVTYPE=iio_device
E: OF_NAME=lis3mdl
E: OF_FULLNAME=/soc/i2c@1c2b000/lis3mdl@1e
E: OF_COMPATIBLE_0=st,lis3mdl-magn
E: OF_COMPATIBLE_N=1
E: MAJOR=248
E: MINOR=3
P: /devices/platform/soc/1c2b000.i2c/i2c-1/1-001e/trigger0
L: 0
E: DEVPATH=/devices/platform/soc/1c2b000.i2c/i2c-1/1-001e/trigger0
E: SUBSYSTEM=iio
$ gdbus introspect --system --dest net.hadess.SensorProxy --object-path /net/hadess/SensorProxy
:
interface org.freedesktop.DBus.Properties {
methods:
Get(in s interface_name,
in s property_name,
out v value);
GetAll(in s interface_name,
out a{sv} properties);
Set(in s interface_name,
in s property_name,
in v value);
signals:
PropertiesChanged(s interface_name,
a{sv} changed_properties,
as invalidated_properties);
properties:
};
interface org.freedesktop.DBus.Introspectable {
methods:
Introspect(out s xml_data);
signals:
properties:
};
interface org.freedesktop.DBus.Peer {
methods:
Ping();
GetMachineId(out s machine_uuid);
signals:
properties:
};
interface net.hadess.SensorProxy {
methods:
ClaimAccelerometer();
ReleaseAccelerometer();
ClaimLight();
ReleaseLight();
ClaimProximity();
ReleaseProximity();
signals:
properties:
readonly b HasAccelerometer = true;
readonly s AccelerometerOrientation = 'undefined';
readonly b HasAmbientLight = true;
readonly s LightLevelUnit = 'lux';
readonly d LightLevel = 0.40000000000000002;
readonly b HasProximity = true;
readonly b ProximityNear = false;
};
node Compass {
};
};
G_MESSAGES_DEBUG=all iio-sensor-proxy
:
** (process:5980): DEBUG: 00:11:41.829: Found device /sys/devices/platform/soc/1c2b000.i2c/i2c-1/1-0048/iio:device1 of type ambient light sensor at IIO Polling Light sensor
** (process:5980): DEBUG: 00:11:41.829: Found IIO poll proximity sensor at /sys/devices/platform/soc/1c2b000.i2c/i2c-1/1-0048/iio:device1
** (process:5980): DEBUG: 00:11:41.830: Found device /sys/devices/platform/soc/1c2b000.i2c/i2c-1/1-0048/iio:device1 of type proximity at IIO Poll proximity sensor
** (process:5980): WARNING **: 00:11:41.835: Could not find trigger name associated with /sys/devices/platform/soc/1c2b000.i2c/i2c-1/1-0068/iio:device2
** (process:5980): DEBUG: 00:11:41.835: Found IIO poll accelerometer at /sys/devices/platform/soc/1c2b000.i2c/i2c-1/1-0068/iio:device2
** (process:5980): DEBUG: 00:11:41.835: No auto-detected location, falling back to display location
** (process:5980): DEBUG: 00:11:41.836: Found device /sys/devices/platform/soc/1c2b000.i2c/i2c-1/1-0068/iio:device2 of type accelerometer at IIO Poll accelerometer
** (process:5980): DEBUG: 00:11:41.859: No auto-detected location, falling back to display location
** (process:5980): DEBUG: 00:11:41.859: Attribute in_accel_scale ('0.000598') found on sysfs
** (process:5980): DEBUG: 00:11:41.860: Near level: 250
** (process:5980): DEBUG: 00:11:41.867: Handling driver refcounting method 'ClaimLight' for ambient light sensor device
** (process:5980): DEBUG: 00:11:41.965: Light read from IIO: 4.000000, (scale 0.100000)
** (process:5980): DEBUG: 00:11:41.965: Light level sent by driver (quirk applied): 0.400000 (unit: lux)
...
Running monitor-sensor
as geoclue
reports No compass
. Setting FAKE_COMPASS=1 doesn't appear to change anything.
apt
tells me I have iio-sensor-proxy version 3.0 installed.