07-09-2012 09:48 AM
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?
Solved! Go to Solution.
07-09-2012 09:54 AM
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
07-09-2012 12:16 PM
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.
07-09-2012 12:52 PM
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
07-09-2012 04:38 PM
DAQmxGetSysDevNames! That was exactly what I was looking for. Thanky!