IIO buffer refill time out

1.7k views Asked by At

I would like to read the values of an IMU sensor from a C project. The device in question is the LSM6DSL, and I am using the IIO kernel drivers. They are working correctly because I am able to read the values by using the command :

cat /sys/bus/iio/devices/iio:device0/in_accel_x_raw
> 2

The issue is that when I want to refill my buffer using the function iio_buffer_refill(struct iio_buffer *buffer) it returns the error code 110, which is a time out. Before that, I enabled some channels to read from, and the buffer was successful created. I made some research about this problem and I believe it is linked with the Interrupt parameters from the device tree.

Here is my device tree for the i2c protocol (I took an example from this link):

lsm6dsl@6b {                                                                  
            compatible = "st,lsm6dsl";                                            
            reg = <0x6b>;                                                         
            interrupt-parent = <&gpio>;                                           
            interrupts = <26 0x4>;                                                
           };

Is it really related to the device tree or am I missing something else ? Thanking you in advance.

[Edit] Here is the source code that creates the buffer and tries to read from it:

struct iio_context *context = iio_create_local_context();
struct iio_device *device = iio_context_get_device(context, 1);
struct iio_channel *chan = iio_device_get_channel(device, 0);
iio_channel_enable(chan);
struct iio_buffer *buff = iio_device_create_buffer(device, 1, false);
if (buff == NULL)
{
  printf("Error %d: %s\n", errno, strerror(errno));
  return (1);
}
printf("Read size is: %ld\n", (long)iio_buffer_refill(buff));
iio_buffer_destroy(buff);

> Read size is: -110
0

There are 0 answers