05-18-2011 08:15 PM
Hi,
I'm trying to get an ibnotify callback system working. At the moment I'm just trying to develop an example program to emulate an instrument's GPIB interface. The example program (interrupt_test.cpp) is running on a windows XP system, with NI VISA 5.0. I'm building all my code in Visual Studio 2008. The system controller is an older machine running NI-488.2 version 1.70.
Because I'm trying to do instrument emulation, I set up the GPIB interface as a non-system controller as follows:
//initialize GPIB bus
noncontroller = ibfind("gpib0");
//release system control
ibrsc(noncontroller,0);
//change the primary address
ibpad(noncontroller,2);
I set up ibnotify as follows:
ibnotify(noncontroller, gpibMask, gpibCB, NULL);
with gpibMask = (LACS|TACS|DCAS|CMPL);
My Callback is then defined as
int __stdcall gpibCB(int ud, int localIbsta, int localIberr, long localIbcntl, void *refData)
The problem is that the callback never triggers. If I set my original mask to only LACS - it will trigger, but it won't re-trigger for the next case (when I want to say, be addressed as a talker).
I'm attaching the example code I've written, and I'm really hoping someone can help me find the problem here - I know there must be something obvious I'm missing.
Thank you,
Lex
05-19-2011 10:44 AM
Ok I have the callback triggering -
I accomplished this by using a global variable for the mask that is shared between the main program and the callback thread.
The problem now, is that I never hit my I/O complete state (if (localIbsta & CMPL)) in the callback.
After a write to my program (listener state) I set my mask to (TACS|DCAS|CMPL)
Again - any ideas?
Thanks,
Lex
05-19-2011 11:03 AM
Ok - Sheepish grin -
It appears I've figured it out - I was missing a critical case statement in the read state -
resetting the system to the idle state and removing the i/o complete mask was important, if there was nothing on the output buffer 🙂
currentIo = idleState;
gpibMask = (DCAS | LACS);
Thanks again,
I think I'm all set
Lex