Problems in setting the trigger with lps22qs and iis2mdc sensors (magnetometer and barometer)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2024-02-09 11:06 AM
To make it more clear,
- Here the result of the iio_info command (the devices of interest are ilps22qs and iis2mdc, respectively the barometer and the magnetometer). From here you can also see that for the magnetometer there's already (not set up by me) a trigger (iis2mdc-trigger).
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:device1: ilps22qs (buffer capable) 3 channels found: pressure: (input) 2 channel-specific attributes found: attr 0: raw value: 4143498 attr 1: scale value: 0.000024414 temp: (input) 2 channel-specific attributes found: attr 0: raw value: 4278 attr 1: scale value: 10.000000000 timestamp: (input, index: 2, 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: 1 attr 3: sampling_frequency_available value: 1 4 10 25 50 75 100 200 attr 4: suppliers ERROR: Input/output error (-5) 2 buffer-specific attributes found: attr 0: data_available value: 0 attr 1: watermark value: 1 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)
Trying to work from the linux terminal (sysfs), so for example enabling the buffer with "sudo echo 1 > buffer/enable" (and similar commands) for the magnetometer I am able to obtain the data but not the timestamp, while in the case of the barometer I am not even able to enable the buffer (it says "1" is a wrong argument for the "enable" file). So I do not know how these problems are linked with the trigger and how to resolve them.
I also already tried to deactivate the trigger for the barometer (see the code below), but it then says it is not able to create the buffer. Same thing if I do not deactivate the trigger. I recall thatfor the barometer no trigger has been set-up, so maybe the problem is that I should create one instead of deactivating it... For the magnetometer I didn't try with the C++ code but from sysfs I was not able to get the timestamp and so I guess the problem will be the same if I try to work with the code.
So the questions are:
1. How can I get the "timestamp" for the magnometer?
2. How can I make the barometer work (data + timestamp)?
It's fine for me to work either from the linux terminal (sysfs) or with a C++ code.
Thanks in advance
trigger_device = iio_device_set_trigger(press_device, NULL); if (!trigger_device) { std::cerr << "Trigger not disabled" << std::endl; iio_context_destroy(ctx); return -1; }
- Labels:
-
DAC
-
I2C
-
STM32F2 Series
-
TIM
