I have a C++ application interfacing with a NI DAQ card, however the name of the device is hard coded and if changed in the NI Max app it would stop working, so is there a way to enumerate connected devices to know the name of the cards that are connected ?
Asked
Active
Viewed 265 times
1 Answers
2
List of all devices can be retrieved with DAQmxGetSysDevNames()
. The names are separated by commas.
Once you have the list of all names, you can use the product type to find the correct device.
const std::string expectedProductType = "1234";
constexpr size_t bufferSize = 1000;
char buffer[bufferSize] = {};
if (!DAQmxFailed(DAQmxGetSysDevNames(buffer, bufferSize))) {
std::string allNames(buffer);
std::vector<std::string> names;
boost::split(names, allNames, boost::is_any_of(","));
for (auto name : names) {
char buffer2[bufferSize] = {};
if (!DAQmxFailed(DAQmxGetDevProductType(name.c_str(), buffer2, bufferSize))) {
if (expectedProductType == std::string(buffer2)) {
// match found
}
}
}
}

VLL
- 9,634
- 1
- 29
- 54
-
thanks a lot, I did not come across that function searching through the documentation. this does provide the functionality I am seeking. – UbiMiles Feb 10 '22 at 10:17