01-06-2017 12:39 PM
Thank you for additional info but logic is still unclear.
First of all, what is a reason that application opens serial port twice? In my applications - at the beginning, application opens serial port and initializes port (rate, etc) and attached device(s). Then multiple LabVIEW “lines” writes/reads.
Maybe there is better example?
I assume when LabVIEW application opens port at first time then VISA library really opens port in Windows. When the application opens port second time and the port has been opened then VISA library doesn't open port in Windows but registers internally. At the end, VISA library should close port when last registration closes port … but I assume VISA doesn’t close the port! If I want to check device by another application it can’t open port. I need to close LabVIEW and that is very annoying.
03-31-2017 02:46 PM
Hi Vasilich,
It is calling the VISA Open function twice to simulate 2 resources trying to control the same device. We lock the communication to be used with Resource 1 and if we don't unlock it before the timeout period set on VISA Lock Async of Resource 2 it will return an error.
You don't want to cause a race condition by writing then reading from the same resources "at the same time". So we attempt to lock the communication for the resource we are using at the time and set a timeout so we Resource 2 isn't waiting forever. You could also serialize this entire process if you wanted, but this gives you a little more flexibility.
---
Aaron F.
National Instruments