From 04:00 PM CDT – 08:00 PM CDT (09:00 PM UTC – 01:00 AM UTC) Tuesday, April 16, ni.com will undergo system upgrades that may result in temporary service interruption.

We appreciate your patience as we improve our online experience.

Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

My callback function under MFC is never called back!

I am developming a MFC application using NIDAQ 6.7 driver and PCI-DIO-6533
for a new
data adquisition system at the Jicamarca Radio Observatory. It is my first
project with the
PCI card. I am having problems with the CALLBACK functions. Following are
relevant portions
of the source code that illustrates my problem:

.............................................................................
.......
void CallbackNidaq()
{
int j;
j=1234;
TRACE("I have entered the callback function \n");
}

void CCAMUView::OnCallbackNidaq()
{
HWND my_hwnd = m_hWnd ;
u32 direcion=0 ;
puntero = (unsigned char *)piBuffer;
puntero[4*NSAMPLES-1]=0;
puntero[4*NSAMPLES-2]=0;
puntero[4*NSAMPLES-3]=0;
puntero[4*NSAMPLES-4]=0;
iStatus = Config_DAQ_Event_Message(iDevice,(i16)1,//add message
"DIGRP0" , // string description
(i16)0 , // DAQEvent 0-> Adquire N scans
(i32)NSAMPLES , /*DAQTrigVal0*/
(i32)0 , //DAQTrigVal1
(u32)0 , //trigSkipCount
(u32)0 , //preTrigScans
(u32)0 , //postTrigScans
0 , // hwnd
0 , // to post WM_NIDAQ_MSG
(u32)CallbackNidaq) ; // function address
TRACE("I have already configured : status = %d\n",iStatus);
int iStatus2;
iStatus2 = DIG_Block_In(iDevice, iGroup, piBuffer, ulCount);
TRACE("I have started asinc Status2 = %d",iStatus2);
Sleep(1000);
TRACE("Buffer= %d %d %d %d \n",puntero[4*NSAMPLES-1],puntero[4*NSAMPLES-2],puntero[4*NSAMPLES-3],puntero[4*NSAMPLES-4]);
}
.....................................................
What I expect to happen is as follows:
After I configure the device I should get the first TRACE messages I do. I get
"I have already configured : status = 0" ,
"I have started asinc Status2 = 0"
To make sure the device has actually read a buffer full of data, I print out the contents of the last
four bytes which have been previously set to cero. They do show new values.

My problem is that the callback
function is never triggered.I never get the ""I have entered the callback
function"
message.

For your information, in case it helps. I have used the compiler debug to
find out the address of CallbackNidaq()
but it does not aggree with the address I get for the (u32)CallbackNidaq
address assign to the last argument of
the Config_DAQ_Event_Message function.
I would appreciate very much if you tell me What I am doing wrong.
Wishes.

Gabriel
0 Kudos
Message 1 of 2
(2,770 Views)
Hello Gabriel,

the propotype of your callback function is wrong; must be (without CALLBACK keyword):
void CallbackNidaq(HWND handle, UINT message, WPARAM wParam, LPARAM lParam)

See the Config_DAQ_Event_Message in NI-DAQ Help at the bottom.

Hope this will help you.

Grettings,
Alain
0 Kudos
Message 2 of 2
(2,770 Views)