Is there a simple method to test for the presence of a device? I have a 9172 chassis that I occasionally forget to turn on so my LabVIEW VI errors out the first time it tries to do something with the hardware (and I need to resart the VI and reenter the GUI selections ).
I would like to find a nice simple way to test to be sure the cassis is connected tot he PC and turned on and if it isn't give a not so subtle remicer to do so before proceeding with the actual test portion of the code.
Solved! Go to Solution.
Trying querying the device for some status or ID before completing your initialization. If this fails then inform the user.
This also sounds like your application could benefit from some UI enhancements which allow for error recovery in general. I get the impression that the user has one chance to set values when running the program. When writing an application that is interactive (the user will be present) it is always best to have error recovery techniques and provide as much control to the user as possible. Things like pausing or aborting an action, exiting, saving configuration values, reconfiguring and restarting if an error occurs, etc.
I recommend using the DAQmx System and Device property nodes, similar to something like this:
You may want to look at this thread. Also, what type of communication do you have in your application now? What devices do you expect to be there? I have to assume that your applications runs if the chasis is turned on. So, you have known equipment that you do communicate with now. Any status query of any of these devices would be enough for you to determine if the chasis is there or not. If you can connect and get a response you are good to go. If not, then you need to have the user turn the chasis on, connect it or whatever to resolve the problem.
For your application you could use a producer/consumer architecture or a state machine which would allow you to stay in the initialization state before proceeding if you cannot communicate with the device.
Ah ha! I stumbled into something very similar. across something. I tried to read the DevSerialNum which when it is off (not connected) I get an error code of -200220 and no error code when it is not present. I then fed the error status (AND withthe -200220 error code value) to a case structure for the appropriate action.
Thanks for your help!