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.

LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

VISA Find Resource Function issue after COM port disconnected

Solved!
Go to solution

I tried that too. In both case I am getting the error. Irrespective of its presense. Strange.

 

I dont think its a bug of VISA find resourse. Why its happening?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 11 of 20
(2,202 Views)

@Ranjeet_Singh wrote:

I tried that too. In both case I am getting the error. Irrespective of its presense. Strange.

 

I dont think its a bug of VISA find resourse. Why its happening?


Ok, again not clear, sorry, it is really morning for me 🙂

"I tried that too. In both case I am getting the error."

I assumed when the USB port is connected to the PC (from the device), you are able to communicate with the device from LabVIEW, no? This is the task, no?

You mean, if you unplug the USB device, and plug it back, you cannot communicate with it anymore? What is your actual VI you use for communication? What is the hardware? Model/manufacturer?

0 Kudos
Message 12 of 20
(2,195 Views)

@Blokk wrote:

@Ranjeet_Singh wrote:

I tried that too. In both case I am getting the error. Irrespective of its presense. Strange.

 

I dont think its a bug of VISA find resourse. Why its happening?


Ok, again not clear, sorry, it is really morning for me 🙂

"I tried that too. In both case I am getting the error."

I assumed when the USB port is connected to the PC (from the device), you are able to communicate with the device from LabVIEW, no? This is the task, no? NO THIS IS NOT A TASK

 

 

You mean, if you unplug the USB device, and plug it back, you cannot communicate with it anymore? What is your actual VI you use for communication? What is the hardware? Model/manufacturer?

 

INHOUSE MADE HARDWARE. Yes after reconnection I am not able to connect.



Its a inhouse made harware.

 

Sequence is below:

1. Turn on device

2. Communicate with device and also from USB

3. Once testing completed. Turn off the device

4. Now if system is ok then COM port should be disconnected

5. If device is not ok then COM port will not be disconnected. 

6. Open USB com port and check whether it is responding or not atleast.

7. Now whether USB is connected or disconnected in both case I am getting error resourse not available.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 13 of 20
(2,190 Views)

Once testing completed. Turn off the device

4. Now if system is ok then COM port should be disconnected

5. If device is not ok then COM port will not be disconnected. 

 

Before physically turning off the device, do you close the COM port from LabVIEW? So all references are closed properly, yes?

To me it looks like something problem in the sequence. But I used to have also problems with some USB (virtual serial) devices from LabVIEW, and sometimes only Windows restart solved the problem. I never had to test many USB devices sequentially, lets wait for someone who is more experienced than me...

0 Kudos
Message 14 of 20
(2,177 Views)

I think once I had to do something similar. In my case the device which should be discovered automatically, after attaching to the PC was also using a USB-serial interface. What I did was to simply make the list of the available COM ports, as you do in your VI. But after this point, my code was simply testing through all COM ports in a FOR loop, and requesting the ID of the device (so first VISA Open, Perform ID Read command with VISA write/read, and Close VISA). If there was response, and ID matched, I stopped the FOR loop, and the device was ready for usage by the LV application.

 

In your VI I see a problematic part (but this is not necessarily your actual bug right now) also: you use the property node "Interface description". This string is not intended to be used as a programmatic value to test the presence of a hardware, see the Context help of this PN: "for display purposes only". That is why I think it is better to request a valid response from the device...

But of course, all depends on your actual test requirements...

 

CheckComPort_BD.png

0 Kudos
Message 15 of 20
(2,159 Views)

In my case during testing there might be multiple COM port is available, The USB port name start with USB Serial Port is my actual required one that is why I am using interface description. 

 

Also I am using this method from last 3 Yrs in different PC and it is working reliable so far.

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 16 of 20
(2,133 Views)
Solution
Accepted by topic author Ranjeet_Singh

I found the actual bug in my application. Before my USB disappears, I detect it and close the VISA before it disconnects. and after if I search the VISA and it is not present it doesn't shows in my search. Mysteriously it is working so far.

 

 

 

 

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 17 of 20
(2,130 Views)

Why is it mysterious? 🙂 I told you you should always close every resources properly after opening a connection toward a device...

0 Kudos
Message 18 of 20
(2,123 Views)

Because if its resourse issue after few detection application should hang because VISA resourse not closed. In one day I test almost 2000 times in same PC and it works fine.

 

Second, after my testing stops, if port is not present then it was not showing properly as it should be BUT INBETWEEN TESTING WHY IT WAS NOT WORKING i.e even com port is not there it was showing in VISA FIND RESOURSE?

--------------------------------------------------------------------------------------------------------
Kudos are always welcome if you got solution to some extent.

I need my difficulties because they are necessary to enjoy my success.
--Ranjeet
0 Kudos
Message 19 of 20
(2,112 Views)

Sorry, not really clear what you mean here. But if you open a VISA reference, and close properly afterwards when finished testing, do you see any problem? Resources should be closed always, specially those corresponding to physical ports.

 

edit: if you do not close a VISA reference, I guess LV can "autorelease" it in some conditions. But just better to close everything explicitly...

0 Kudos
Message 20 of 20
(2,108 Views)