The DIO read function is a synchronous function call, which means that the rest of your code will wait for that call to complete before continuing. There are a few ways to program your input and output operations to take this into account.
The easiest way is to program using two DIO reads as follows:
1st DIO Read will be setup to read 0 scans. From this call we can find out how many reading are in the buffer through the scans backlog output.
The 2nd DIO read can be in a case statement and will execute with the desired number of scans to read (X) is available. We can compare the scans backlog to X and if true execute the 2nd DIO read.
Both of these operations will execute in a loop if you are doing continuous operations. If you are simply reading on
e buffer then the first DIO read will be in a loop which will execute until X number of points are available, the the second DIO read will execute after the loop is completed.
This programming technique effectively allows you to make your DIO read an asynchronous call. Which means it will only read the data when the data is available, and not hold up the rest of the program in the mean time.
Good Luck with your project.