From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
From Friday, April 19th (11:00 PM CDT) through Saturday, April 20th (2:00 PM CDT), 2024, ni.com will undergo system upgrades that may result in temporary service interruption.
We appreciate your patience as we improve our online experience.
09-14-2021 06:31 AM
Hi guys, a bit of a background first.
I want to search for a specific model of USB-DAQ, and if it's found, I want to use its data further in the program (S/N, DevName, Product type).
I made a bit of code, where I search for the devices, but having trouble with the next part.
I'm looping through all available devices, then creating an array of clusters, if the product info matches, I would like to use the remaining data from that cluster.
Any help would be appreciated.
Thanks,
Johnny
Solved! Go to Solution.
09-14-2021 06:58 AM
Can there be more than one match?
If you are only looking for the first match, use "search array" (instead of the second FOR loop) and use the result to index into the cluster array.
If you are looking for multiple matches, use your current code and a conditional tunnel.
09-14-2021 07:19 AM
Here's one possible way to create an array of clusters containing only matching devices.
(Sorry, I don't have drivers installed, so everything is broken for me).
Maybe if you would explain what you mean by "use the remaining ...", we could give more specific advice. 🙂
09-14-2021 07:47 AM
Hi altenbach,
Thanks a lot for the suggestion, I went with your first post- as I'm only after noticing the new one now.
I did what you said and it's exactly what I needed.
I'm only looking for one match, as only one USB-6126 will be plugged into the PC at any time.
Funny enough, I tried using the "search array" previously and always got errors, I didn't realize I had to wire the "element" with the specific data type.
I'll take a look at your other suggestion in a while.
Thanks a lot!
09-14-2021 08:11 AM
You probably need a bit more code to deal with the possibility that there is no match (i.e. search returns -1). You need to decide what result should be returned if this happens.
My second solution is more explicit, because you would get an empty array in that case.
09-14-2021 09:19 AM - edited 09-14-2021 09:20 AM
I only want to run this bit of code at the "first call", and if the 6216 is not connected I display an error for user to see and set a bool- which if not true, won't let the test to be carried out.
The example I attached with the bit of extra code I have does just that for me.