502 Commits

Author SHA1 Message Date
Guido Günther
fe56bdba12 tests: Skip some test when fr_FR locale isn't available
Some test require that locale so skip those when it is unavailable.

Closes: #392
2024-04-07 16:13:08 +00:00
Sicelo A. Mhlongo
9833a28080 support switch-type proximity sensors
Support binary, switch-type proximity sensors. They are are exposed over the
input subsystem, emitting the SW_FRONT_PROXIMITY event code.

Also provide simple tests, based on the tests for evdev-based accelerometers.

Fixes #363
2024-03-12 01:26:47 +02:00
Guido Günther
d9e306c781 README: Fix link to API docs 2024-03-06 15:13:41 +01:00
Yauhen Kharuzhy
1f5069d13f iio-buffer-utils: Correctly disable sensors when exiting
The enable_sensors() function has an error preventing sensor
disabling: it checks if the sensor is already enabled and does nothing
even if we need to disable it.

Also, there is lack of error handling in the _write_sysfs_int()
function: the result of fprintf() is not checked. If some error occurs
during writing to the sysfs attribute, it is ignored.

Fix these errors and change the order of sysfs attribute writing during
device releasing to avoid "Device or resource busy" errors (a buffer
should be disabled before scan elements).
2024-01-04 22:27:52 +02:00
Yauhen Kharuzhy
408f75ff29 main: Implement a graceful shutdown
Gracefully stop the main loop and release used drivers upon receiving a
termination signal.

Without this, iio kernel drivers are not released, and modules cannot
be unloaded after iio-sensor-proxy termination.
2024-01-04 22:27:52 +02:00
Guido Günther
1ecb9fbb48 ci: Fix destination path
Moving multiple files into a non existent target folder won't work.
Just move the whole directory instead.

While at that list the folder content so we get an idea what CI
produced.
2023-12-25 12:18:39 +01:00
Guido Günther
2c9aaba33b ci: Publish docs via gitlab-pages 2023-12-24 16:32:28 +01:00
Raymond Hackley
a0ff1fe4b0 light: Add support for "illuminance_clear" light sensors
That would be used in the cm36651 kernel driver, as well as devices with
multiple channels, such as combined proximity and light sensors, which use
"illuminance_clear" as the channel name.
2023-11-21 18:17:43 +01:00
Dylan Van Assche
8f53394fb5 CI: more fixes
Passed fine in MR, but not in master
2023-11-21 18:16:31 +01:00
Dylan Van Assche
b38c8da204 CI: fix dnf
Fedora is switching from dnf to dnf5, handle both in CI.
2023-11-21 18:06:14 +01:00
Bastien Nocera
29c79c9e3b 3.5 2023-07-25 10:28:22 +02:00
Gioele Barabucci
caa0318903 build: Install D-Bus policy in /usr/share, not /etc
dbus supports policy files in both /usr/share/dbus-1/system.d and
/etc/dbus-1/systemd. The recently released dbus 1.14.0, officially
deprecates installing packages' default policies into /etc/dbus-1/systemd,
instead reserving it for the sysadmin. This is the same idea as the
difference between /usr/lib/udev/rules.d and /etc/udev/rules.d.

See https://bugs.debian.org/1006631
2023-07-24 15:54:21 +02:00
Bastien Nocera
48cb957c41 tests: Add test for available sampling frequencies
Add 2 tests for parsing the *sampling_frequency_available sysfs attribute
and then picking the closest supported value higher then the desired 10 Hz:

1: Check whether the sampling frequency gets corrected to >= 10Hz,
   integer numbers sorted low to high

2: Check whether the sampling frequency gets corrected to >= 10Hz,
   double numbers sorted high to low
2023-04-21 18:08:57 +02:00
Hans de Goede
b888499f50 iio: Fix iio_fixup_sampling_frequency() picking an unsupported sampling_frequency
Some iio drivers only accept sampling_frequency values listed in
sampling_frequency_available and will reject any other values with
an EINVAL error.

This causes iio_fixup_sampling_frequency() to fail to fixup
the sampling rate making screen-rotation really really slow on
e.g. devices where the st_accel driver is used.

Add support for parsing sampling_frequency_available and pick
a value from there to fix this.

As part of this also switch to using g_ascii_dtostr() to format
the string to write so that numbers which are not whole can be
represented.
2023-04-21 18:08:57 +02:00
Bastien Nocera
c8b528b020 tests: Add some tests to the test suite
test-mount-matrix and test-orientation were both built, but never run as
part of the automated test suite.
2023-04-21 14:39:30 +02:00
Bastien Nocera
43f093115f ci: Use detached pipelines
See https://gitlab.freedesktop.org/freedesktop/freedesktop/-/issues/438#what-it-means-for-me-a-maintainer-of-a-project-part-of-gitlabfreedesktoporg
2023-03-15 13:49:32 +01:00
Pinienzapfen
5a1a5df532 Fix sensor hotplugging
Hotplugged sensors were not working because of the missing
DEVICE_FOR_TYPE entry.

Logged error message:
driver_set_polling: assertion 'sensor_device' failed

Fixes: 4baa1f ("main: Make it possible to instantiate multiple drivers")
2022-12-23 18:26:32 +01:00
Bastien Nocera
cd6d5e653e 3.4 2022-07-15 15:08:38 +02:00
Bastien Nocera
4b84a36f15 README: Add some docs on using fake-input-accelerometer 2022-07-13 17:12:27 +02:00
Bastien Nocera
fbdddf0638 fake-input-accelerometer: Fix test program not working
We forgot to "steal" the pointer before returning from the function
successfully, so the file descriptor was closed. Oops.

Fixes: cc11240 ("fake-input-accelerometer: Simplify error paths")
2022-07-13 17:09:10 +02:00
Bastien Nocera
40e055b7c8 tests: Fix error running tests with Python 3.11
In 664448d81f
the "errors" attribute was removed from the _Outcome object. Adapt the
code to print the daemon log after a failed run().
2022-06-24 13:32:52 +02:00
Bastien Nocera
e4f0e05af3 tests: Make tests a build option
And don't skip tests if any test dependencies are missing.
2022-04-04 17:51:47 +02:00
Bastien Nocera
ad2c296b46 iio: Fix sysfs attribute verification failing
sysfs usually appends newlines at the end of attributes to make them
easier to consume, but the test suite can't test for that.

** (iio-sensor-proxy:4882): WARNING **: 14:14:46.792: Possible failure in string write of 'accel_3d-dev0
' Should be 'accel_3d-dev0' written to /sys/devices/platform/AMDI0010:02/i2c-2/i2c-BMA250E:00/0018:6243:0001.0002/HID-SENSOR-200073.2.auto/iio:device0/trigger/current_trigger

Closes: #347

Fixes: ac053f8a12
2022-03-29 21:57:13 +02:00
Bastien Nocera
3d67c6dc83 iio: Remove left-over debug 2022-03-29 21:48:17 +02:00
Bastien Nocera
7124a42d34 tests: Bump timeout when running under valgrind 2022-03-25 16:55:38 +01:00
Bastien Nocera
5ba03b0636 main: Fix warning in accel_changed_func()
From Coverity:
iio-sensor-proxy-3.3/src/iio-sensor-proxy.c:727:16: warning[deadcode.DeadStores]: Value stored to 'orientation' during its initialization is never read
2022-03-25 16:45:26 +01:00
Bastien Nocera
ac053f8a12 iio: Remove fscanf usage in _write_sysfs_string()
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:435: dont_call: "fscanf" assumes an arbitrarily long string, so callers must use correct precision specifiers or never use "fscanf".

This also fixes the temp variable being reused to parse the contents of
the sysfs file before being freed. How this behaves depends on the
length of the sysfs file path and the length of the string inside the
file.
2022-03-25 16:45:26 +01:00
Bastien Nocera
7ba893a6c9 iio: Simplify _write_sysfs_string()
Use g_autofree to avoid a goto on error.
2022-03-25 16:45:26 +01:00
Bastien Nocera
62bb35960e iio: Fix filename variable leak in build_channel_array()
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:289: leaked_storage: Variable "filename" going out of scope leaks the storage it points to.
2022-03-25 16:45:25 +01:00
Bastien Nocera
d87732b64c iio: Fix channel info leak in build_channel_array()
On error, the channel info would just be left unfreed.

From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:330: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:312: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:304: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:302: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:293: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:289: leaked_storage: Variable "current" going out of scope leaks the storage it points to.
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:350:2: warning[unix.Malloc]: Potential leak of memory pointed to by 'current'
2022-03-25 16:45:18 +01:00
Bastien Nocera
18a043f37f iio: Fix leak in buffer_drv_data_free()
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:769: noescape: Resource "buffer_data" is not freed or pointed-to in "buffer_drv_data_free".
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:770:3: warning[unix.Malloc]: Potential leak of memory pointed to by 'buffer_data'
2022-03-25 16:45:04 +01:00
Bastien Nocera
a4b1f3ee09 mount-matrix: Fix unchecked return value
From Coverity:
iio-sensor-proxy-3.3/src/accel-mount-matrix.c:86: check_return: Calling "parse_mount_matrix" without checking return value (as is done elsewhere 10 out of 11 times).
2022-03-25 12:41:15 +01:00
Bastien Nocera
6a4d5fab95 mount-matrix: Split off getting the identity mount matrix 2022-03-25 12:41:15 +01:00
Bastien Nocera
2e3d7bb735 main: Check g_setenv() return value
From Coverity:
iio-sensor-proxy-3.3/src/iio-sensor-proxy.c:964: check_return: Calling "g_setenv("G_MESSAGES_DEBUG", "all", 1)" without checking return value. This library function may fail and return an error code.
2022-03-25 12:41:11 +01:00
Bastien Nocera
a279a80502 iio: Fix filename leak in iioutils_get_param_float()
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:173: leaked_storage: Variable "filename" going out of scope leaks the storage it points to.
2022-03-25 12:41:07 +01:00
Bastien Nocera
1f4e5cff01 iio: Fix filename variable leak in iioutils_get_type()
From Coverity:
iio-sensor-proxy-3.3/src/iio-buffer-utils.c:111: overwrite_var: Overwriting "filename" in "filename = g_build_filename(device_dir, "scan_elements", builtname, NULL)" leaks the storage that "filename" points to.
2022-03-25 12:41:01 +01:00
Bastien Nocera
0ca8016560 iio: Simplify iioutils_break_up_name()
Use g_auto() to simplify the memory management.
2022-03-25 11:49:39 +01:00
Bastien Nocera
418f00ac40 build: Fix run_command() usage in newer meson
WARNING: You should add the boolean check kwarg to the run_command call.
         It currently defaults to false,
         but it will default to true in future releases of meson.
         See also: https://github.com/mesonbuild/meson/issues/9300
2022-03-25 11:48:59 +01:00
Bastien Nocera
716ee37d51 main: Prefer buffer driver to polling driver
In c7fb43e0, we added a buffer driver for ambient light sensors, but we
added it to the list of drivers in a way that would favour polling
drivers. Since we started using IIO_SENSOR_PROXY_TYPE to tag devices,
and as those can support multiple drivers, we need to prefer the buffer
driver as it's the one that doesn't require constant monitoring.

This also fixes operations on some Dell laptops where the polling driver
is completely broken.

See https://gitlab.freedesktop.org/hadess/iio-sensor-proxy/-/merge_requests/352
2022-03-15 10:57:26 +01:00
Bastien Nocera
1728742047 drivers: Print debug when accelerometers are ignored 2022-03-14 13:00:10 +01:00
Bastien Nocera
6a07e25826 accel: Add enum to string helper 2022-03-14 13:00:10 +01:00
Guido Günther
bba4560748 README: Document near-level property
Linux 5.6 added the near level property in 445b16fb6bdc2 which can
be used in DT based devices to give a default.
2021-12-21 17:00:43 +01:00
Bastien Nocera
0b1574d0eb main: Check whether user is allowed to claim a sensor
Check whether a particular user/D-Bus client is allowed to claim a
sensor.

The ClaimCompass method on net.hadess.SensorProxy.Compass doesn't have a
check as only the geoclue user is allowed to access this interface, as
per the D-Bus configuration.
2021-09-29 12:06:55 +02:00
Bastien Nocera
abd16b5911 tests: Start mock polkitd in the tests
And allow all us to perform all the actions.
2021-09-29 11:54:26 +02:00
Bastien Nocera
63a84af6a2 data: Add polkit policy description
Describe and set defaults for claiming sensors.
2021-09-29 11:54:26 +02:00
Bastien Nocera
b68811417e tests: Split the integration test into individual tests
unittest_inspector.py lists the tests in the integration-test.py script,
which are then added as individual tests.
2021-09-07 11:06:25 +02:00
Bastien Nocera
74b71d9a3b tests: Rename integration test script
Add the python suffix.
2021-09-07 10:50:35 +02:00
Bastien Nocera
a7b603270f main: Print version in debug output on startup
This will stop needing to ask users that read the README when reporting
bugs but don't include this info.
2021-08-19 20:35:46 +02:00
Bastien Nocera
860405323b ci: Remove libgudev manual installation
The package is already available in repositories.
2021-08-19 20:35:46 +02:00
Bastien Nocera
83d963b345 3.3 2021-08-16 14:52:44 +02:00