This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

Linux/ADS8688: unable to read data through the ti_ads8688.ko driver via libiio

Part Number: ADS8688

Tool/software: Linux

It seems i did post this question in the wrong forum and got redirected here.

i got a the ads8688 connected via SPI protocol.

It shows up in /sys/buses/iio/devices/iio:device0

I can run iio_info and it shows the device entries

prompt$>iio_info

Library version: 0.7 (git tag: v0.7)
IIO context created with local backend.
Backend version: 0.7 (git tag: v0.7)
Backend description string: Linux arm 4.9.10-bone4 #1 Thu Feb 16 19:35:11 UTC 2017 armv7l
IIO context has 1 devices:
	iio:device0: ads8688
		8 channels found:
			voltage6:  (input)
			5 channel-specific attributes found:
				attr 0: raw value: 39887
				attr 1: scale value: 0.312504320
				attr 2: offset value: -32768
				attr 3: offset_available value: -32768 0
				attr 4: scale_available value: 0.312504320 0.156254208 0.078127104
			voltage4:  (input)
			5 channel-specific attributes found:
				attr 0: offset value: -32768
				attr 1: raw value: 39887
				attr 2: scale value: 0.312504320
				attr 3: offset_available value: -32768 0
				attr 4: scale_available value: 0.312504320 0.156254208 0.078127104
			voltage0:  (input)
			5 channel-specific attributes found:
				attr 0: scale value: 0.312504320
				attr 1: raw value: 48303
				attr 2: offset value: -32768
				attr 3: offset_available value: -32768 0
				attr 4: scale_available value: 0.312504320 0.156254208 0.078127104
			voltage3:  (input)
			5 channel-specific attributes found:
				attr 0: scale value: 0.312504320
				attr 1: raw value: 32726
				attr 2: offset value: -32768
				attr 3: offset_available value: -32768 0
				attr 4: scale_available value: 0.312504320 0.156254208 0.078127104
			voltage7:  (input)
                                 [...]

This is fine, and i can read the voltage from channel 0, as you might see in the raw value for that channel in the listing above.

However I can not find some folders i was expecting to find, those used to enable/disable channels, the buffer, etc.

Anyhow, i tried to read from the device using the iio tools, but i got...

bs@arm:~$ iio_readdev iio:device0
Unable to allocate buffer: Invalid argument

I get the same result with my own code when calling iio_device_create_buffer: it fails with --EINVAL ( Invalid argument ).

Under further inspection of the libiio code i got suspicious about the return value of the iio_device_get_sample_size.

Calling iio_device_get_sample_size ( dev ) returns 0, and sets errno to: 13 ( permission denied ) if you are not root or  2 ( No such file or directory ) if you are running it as root.

In order to create the buffer iio_device_get_sample_size must be bigger than zero.

Also, i found out that calling iio_channel_enable() will not enable the channel, since a later call to iio_channel_is_enabled will return false. So it is very likely
that when retrieving the value for iio_device_get_sample_size, it finds out all the channels seem to be disabled, and thus returns Zero.

Given the implementation of both iio_channel_enable, i am quite sure it is due to some missing features at the driver, the missing scan-elements folder / habilities
or something like that.

I think this is a flaw or an issue at the ti_ads8688.c driver. Is there an updated ti_ads8688.c driver i could try r any plans to update it?
Does anyone have idea of how to read programmatically through the iio_device?

Thanks in advance.