12-18-2009 12:24 PM
If I lock an instrument session (viLock) and the session is not unlocked when the debug session is closed, the next time I run the code VISA tells me that the device is locked. Is there any way to free up locks that were never cleared like this (apart from rebooting the PC?).
Thanks,
Ronnie
12-18-2009 12:53 PM
Sorry - my fault - I was trying to lock the device twice by mistake.
I guess the lock is freed when the debug session quits anyway.
12-21-2009 11:52 AM
Hey Ronnie,
Glad to hear you found a solution to the issue, and thanks for posting it!
02-23-2012 07:11 AM
Hello,
I'm actually work for a company in Germany and need to automate test cases with high end spectrum analyzers.
All stuff is working.
But I got the same effect as you:
after closing a debug-session, the VISA session of the device is still locked!
And I have to reboot the device to relock it again.
I do normal cases:
But if I close the debug-session after step 3. or 4. the unlock and close can not be run.
How can I relock the old VISA session on next connection?
Best regards,
VikingGod
02-24-2012 06:12 PM
Hey VikingGod,
If you are using LabVIEW you can refer to this KnowledgeBase on using the Visa Resource Monitor
http://digital.ni.com/public.nsf/allkb/6A9B4BA95EFA6C22862575080064D98F?OpenDocument
If you go to Programs » National Instruments » NI-VISA » Examples » C » General » Locking_MSVC_VS2005.vcproj, this example goes over locking VISA resources for use, it also shows how you can safely exit a program to ensure that your VISA resources are released when your program terminates.
Hope this helps.
02-27-2012 01:29 AM
Hi BeauH,
thank you for the fast reply.
I checked the example, but we make the same stuff.
If I close our program with the "close button" than everything is going right.
But if I stop the process by clicking "STOP" from inside the Visual Studio debugger;
my code (=destructor) to send viunlock and viclose will not be run. The programm is hard terminated by the VS debugger.
In this case, I have no chance to run last code steps to unlock the VISA session.
Do you know what I mean?
It is not a normal programm termination by closing via close button, or exit.
The programm is running by VS debugger and is closed/terminated by VS and not by normal close process.
02-27-2012 04:10 PM
Hey VikingGod,
When you stop your program(terminate execution) and if you were to just "run" the program again without rebooting the device, do you get an error message or Run-time error, and even after those errors the VISA resources are still locked? If you do could you post a screenshot of the error?
Thanks
02-27-2012 11:44 PM
Hi BeauH,
after stop programm by debugger, the unlock and close function could not be called.
On next start I got on open following error:
VI_ERROR_RSRC_LOCKED /* BFFF000F, -1073807345 */
So my device is still locked.
How can I unlock it again, on the next start?
I just try to save the handle and unlock this handle on next start, but it is not working (still locked)
Only a reboot of the device is helping.
Hope you have a better solution for us 😉
Best regards and thanks for your support!
02-29-2012 11:20 AM
Hey VikingGod
Would it be possible to get a I/O Trace screen capture of what calls are being made and resources being reserved and released, or not released as seems to be the case? If you are unfamiliar with NI I/O Trace here is a good walkthrough http://digital.ni.com/public.nsf/allkb/282C5D41E2BA04F2862574BA007803B9?OpenDocument
11-08-2022 08:34 AM
Was this ever resolved? I too am having a very similar issue to what you are describing.