DAQmxRegisterEveryNSamplesEvent

NI-DAQmx C Reference Help

Edition Date: January 2019

Part Number: 370471AM-01

»View Product Info
Download Help (Windows Only)

int32 DAQmxRegisterEveryNSamplesEvent (TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, uInt32 options, DAQmxEveryNSamplesEventCallbackPtr callbackFunction, void *callbackData);

Purpose

Registers a callback function to receive an event when the specified number of samples is written from the device to the buffer or from the buffer to the device. This function only works with devices that support buffered tasks.

When you stop a task explicitly any pending events are discarded. For example, if you call DAQmxStopTask then you do not receive any pending events.

Parameters

Input
Name Type Description
taskHandle TaskHandle The task used in this function.
everyNsamplesEventType int32 The type of event you want to receive.
Value Description
DAQmx_Val_Acquired_Into_Buffer This event type is only supported for input tasks. Events occur when the specified number of samples are acquired into the buffer from the device.
DAQmx_Val_Transferred_From_Buffer This event type is only supported for output tasks. Events occur when the specified number of samples are transferred from the buffer to the device.
nSamples uInt32 The number of samples after which each event should occur.
options uInt32 Use this parameter to set certain options. You can combine flags with the bitwise-OR operator ('|') to set multiple options. Pass a value of zero if no options need to be set.
Value Description
0 The callback function is called in a DAQmx thread. This is the default value.
DAQmx_Val_SynchronousEventCallbacks The callback function is called in the thread which registered the event. In order for the callback to occur, you must be processing messages.

Windows This option is supported only on Windows.

Note If you are receiving synchronous events faster than you are processing them, then the user interface of your application might become unresponsive.
callbackFunction DAQmxEveryNSamplesEventCallbackPtr The function that you want DAQmx to call when the event occurs. The function you pass in this parameter must have the following prototype:

int32 CVICALLBACK Callback (TaskHandle taskHandle, int32 everyNsamplesEventType, uInt32 nSamples, void *callbackData);

Upon entry to the callback, the taskHandle parameter contains the handle to the task on which the event occurred. The everyNSamplesEventType parameter contains the value you passed in the everyNSamplesEventType parameter of this function. The nSamples parameter contains the value you passed in the nSamples parameter of this function. The callbackData parameter contains the value you passed in the callbackData parameter of this function.

Passing NULL for this parameter unregisters the event callback function.
callbackData void * A value that you want DAQmx to pass to the callback function as the function data parameter. Callback functions may be called even after a task is cleared. Do not pass the address of a local variable, a variable associated with a cleared task, or any other variable that might not be valid when the function is executed.

Return Value

Name Type Description
status int32 The error code returned by the function in the event of an error or warning. A value of 0 indicates success. A positive value indicates a warning. A negative value indicates an error.

WAS THIS ARTICLE HELPFUL?

Not Helpful