cbufferiio

How to send data to two iio channels syncroniously?


I'm using AD9361 on FMCOMMS-3 board to control some optical setup. To do so I need to send one signal to the first device (x-axis acousto-optical deflector) and another signal to the second device (y-axis AOD). It is crucial, that the signals for x and y are synced (sent simultaneously).

I operate with the chip via libiio. I've filled the buffers corresponding to both axes with the desired data (there are 2 buffers corresponding to 2 devices).

In theory, now I have to call iio_buffer_push() on both buffers, but AFAIK this function is synchronous - it will return only after all the data is sent by the device. How can I push buffers to two devices, so that the transmitted signals will be sent simultaneously?


Solution

  • You can use iio_buffer_set_blocking_mode() to set an iio_buffer to non-blocking mode. That way, iio_buffer_push() will not block, and will return immediately. e.g. see this documentation.

    e.g.

        iio_buffer_set_blocking_mode(somebuff, false); // Set non-blocking mode
        iio_buffer_push(somebuff); // Returns immediately
        iio_buffer_push(otherbuff);