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.

Instrument Control (GPIB, Serial, VISA, IVI)

cancel
Showing results for 
Search instead for 
Did you mean: 

NI MAX not detecting the USB device after reconnection

Hey guys,

 

I kind of ran into a weird issue recently (which I'm not sure, is one of the known issues) while trying to communicate to a USB device using LabVIEW. The issue is something like this. 

 

When I connect the USB device to my PC, I can see the device getting listed in the NI MAX (after i refresh it). Then I have a LabVIEW code, a simple one to open a VISA reference and then close the reference. What I'm doing is that after I open the reference, I pause the program by adding a breakpoint. When the program is paused after opening the reference, I try to disconnect the USB cable and reconnect it and then resume the execution of the program which now runs the Close VISA reference VI. This vi now removes the device from the NI MAX listing (I am guessing that this is happening because the session id expires when the disconnection of the cable happens). Now the problem is that no matter what I do, I'm not able to get the device listed in NI MAX after this unless I physically disconnect the USB cable and reconnect it. The weird part is that the Windows Device manager is able to list the USB device without any issues when ever the device stays connected and it is only the NI MAX which is not being able to detect it.

 

Is there something that I'm missing here? I would be glad if you could kinldy provide your valuable inputs.

 

Thanks,

Nitz

0 Kudos
Message 1 of 3
(4,410 Views)

I may have an explanation : The discovery in MAX  is event driven.

 

When you unplug the device when it is still opened, MAX gets an disconnect event, but delays the removal of  the device because it is locked by the open VISA session. 

When you now replug the device, the  code  for the connect event sees the still existing list entry for that device and thinks that there is nothing to do, because it is not aware of the still waiting disconnect event. When you run the close() now , the disconnect event is finished and the device is removed 

And now you will  another connect event to get the device seen again. 

 

0 Kudos
Message 2 of 3
(4,358 Views)

mkossmann,

 

Thank you for writing back to me. I think I was able to figure that out by looking at the behaviour of NI MAX. Will you be able to propose a solution to this, either to avoid this or to detect the replug without physically replugging the USB?

 

Regards,
Nitz

0 Kudos
Message 3 of 3
(4,350 Views)