Generally, in the high speed operation, user buffer is divided into two equal parts(1st half and 2nd half). The data from the device will fill them separately. Buffer change event will be triggered when either buffer is full.
(1).When the sampling started, driver writes data start from the 1st half.
(2). Driver throw a buffer change event to notify user's program on 1st half full. User's program should transfer the data in time, or might cause buffer overrun if the 2nd half full.
(3). At the same time, data log is keeping going on the 2nd half during the data transfer.
(4). When 2nd half full, driver throw a buffer change and data log back to the 1st half again. User's program start transfer data from the 2nd half. Back to graph (1) for next status.
In high-speed functions to transfer large amount of data, a larger buffer is required. Usually, we prefer to create a buffer with the size slightly more than we need to keep the fetching data in safe. If the data is not taken away in time after a buffer change event, an overrun event will be signaled, and the data would be overwritten by new ones.
.
After sampling ,we need copy the data from sampling data buffer to the transfer buffer for analyzing ,so that the transfer buffer should also be allocated. However, the size of the transfer buffer should be no less than 2*sampling count bytes when the data type is raw data, or no less than 4*sampling count bytes when the data type is float data.