Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Yosemite NI USB-6009 NIDAQmx

I have a problem trying to use a 6009 device through NIDAQmx and XCode 6.1.1 on Yosemite.

 

Here is my code, taken directly from the contAcquireNChan.c file:

 

   printf("Start\n");
    // Task parameters
    int32       error = 0;
    TaskHandle  taskHandle = 0;
    char        errBuff[2048]={'\0'};
    int32       i,j;
    time_t      startTime;
    bool32      done=0;
    
    // Channel parameters
    char        chan[] = "Dev1/ai0, Dev1/ai1";
    float64     min = -10.0;
    float64     max = 10.0;
    
    // Timing parameters
    char        clockSource[] = "OnboardClock";
    uInt64      samplesPerChan = 1000;
    float64     sampleRate = 5000.0;
    
    // Data read parameters
#define     bufferSize (uInt32)1000
    float64     data[bufferSize * 2];
    int32       pointsToRead = bufferSize;
    int32       pointsRead;
    float64     timeout = 10.0;
    int32       totalRead = 0;
    
    
    printf("Example will halt automatically.\n");
    
    printf("Task configuration.\n");
    printf("DAQmxBaseCreateTask.\n");
    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));
    printf("DAQmxBaseCreateAIVoltageChan.\n");
    DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));
    printf("DAQmxBaseCfgSampClkTiming.\n");
    DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan));
    printf("DAQmxBaseCfgInputBuffer.\n");
    DAQmxErrChk (DAQmxBaseCfgInputBuffer(taskHandle,200000)); //use a 100,000 sample DMA buffer
    
    printf("Start Task.\n");
    DAQmxErrChk (DAQmxBaseStartTask(taskHandle));
    
    // The loop will quit after 10 seconds
    
    startTime = time(NULL);
    while( time(NULL)<startTime+10 ) {
        DAQmxErrChk (DAQmxBaseReadAnalogF64(taskHandle,pointsToRead,timeout,DAQmx_Val_GroupByScanNumber,data,bufferSize*2,&pointsRead,NULL));
        totalRead += pointsRead;
        printf("Acquired %d samples. Total %d\n",pointsRead,totalRead);
        // Just print out the first 10 points of the last data read
        for (i = 0; i < 10; ++i)
            printf ("data0[%d] = %f\tdata1[%d] = %f\n",i,data[2*i],i,data[2*i+1]);
        
    }
    printf("\nAcquired %d total samples.\n",totalRead);
    
Error:
    if( DAQmxFailed(error) )
        DAQmxBaseGetExtendedErrorInfo(errBuff,2048);
    if(taskHandle != 0) {
        DAQmxBaseStopTask (taskHandle);
        DAQmxBaseClearTask (taskHandle);
    }
    if( DAQmxFailed(error) )
        printf ("DAQmxBase Error %d: %s\n", error, errBuff);

I have no problem compiling the code, however when I click on the button running the code it crashes and the problem seems to be the DAQmxBaseCreateTask function.

 

Here is the error message:

Start
Example will halt automatically.
Task configuration.
DAQmxBaseCreateTask.
2015-03-04 15:38:04.748 ProjectName[3850:50381] -[AppDelegate setHandler:withData&colon;]: unrecognized selector sent to instance 0x610000001140
2015-03-04 15:38:04.760 ProjectName[3850:50381] An uncaught exception was raised
2015-03-04 15:38:04.760 ProjectName[3850:50381] -[AppDelegate setHandler:withData&colon;]: unrecognized selector sent to instance 0x610000001140
2015-03-04 15:38:04.760 ProjectName[3850:50381] (
	0   CoreFoundation                      0x00007fff8a5a666c __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x00007fff8731376e objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8a5a96dd -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
	3   CoreFoundation                      0x00007fff8a4f0aa4 ___forwarding___ + 1028
	4   CoreFoundation                      0x00007fff8a4f0618 _CF_forwarding_prep_0 + 120
	5   LabVIEW 14.0 Runtime                0x00000001024866af _ZN19MainLoop_MacCocoaUIC2Ev + 95
	6   LabVIEW 14.0 Runtime                0x000000010248673c _ZN19MainLoop_MacCocoaUI4InstEv + 60
	7   LabVIEW 14.0 Runtime                0x0000000102569dea WSendEvent + 250
	8   LabVIEW 14.0 Runtime                0x000000010256af8f WCreateEx + 543
	9   LabVIEW 14.0 Runtime                0x000000010256b20e _ZN8WMgrCore10InitializeEv + 254
	10  LabVIEW 14.0 Runtime                0x000000010251a790 _Z12InitManagersiPKPKcPiP14MGAppInterfaceP16MGUIAppInterfaceS0_ + 512
	11  LabVIEW 14.0 Runtime                0x0000000101842b53 _Z10MGMainInitiPKPKcPb + 179
	12  LabVIEW 14.0 Runtime                0x0000000101842f84 _Z6MGMainiPKPKc + 132
	13  LabVIEW 14.0 Runtime                0x0000000101843aed _Z11SysUIThreadPv + 13
	14  LabVIEW 14.0 Runtime                0x00000001025dbe9e _Z15ThreadCoverProcPv + 94
	15  libsystem_pthread.dylib             0x00007fff8de2e268 _pthread_body + 131
	16  libsystem_pthread.dylib             0x00007fff8de2e1e5 _pthread_body + 0
	17  libsystem_pthread.dylib             0x00007fff8de2c41d thread_start + 13
)
2015-03-04 15:38:04.761 ProjectName[3850:50381] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AppDelegate setHandler:withData&colon;]: unrecognized selector sent to instance 0x610000001140'
*** First throw call stack:
(
	0   CoreFoundation                      0x00007fff8a5a666c __exceptionPreprocess + 172
	1   libobjc.A.dylib                     0x00007fff8731376e objc_exception_throw + 43
	2   CoreFoundation                      0x00007fff8a5a96dd -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
	3   CoreFoundation                      0x00007fff8a4f0aa4 ___forwarding___ + 1028
	4   CoreFoundation                      0x00007fff8a4f0618 _CF_forwarding_prep_0 + 120
	5   LabVIEW 14.0 Runtime                0x00000001024866af _ZN19MainLoop_MacCocoaUIC2Ev + 95
	6   LabVIEW 14.0 Runtime                0x000000010248673c _ZN19MainLoop_MacCocoaUI4InstEv + 60
	7   LabVIEW 14.0 Runtime                0x0000000102569dea WSendEvent + 250
	8   LabVIEW 14.0 Runtime                0x000000010256af8f WCreateEx + 543
	9   LabVIEW 14.0 Runtime                0x000000010256b20e _ZN8WMgrCore10InitializeEv + 254
	10  LabVIEW 14.0 Runtime                0x000000010251a790 _Z12InitManagersiPKPKcPiP14MGAppInterfaceP16MGUIAppInterfaceS0_ + 512
	11  LabVIEW 14.0 Runtime                0x0000000101842b53 _Z10MGMainInitiPKPKcPb + 179
	12  LabVIEW 14.0 Runtime                0x0000000101842f84 _Z6MGMainiPKPKc + 132
	13  LabVIEW 14.0 Runtime                0x0000000101843aed _Z11SysUIThreadPv + 13
	14  LabVIEW 14.0 Runtime                0x00000001025dbe9e _Z15ThreadCoverProcPv + 94
	15  libsystem_pthread.dylib             0x00007fff8de2e268 _pthread_body + 131
	16  libsystem_pthread.dylib             0x00007fff8de2e1e5 _pthread_body + 0
	17  libsystem_pthread.dylib             0x00007fff8de2c41d thread_start + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

 

0 Kudos
Message 1 of 10
(6,158 Views)

Hi Titoin,

 

Are you sur that your error is linked at NI product and not just an syntax error in XCode.

 

I found any information on the error return.

Brice S.
National Instruments France

0 Kudos
Message 2 of 10
(6,138 Views)
I guess so, I don't have any errors when compiling and if I remove the NIDAQ code I don't have any errors when the app is running.
0 Kudos
Message 3 of 10
(6,133 Views)

The error I reported in my first post is when I run the code in an Obective-C Cocoa App project, by the way. If I run the code in a Command Line Tool C project, the code runs without crashing but throw the following warning at the end:

 

CoreAnimation: warning, deleted thread with uncommitted CATransaction; set CA_DEBUG_TRANSACTIONS=1 in environment to log backtraces.

 And if I set CA_DEBUG_TRANSACTIONS to 1, here is the message I get:

 

CoreAnimation: warning, deleted thread with uncommitted CATransaction; created by:
0   QuartzCore                          0x00007fff9605de2a _ZN2CA11Transaction4pushEv + 312
1   QuartzCore                          0x00007fff9605dcca _ZN2CA11Transaction15ensure_implicitEv + 276
2   QuartzCore                          0x00007fff9606b2c2 _ZN2CA7Context10invalidateEv + 32
3   QuartzCore                          0x00007fff9607eb26 -[CAContextImpl dealloc] + 46
4   libobjc.A.dylib                     0x00007fff8d31489c _ZN11objc_object17sidetable_releaseEb + 236
5   libobjc.A.dylib                     0x00007fff8d2fae8f _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 575
6   CoreFoundation                      0x00007fff9046c302 _CFAutoreleasePoolPop + 50
7   Foundation                          0x00007fff96d7fedf -[NSAutoreleasePool drain] + 153
8   LabVIEW 14.0 Runtime                0x0000000103c87c1e _ZN11LVCocoaMainD0Ev + 62
9   LabVIEW 14.0 Runtime                0x0000000103c873c0 _ZN19MainLoop_MacCocoaUI3RunEv + 352
10  LabVIEW 14.0 Runtime                0x0000000103043027 _Z6MGMainiPKPKc + 295
11  LabVIEW 14.0 Runtime                0x0000000103043aed _Z11SysUIThreadPv + 13
12  LabVIEW 14.0 Runtime                0x0000000103ddbe9e _Z15ThreadCoverProcPv + 94
13  libsystem_pthread.dylib             0x00007fff93e1c268 _pthread_body + 131
14  libsystem_pthread.dylib             0x00007fff93e1c1e5 _pthread_body + 0
15  libsystem_pthread.dylib             0x00007fff93e1a41d thread_start + 13

 

0 Kudos
Message 4 of 10
(6,122 Views)
Hello Titoin. I too am building an application that makes use of the NIDAQmxBase drivers. I am receiving an identical stack trace when I execute my code. I am trying to understand exactly what you had to do to resolve your issue. I understand that you run the code as a Command Line Tool C project as against an Object C Cocao app project. Was the initial code written using Xcode with the Objective-C Cocao App template? Can you tell me what exactly changed between your first post and your most recent post? I really appreciate the help. Regards, Varun
0 Kudos
Message 5 of 10
(5,958 Views)
I did not find a solution to my problem. I think the nidaqmx support for Yosemite is rubbish and the only solution is to wait for a new driver version.

Concerning my code, the first one was within a Cocoa app in Objective-C. In that case there is a conflict between a cocoa UI thread and an nidaq thread.
In my second post, I am referring to an simple C command line project, and since there is no UI, there is no error and just a warning.
0 Kudos
Message 6 of 10
(5,951 Views)

Hey everyone,

 

The mixture of using XCode newer than 6.1 on the Yosemite OS with a LabVIEW-built 64-bit framework (DAQmx base) has been known in the past to throw a CoreAnimation thread warning. The behavior was tracked with CAR 497256 and is now fixed in LabVIEW 2015 and LabVIEW 2014 SP1 f1!

0 Kudos
Message 7 of 10
(5,500 Views)

This is not really solving my problem. I have a NI USB Daq but not Labview. All I want is working OS X 10.10 drivers and I can't find any newer drivers than version 14.0 on your website, a version that does not work.

 

Not to mention that  your links are directing us to a "Windows readme" page while this thread is all about OS X...

0 Kudos
Message 8 of 10
(5,417 Views)

did you get it running ? I'm stuck on the same issue : "unrecognized selector sent to instance" when trying to run...

0 Kudos
Message 9 of 10
(5,217 Views)

 I found the solution !!! 

Apparently, the NiDaq framework tries to send a message setHandler to the appdelegate. If you haven't implemented such message, things go bad. But you can simply implement a dummy handler by adding this to your application delegate class :

 

- (id)setHandler:(id)a withData&colon;(id) b
{
    return nil;
}

this way, the framework doesn't crash !!! I still have to test if the measured data is correct, but at least i'm running again !

0 Kudos
Message 10 of 10
(5,215 Views)