AnsweredAssumed Answered

iio_buffer_refill return -22 & -5

Question asked by jcsistemas2001 on Dec 12, 2015
Latest reply on Dec 13, 2015 by jcsistemas2001

Hi,

 

I'm using the libiio to acquire data from a SPI device @1KHz. I just wondering if somebody could give a suggestion about it.

 

The application fail at:

 

ret = iio_buffer_refill(buffer);

 

The function return -22 or -5 as bellow:

 

Call to trigger_handler(int irq, void *p) at SPI IIO Device driver

 

 

Driver: Call to trigger_handler(int irq, void *p) at SPI IIO Device driver
Application: ret = -22, error = Invalid argument
Application: ret = -5, error = Input/output error
Application: ret = -22, error = Invalid argument
Application: ret = -22, error = Invalid argument
Application: ret = -5, error = Input/output error
Driver:Call to trigger_handler(int irq, void *p) at SPI IIO Device driver
Application:ret = -22, error = Invalid argument
Application:ret = -22, error = Invalid argument
Application:ret = -5, error = Input/output error
Application:ret = -5, error = Input/output error
Application:ret = -22, error = Invalid argument
Driver:Call to trigger_handler(int irq, void *p) at SPI IIO Device driver
Application:ret = -22, error = Invalid argument
Application:ret = -5, error = Input/output error
Application:ret = -22, error = Invalid argument
Application:ret = -22, error = Invalid argument
Application:ret = -22, error = Invalid argument

 

I already report this issue at linux-iio list. I paste the same message here as reference (Gmane -- read  dev iio:device0 return  1  Invalid argument):

 

---------

I get an error trying to read /dev/iio:device0 in a custom application

(C/C++), however in a terminal the command "cat /dev/iio_device0"

return data.

 

Below the procedure:

 

- enable channels

- setup trigger

- setup buffer lenght

- enable buffer (the SPI interrupt is setup properly and all the

trigger handler are done)

- read /dev/iio_device0

 

It's a SPI device acquiring 27 bytes <at> 1KHz.

 

Results:

 

1. Custom application (based on generic_buffer.c): function 'read'

return -1 and strerror(errno) return "Invalid argument"

2. iio_readdev (libiio): show the message "Unable to refill buffer:

Input/output error"

3. In terminal, the command "cat /dev/iio_device0" show values (no

readable) while the buffer is enable.

---------

Outcomes