Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

DAQmxBaseCreateTask -> Bus Error: 10

Solved!
Go to solution

Hello,

 

I've bought a USB-6009 and downloaded the NI-DAQmx Base software on to my MacBook running OS 10.7.2.  When running lsdaq I was told to update the firmware on the USB-6009, so I did using FWUpdate.

 

The examples that come with NI-DAQmx Base compile ok, but cause an error when they run.  The error is-  Bus Error: 10

 

I think this is an OS error, but it is occuring when the following line is executed-  DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));

 

This line of code seem fine when I read the documentation.  Furthermore it is consistent with every example and code snippet I can find.  Has anyone experienced this problem and/or know how to solve it?

 

Thanks

Lee.

 

P.S. I was unable to attach the source file because the stupid forum says I have set the wrong content type for the file extension, but it does not let me change the content type.  So I've pasted it below.

 

#include "NIDAQmxBase.h"

#include <stdio.h>

#include <time.h>

 

#define DAQmxErrChk(functionCall) { if( DAQmxFailed(error=(functionCall)) ) { goto Error; } }

 

 

int main(int argc, char *argv[])

{

    // 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("Press Ctrl-C to exit\n");

    DAQmxErrChk (DAQmxBaseCreateTask("",&taskHandle));

    DAQmxErrChk (DAQmxBaseCreateAIVoltageChan(taskHandle,chan,"",DAQmx_Val_Cfg_Default,min,max,DAQmx_Val_Volts,NULL));

    DAQmxErrChk (DAQmxBaseCfgSampClkTiming(taskHandle,clockSource,sampleRate,DAQmx_Val_Rising,DAQmx_Val_ContSamps,samplesPerChan));

    DAQmxErrChk (DAQmxBaseCfgInputBuffer(taskHandle,200000)); //use a 100,000 sample DMA buffer

    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",(int)pointsRead,(int)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",(int)i,data[2*i],(int)i,data[2*i+1]);

 

    }

    printf("\nAcquired %d total samples.\n",(int)totalRead);

 

Error:

    if( DAQmxFailed(error) )

        DAQmxBaseGetExtendedErrorInfo(errBuff,2048);

    if(taskHandle != 0) {

        DAQmxBaseStopTask (taskHandle);

        DAQmxBaseClearTask (taskHandle);

    }

    if( DAQmxFailed(error) )

printf ("DAQmxBase Error %d: %s\n", (int)error, errBuff);

    return 0;

}

 

0 Kudos
Message 1 of 9
(5,193 Views)

Sorry, I forgot to say that it does not appear to be the DAQmxErrChk() call, because if I alter the code to do that seperately then the error still occurs on the line- DAQmxBaseCreateTask("",&taskHandle);

 

Thanks

Lee.

0 Kudos
Message 2 of 9
(5,190 Views)

Lee, 

 

At this time, there are some compatibility issues with Mac OS X Lion and NI-DAQmx. We are working on fixing these issues, but a workaround that has worked for other customers is to install a 10.6 server edition on a virtual machine and then copying the compiled programs and running them from there. 

 

Let me know if that works for you!

 

Katie

Katie Collette
National Instruments
0 Kudos
Message 3 of 9
(5,181 Views)

Lee, 

 

I wanted to elaborate on my earlier post. The behavior you are seeing is a known issue and R&D is currently working on it. At this time, the LabVIEW interface works with Lion (hence the reason Isdaq and data logger work), but the C interface does not. You will need to either use the LabVIEW interface or use 10.6 as I mentioned earlier until the DAQmx base is officially supported on Lion. Good luck!

 

Katie

Katie Collette
National Instruments
0 Kudos
Message 4 of 9
(5,176 Views)

Katie,

 

Thanks for your reply.  I'll try to track down an old copy of OS X 10.6, it might be difficult as it is not sold anymore.

 

Is there a timeframe for when NI-DAQmc Base will be supported in Lion?

 

Btw, this infomration was not given to me when I asked your sales engineer if the NI-DAQmx API was compatible with OS X.  I have now bought hardware that is useless to me until I find a copy of an old OS or NI updates the software.

 

Thanks

Lee.

0 Kudos
Message 5 of 9
(5,164 Views)

Can't get OS X Server 10.6, so my work around is rebooting onto another partition that has OS X 10.6 installed.  It's more annoying than having to run a VM, but at least I can use my hardware now.

 

Here's hoping a 64-bit Lion compatible version is not too far away.

0 Kudos
Message 6 of 9
(5,159 Views)

Lee,  

 

Right now, it is projected to be compatible in quarter 1 of 2012--so not too far away! I am very sorry the sales engineer didn't specify this, but I am glad you have found a workaround. 

 

Katie

Katie Collette
National Instruments
0 Kudos
Message 7 of 9
(5,156 Views)
Solution
Accepted by topic author Tangle

Hello,

 

NI-DAQmx Base support for Mac OS X 10.7 has released.  In this release, there are updates solve this issue.  In addition, 64-bit versions of 10.6 and 10.7 are now supported along with the 32-bit versions.

 

http://joule.ni.com/nidu/cds/view/p/id/2892

 

Thanks,

Steven T.

0 Kudos
Message 8 of 9
(5,025 Views)

Excellent.

0 Kudos
Message 9 of 9
(5,018 Views)