Part Number: ADS8688 Tool/software: Linux Hi, how to read data of ADS8688 by using libiio .(in debian and kernel version: 4.4.54-ti-r93) I'm trying to read from ADS8688 using libiio, but when I create a buffer with iio_device_create_buffer I'm always getting a null. It is displaying errno 22 : Invalid argument I am using libiio version of v0.16 i am new to linuk device driver and libiio. Here i have attached the output of iio_info and my code iio_info output Library version: 0.16 (git tag: v0.16) Compiled with backends: local xml ip usb IIO context created with local backend. Backend version: 0.16 (git tag: v0.16) Backend description string: Linux beaglebone 4.4.54-ti-r93 #1 SMP Fri Mar 17 13:08:22 UTC 2017 armv7l IIO context has 1 attributes: local,kernel: 4.4.54-ti-r93 IIO context has 1 devices: iio:device0: ads8688 8 channels found: voltage0: (input) 5 channel-specific attributes found: attr 0: offset value: -32768 attr 1: offset_available value: -32768 0 attr 2: raw value: 32639 attr 3: scale value: 0.312504320 attr 4: scale_available value: 0.312504320 0.156254208 0.078127104 voltage1: (input) 5 channel-specific attributes found: attr 0: offset value: -32768 attr 1: offset_available value: -32768 0 attr 2: raw value: 65535 attr 3: scale value: 0.312504320 attr 4: scale_available value: 0.312504320 0.156254208 0.078127104 voltage2: (input) 5 channel-specific attributes found: attr 0: offset value: -32768 attr 1: offset_available value: -32768 0 attr 2: raw value: 65535 attr 3: scale value: 0.312504320 attr 4: scale_available value: 0.312504320 0.156254208 0.078127104 voltage3: (input) 5 channel-specific attributes found: attr 0: offset value: -32768 attr 1: offset_available value: -32768 0 attr 2: raw value: 65535 attr 3: scale value: 0.312504320 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: offset_available value: -32768 0 attr 2: raw value: 65535 attr 3: scale value: 0.312504320 attr 4: scale_available value: 0.312504320 0.156254208 0.078127104 voltage5: (input) 5 channel-specific attributes found: attr 0: offset value: -32768 attr 1: offset_available value: -32768 0 attr 2: raw value: 65535 attr 3: scale value: 0.312504320 attr 4: scale_available value: 0.312504320 0.156254208 0.078127104 voltage6: (input) 5 channel-specific attributes found: attr 0: offset value: -32768 attr 1: offset_available value: -32768 0 attr 2: raw value: 65535 attr 3: scale value: 0.312504320 attr 4: scale_available value: 0.312504320 0.156254208 0.078127104 voltage7: (input) 5 channel-specific attributes found: attr 0: offset value: -32768 attr 1: offset_available value: -32768 0 attr 2: raw value: 65535 attr 3: scale value: 0.312504320 attr 4: scale_available value: 0.312504320 0.156254208 0.078127104 and my code is int main() { bool cyclic = 0; unsigned int *data; struct iio_buffer *buf; unsigned int chan = 0; struct iio_channel *ch; unsigned int samples_count = 100; ctx = iio_create_default_context(); dev = iio_context_find_device(ctx," ads8688 "); chan = iio_device_get_channels_count(dev); printf("number of channel = %d\n",chan); struct iio_device *trigger = iio_context_get_device(ctx, 0); if(trigger == NULL) printf("tri cr errno %d:%s\n",errno,strerror(errno)); int err = iio_device_set_trigger(dev, trigger); if(err < 0) { printf("tri errno %d:%s\n",errno,strerror(errno)); } ch = iio_device_get_channel(dev, 0); if(ch == NULL) { printf("ch errno %d:%s\n",errno,strerror(errno)); } iio_channel_enable(ch); if(ch == NULL) { printf("ch errno %d:%s\n",errno,strerror(errno)); } buf = iio_device_create_buffer(dev, 1024, FALSE); if(buf == NULL){ printf("buf errno %d:%s\n",errno,strerror(errno)); } // iio_buffer_refill(buf); // for (data = iio_buffer_first(buf, ch);data < iio_buffer_end(buf);data += iio_buffer_step(buf)) // printf("%d\n", *data); // iio_buffer_destroy(buf); iio_channel_disable(ch); // receive(ctx); iio_context_destroy(ctx); return 0; } Please suggest me the solution as early as possible.Waiting for your reply soon Thanks and regards KUMUDA
↧