LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I recover from a USB disconnect using NI-Visa from CVI?

If the USB device is not on when my CVI code accesses it, I lose the handle and can't even close the session. Is there a recovery process for when the USB disconnects during transmission?
0 Kudos
Message 1 of 3
(3,254 Views)
You can try enabling notification of events using viEnableEvent and viEventHandler. Take a look at the CVI Help under the NI-VISA Library. There are some good references in there for Event handling, function references, and it talks about a USB Interrupt that you can use. My first instinct would be to try that method. If this doesn't work, then you can use Windows SDK calls to register device notification and install a callback to CVI. Inside the callback, you could then look for the event that fired the callback, (i.e. a disconnect message) and then handle the problem accordingly. I would look into the device management reference on msdn to learn
about finding when a device change occurs. Hope this helps!

Jeremy L.
National Instruments
Jeremy L.
National Instruments
Message 2 of 3
(3,254 Views)
Thanks Jeremy.
Those are great ideas. At least I have a direction to go now.
0 Kudos
Message 3 of 3
(3,254 Views)