Sampling Completion

Sampling stops in cases when Sampling stop condition is satisfied, specified buffer area is filled with transferred data, or compulsive stop is executed in the CntSamplingStop function.

You can indicate Sampling stop condition with CntSetSamplingStopTrigger function.
You can indicate Sampling buffer with CntSamplingSetBuffer function.


There are the following two methods to confirm that sampling has completed.


1. Perform notification by sampling stop message

The sampling completion can be confirmed in the CntNotifySamplingStop function by sending message to specified window when sampling completed.

Moreover, it is also possible to notify the completion of specified times during sampling in the CntNotifySamplingCount function.


2. Perform monitoring by polling sampling status

The sampling completion can be confirmed in the CntGetSamplingStatus function by monitoring CNTS_STATUS_BMSTOP and CNTS_STATUS_CNTSTOP for received status.

It is possible to retrieve the current sampling data number in the CntGetSamplingCount function.


It is common to both of the two methods, the operation of accessing a device during high-speed sampling will interrupt the sampling. The sampling is temporarily interrupted in cases when interrupt occurred frequently for that the notification number of the CntNotifySamplingCount function is small, and the CntGetSamplingStatus function and the CntGetSamplingCount function are called.

The transfer error occurred during high-speed sampling if the 3rd argument Err indicates Error information with calling CntGetSamplingStatus function.
In this case, please try to enlarge the notification number parameter of the CntNotifySamplingCount function, or decreasing the calling frequency of the CntGetSamplingStatus function and the CntGetSamplingCount function.

Before processing sampling data or preparing for the next transfer, be sure to confirm that the transfer has been completed in one of the methods before starting the next process. (The same applies when using CntSamplingStop.)

Other Notes

If the buffer for sampling has been set by CntSamplingSetBuffer function in a thread, when the thread is terminated, memory lock will be released and the sampling will end by forced. Therefore, do not terminate the thread until the sampling has completed.