/* This program demonstrates the use of some of the NI-VXI signal functions. * This program routes all signals to the global signal queue, then waits for * signals to be written to the controller's signal register. You could also * route interrupts as signals using the RouteVXIint functions, but that is * not covered in this example. Please see your NI-VXI software reference * manual and the chapter covering NI-VXI Signal Functions for more detailed * information on handling signals. */ #include "nivxi.h" #include #include #include main() { INT16 ret, done = 0; UINT16 retsignal; /* holds the signal that we receive */ UINT32 retsignalmask; /* holds the type of signal we receive */ /* Launch VICtext? */ ret = InitVXIlibrary(); /* always init the VXI library */ printf("\nYou can run this program with VICtext. If it is not already"); printf("\nrunning, you can launch it now. To write a signal to the signal"); printf("\nregister with VICtext, type 'vxioutreg 0,8,0xfd00'. This will"); printf("\nwrite a signal with value 0xfd00 to the signal register"); printf("\n\nWrite a signal 0xfe00 to quite this program"); ret = RouteSignal(-1,0); /* route all signals to the signal queue */ ret = EnableSignalInt(); /* tell the CPU to accept writes to signal registers */ while (!done) /* loop until we receive signal 0xfe00 */ { /* Wait 10 seconds for a signal to come in */ ret = WaitForSignal(-1, 0xffff, 20000L, &retsignal, &retsignalmask); /* If we receive signal 0xfe00 or if we timeout tell program to stop */ printf("\nSignal! %x\n", retsignal); if ((retsignal == 0xfe00) || ret == -2) done = 1; } ret = DisableSignalInt(); /* tell CPU to ignore writes to signal register */ ret = CloseVXIlibrary(); printf("\nPress a key to exit..."); while (!kbhit()); return 0; }