iis2mdc magnetometer not writing timestamp
I am trying to get the raw data (with timestamp included) from a few IIO devices (hardware sensors, such as accelerometer, gyroscope, magnetometer and barometer) mounted on a linux platform and with the ST drivers. I was able to get the data for the accelerometer and for the gyroscope using the libiio library within a C++ code or using sysfs commands (enabling the buffer). However, for the magnetometer and for the barometer it seems (I'm not expert in this field) this procedure doesn't work. In particular, with the magnetometer (device2), I am able to get the data but not the timestamp (that remains 0).
root@dab:/sys/devices/platform/soc@0/soc@0:bus@30800000/30a50000.i2c/i2c-3/3-001e/iio:device2/buffer# hexdump -C /dev/iio:\device2
00000000 85 01 20 00 34 fe 00 00 00 00 00 00 00 00 00 00 |.. .4...........|
00000010 87 01 24 00 31 fe 00 00 00 00 00 00 00 00 00 00 |..$.1...........|
I've noticed, from the iio_info commands that there is a trigger set-up for the magnetometer, however it seems to me (I am not expert in this field) it isn't really working (as we're able to get the data but not the timestamp), so the problem might be elsewhere. I thought there might be a problem in the location (some REGs maybe?) where the timestamp is written, but I am not sure, as this is the first time I work with sensors.
Is there anything I could check to see why am I getting this problem and how to solve it?
This is the output of the "iio_info" command:
Library version: 0.19 (git tag: v0.19) Compiled with backends: local xml ip usb serial IIO context created with local backend. Backend version: 0.19 (git tag: v0.19) Backend description string: Linux dab 5.4.193-toradex #1 SMP PREEMPT Fri Oct 6 13:55:59 CEST 2023 aarch64 IIO context has 1 attributes: local,kernel: 5.4.193-toradex IIO context has 6 devices: .... iio:device2: iis2mdc (buffer capable) 4 channels found: magn_x: (input, index: 0, format: le:S16/16>>0) 3 channel-specific attributes found: attr 0: raw ERROR: Device or resource busy (-16) attr 1: scale value: 0.001500 attr 2: scale_available value: 0.001500 magn_y: (input, index: 1, format: le:S16/16>>0) 3 channel-specific attributes found: attr 0: raw ERROR: Device or resource busy (-16) attr 1: scale value: 0.001500 attr 2: scale_available value: 0.001500 magn_z: (input, index: 2, format: le:S16/16>>0) 3 channel-specific attributes found: attr 0: raw ERROR: Device or resource busy (-16) attr 1: scale value: 0.001500 attr 2: scale_available value: 0.001500 timestamp: (input, index: 3, format: le:S64/64>>0) 5 device-specific attributes found: attr 0: consumers ERROR: Input/output error (-5) attr 1: current_timestamp_clock value: realtime attr 2: sampling_frequency value: 10 attr 3: sampling_frequency_available value: 10 20 50 100 attr 4: suppliers ERROR: Input/output error (-5) 2 buffer-specific attributes found: attr 0: data_available value: 16 attr 1: watermark value: 1 Current trigger: trigger0(iis2mdc-trigger) ... attr 1: watermark value: 1 trigger0: iis2mdc-trigger 0 channels found: 2 device-specific attributes found: attr 0: consumers ERROR: Input/output error (-5) attr 1: suppliers ERROR: Input/output error (-5)
