ibnotify Usage

NI-488.2

ibnotify Usage

The ibnotify function is passed a unit descriptor, the bit mask of the desired GPIB events, the address of your callback function, and user-defined reference data. ibnotify has the following prototype:

C

unsigned long ibnotify (int ud, int mask, GpibNotifyCallback_t
              Callback, void * RefData)

Visual Basic (6.0)

CALL ibnotify (ud%, mask%, AddressOf 
               Callback&, RefData$)

or

status% = ilnotify (ud%, mask%, AddressOf 
                   Callback&, RefData$)

Input for ibnotify

ud Board or device descriptor
mask Bit mask of GPIB events to notice
Callback Pointer to the Callback function
RefData User-defined reference data for the callback

The ibnotify callback has the following prototype:

C

int __stdcall Callback (int LocalUd, unsigned long LocalIbsta, unsigned long LocalIberr, unsigned long LocalIbcnt, void *RefData)

Visual Basic (6.0)

Function Callback (LocalUd%, LocalIbsta%, LocalIberr%, LocalIbcnt&, RefData$)

Callback Parameters

LocalUd Board or device descriptor
LocalIbsta Value of Ibsta
LocalIberr Value of Iberr
LocalIbcnt Value of Ibcnt
RefData User-defined reference data for the callback

The Callback function is passed a unit descriptor, the current values of the NI-488.2 global variables, and the user-defined reference data that was passed to the original ibnotify call. The NI-488.2 driver interprets the return value for the Callback as a mask value that is used to automatically rearm the callback if it is non-zero.

You can view an example written in C of how you can use ibnotify in your application. Assume that your GPIB device is a multimeter that you program to acquire a reading by sending it "SEND DATA". The multimeter requests service when it has a reading ready, and each reading is a floating point value.

In this example, global functions/variables are shared by the Callback thread and the main thread, and the access of the global functions/variables is not protected by synchronization. In this case, synchronization of access to these global functions/variables is not necessary because of the way they are used in the application: only a single thread is writing the global values and that thread always just adds information (increases the count or adds another reading to the array of floats).

For overview information about asynchronous event notification within an NI-488.2 application, please refer to the Asynchronous Event Notification Overview section. For more specific information about ibnotify, please refer to the ibnotify function definition.

Note The ibnotify Callback is executed in a separate thread of execution from the rest of your application. If your application might be performing other NI-488.2 operations while it is using ibnotify , you should use the per-thread NI-488.2 global functions/variables that are provided by the Thread calls (ThreadIbsta, ThreadIberr, and ThreadIbcnt). In addition, if your application needs to share global functions/variables with the Callback , you should use a synchronization primitive (for example, semaphore) to protect access to any global variables. For more information about the use of synchronization primitives, refer to the documentation on using synchronization objects that came with your development tools.

Related Topics:

ibnotify Usage Example

ibnotify

GpibNotify

GpibNotify Usage