Measurement Studio for VC++

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxRegisterEveryNSamplesEvent; Compiler error regarding the Callback function.

I am running in circles sice a few hours now. I do have a managed project VC++ in Visual Studio and try to read a thermocouple in this project. The plan is to use the Legacy C-interface. I do not have the Measurement Studio, so I have to figure out how to do that w/o .NET. So therefore I created a unmanaged class handling my thermocouple.

 

The configuration of the thermocouple channel is done in the constructor and looks as follows:

 

    signed long RetVal = 0;
    RetVal = DAQmxCreateTask("TempTask",&taskTempHandle);
    RetVal = DAQmxCreateAIThrmcplChan(taskTempHandle,"Dev2/ai0","",-60.0,100.0,DAQmx_Val_DegC,DAQmx_Val_J_Type_TC,DAQmx_Val_BuiltIn,25.0,"");
    RetVal = DAQmxCfgSampClkTiming(taskTempHandle,"",10.0,DAQmx_Val_Rising,DAQmx_Val_ContSamps,NUM_SAMPLES);

 

Everything seems to work up to this point, all functions return 0.

 

Then I am trying to set the Callback for the samples event: 
    RetVal = DAQmxRegisterEveryNSamplesEvent(taskTempHandle, DAQmx_Val_Acquired_Into_Buffer, NUM_SAMPLES, 0, &Thermocouple::EveryNCallback, NULL);

 

Compiler Errors:

.\Thermocouple.cpp(13) : error C2664: 'DAQmxRegisterEveryNSamplesEvent' : cannot convert parameter 5 from 'int32 (__cdecl Thermocouple::* )(TaskHandle,int32,uInt32,void *)' to 'DAQmxEveryNSamplesEventCallbackPtr'
        There is no context in which this conversion is possible
c:\work\upa\aw system\software\sensor environmental tester\sensor environmental tester\Thermocouple.h(10) : error C3641: 'Thermocouple::EveryNCallback' : invalid calling convention '__cdecl ' for function compiled with /clr:pure or /clr:safe
Build log was saved at "file://c:\work\UPA\AW System\Software\Sensor Environmental Tester\Sensor Environmental Tester\Debug\BuildLog.htm"
Sensor Environmental Tester - 2 error(s), 0 warning(s)

 

It seems that there two problems and I just can't figure out how to get arround them:

 

1) The Callback does not work.

2) VS has a problem with CVICALLBACK the callback function, I undefined that in NIdaqMX.h, which solves the problem but I am not sure if this is a good idea

 

Can anybody help me? Please? I attached what I have so far.

Thanks

Download All
0 Kudos
Message 1 of 2
(6,466 Views)

Take a look at this Developer Zone example:

 

DAQmx Cont. Analog Output Using the Every N Sample Event

 

This is an example that uses the DAQmxRegisterEveryNSamplesEvent callback correctly. 

 

Regards,

Mark E.

Applications Engineer

National Instruments

 

 

 

 

Message Edited by EadieU on 02-10-2009 05:42 PM

Mark E.
National Instruments

0 Kudos
Message 2 of 2
(6,443 Views)