I am using IIO drivers from userspace to read the value of an ADC (AD7924). I have all steps to get a triggered acquisition working ( create a trigger, assign it, enable the ADC channels, set the dimension of the buffer, and enable it). Here is the code for this :
// Create IIO trigger
system("echo 0 > /sys/devices/iio_sysfs_trigger/add_trigger");
// Assign IIO trigger "sysfstrig0" to IIO AD7923 driver
system("echo sysfstrig0 > /sys/bus/iio/devices/iio:device0/trigger/current_trigger");
// Enable scan of the first 3 channels for AD7924
system("echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage0_en");
system("echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage1_en");
system("echo 1 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage2_en");
system("echo 0 > /sys/bus/iio/devices/iio:device0/scan_elements/in_voltage3_en");
// Dim IIO buffer and enable it
sprintf(CommandeADC, "echo %d > /sys/bus/iio/devices/iio:device0/buffer/length", NB_ECH);
system(CommandeADC);
system("echo 1 > /sys/bus/iio/devices/iio:device0/buffer/enable");
//Launch acquisition...
system("echo 1 > /sys/bus/iio/devices/trigger0/trigger_now");
The system configured like this will process acquisition, and fill the complete buffer. Once it is full the acquisition stops.
My question is : how can I know when the buffer is fully filled ? I tried using poll or select function on the file iio:device0 located in /dev/ to check changes in the file descriptor , but I was only able to know when the acquisition started (by checking for POLLIN event).