Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

NIDAQmxBase 'Refnum to Session in Fusion' error in OSX CodeWarrior

I am implementing data aquisition in CodeWarrior project using NIDAQmxBase framework.
(USB-6009 board, OSX 10.4.6, Metrower CodeWarrior 10.0, Mach-0, PowerPlant ).

Basically it works, however I run into several problems.
For some of them I found workarounds, but one is still unresolved.

Problem description:
First or/and second call of DAQmxBaseStartTask() function returns error
error# 0xBFFF000E
"Refnum to Session in Fusion.WriteThenRead.vi->Fusion.AIADC.getResolution.vi->USB-92xx
AI Start Get Info.vi->DAQmxBase Start Task 92xx.vi:2->DAQmxBase Start Task.vi:1->DAQmxBaseStartTask.vi->DAQmxBase"

In my application I have runDigitizer() function called in application main loop by user command.

OSStatus runDigitizer(...) // configuration parameters are omitted
{
OSStatus error = 0;
static TaskHandle gTaskHandle = NULL;
if (gTaskHandle) error = DAQmxBaseClearTask (gTaskHandle);
if (error==0) error = DAQmxBaseCreateTask ("", &gTaskHandle);
if (error==0) error = DAQmxBaseCreateAIVoltageChan (gTaskHandle,chanList,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL);
if (error==0) error = DAQmxBaseCfgSampClkTiming (gTaskHandle,"OnboardClock",mSamplingRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,mBlockSamples);
if (error==0) error = DAQmxBaseCfgInputBuffer (gTaskHandle,200000);
if (error==0) error = DAQmxBaseStartTask(gTaskHandle);
return error;
}

1) If runDigitizer() is called later in program (in application main loop), first call of runDigitizer() works fine, second call always results in above mention error, subsequent call are fine again.
Application Quit command is not working anymore.

2) If I call DAQmxBaseCreateTask() in main() function before application main loop, the behavior is different.
First and sometimes a second call of runDigitizer() fail with 0xBFFF000E error, then everything runs as expected.
Application Quit command is working fine in this case.

Any suggestions?
0 Kudos
Message 1 of 3
(2,744 Views)

Hello

Thanks for contacting National Instruments.Its saha.

I have searched about the error you have pointed.I guess your NI-DAQmxBase Driver version is 1.4 or earlier with which this is a common issue.If this is the case, I would suggest you to upgrade your driver to version 1.5 or later which is available from the following site.

Multifunction DAQ:

http://digital.ni.com/softlib.nsf/webcategories/85256410006C055586256BBB002C1293?opendocument&node=1...

If your problem is not solved, let me know.

Best of luck

saha | Application Engineer | National Instruments,Japan

0 Kudos
Message 2 of 3
(2,728 Views)
Thanks for the answer.
I am using NI-DAQmx Base Version 2.0 for Mac OS X. I think this is the most recent upgrade. Nevertheless I'll reinstall the package when I will be back from vacation.
From what I see I may conclude my problem is related to handler calling sequence.

Looks like some of event handlers installed during driver initialization are overwritten by PowerPlant handlers and vice versa. Under 'overwritten' I mean handler returns YES handled result on completion and command does not propagate further in command chain. In this way application Quit command handler is intercepted, and application does respond to Quit command if NI-DAQmx initialized after PowerPlant initialization. However if I call DAQmxBaseCreateTask function before PowerPlant handlers are installed, Quit command is working fine, because application quit handler is called first.

Alternatively some events may not reach driver because PowerPlant handler reports it handles the event.

At least in my case everything starts working only after second driver initialization.

1. First driver initialization (DAQmxBaseCreateTask).
2. Application initialization (PowerPlant event handlers are installed);
At this point DAQmxBaseStartTask returns error, because some handlers were overwritten during PowerPlant initialization.
3. Another DAQmxBaseCreateTask call normalizes the situation - task handlers are reinstalled, but quit command handler was installed only once at first call.

It's the only explanation I have.
0 Kudos
Message 3 of 3
(2,707 Views)