Multifunction DAQ

cancel
Showing results for 
Search instead for 
Did you mean: 

Program self-testing for present device

Solved!
Go to solution

The computer I'm using with an installed NI PCI card is shared by several coworkers and is frequently disasembled and reasembled. Sometimes the NI card ends up in a different PCI slot on reasembly. 

 

Does anyone have any recomendations for how to test device locations for the card with C / C++ code without interupting the user with error messages?

0 Kudos
Message 1 of 5
(2,964 Views)

MrSky,

 

There are a number of device specific properties available which can help to identify/locate specific hardware.

 

If you look at NIDAQmx.h, find the sections commented as "//********** Device Attributes **********", and "//********** System Attributes **********".

 

With these sets of properties, you should be able to query for the names of all DAQmx devices in your system, then look at each devices properties to identify each device.

 

Is this what you are looking for?

 

Dan

0 Kudos
Message 2 of 5
(2,961 Views)

Dan,

 

Thanks for the reply. I suppose that static list of #define statements from the NIDAQmx.h header might be one step in the path I'm looking for, but knowing the middle step doesn't really help much without knowing the starting and ending steps as well.

 

As a first step, how would I query for the names of all DAQmx devices on my system to begin with?

 

 

To illistrate what's happening, lets say I'm trying to set an output on line 0-2.

 

CString channel = "Dev1/port0/line2";

DAQmxErrChk( DAQmxCreateTask("OutChan",&taskHandle));

DAQmxErrChk( DAQmxCreateDO(taskHandle, channel, """, DAQmx_Val_ChanPerLine));

 

The problem is, the card might actually be at 'Dev2'.

My current best plan is to check for failure, and if failed try a different channel.

 

CString channel = "Dev1/port0/line2";

DAQmxErrChk( DAQmxCreateTask("OutChan",&taskHandle));

if( DAQmxFailed( DAQmxCreateDO(taskHandle, channel, """, DAQmx_Val_ChanPerLine)) {

    channel = "Dev2/port0/line2";

    if( DAQmxFailed( DAQmxCreateDO(taskHandle, channel, """, DAQmx_Val_ChanPerLine))

    {

        exit(0); //card not installed

    }

}

 

 

However, this feels like a kludge, so I was curious if anyone know of either a better or official way to check for a card's existence/location.

0 Kudos
Message 3 of 5
(2,954 Views)
Solution
Accepted by topic author MrSky

If you search in the file for these defines, you'll find 'getters' for all of these properties... For example if you search for DAQmx_Sys_DevNames, you'll find DAQmxGetSysDevNames, which is the function you'd call to get a list of all DAQmx devices in your system.  Similar 'getters' are available for the other device and system attributes as well.

 

Basically, you need to figure out how you'd like to identify a device.  You might want to use Product Type (DAQmxGetDevProductType - which would give you the product name ie.. 'PCI-6259').  If you have more than one device of a particular type, you can use serial number (DAQmxGetDevSerialNum).  Your logic would then look like this:

 

DAQmxGetSysDevNames()

for (each devNme)

{

   DAQmxGetDevProductType()

   if(devName == desiredDevName)  break;

}

 

Now that you've identified which device you want to use, you'd pre-pend this to the channel you want to use, and your app should work regardless of what device name it receives.

 

Dan

Message 4 of 5
(2,945 Views)

DAQmxGetSysDevNames! That was exactly what I was looking for. Thanky!

0 Kudos
Message 5 of 5
(2,932 Views)