pi40iv_UnlockSession

ViStatus pi40iv_UnlockSession (ViSession instrumentHandle, ViPBoolean callerHasLock);

Purpose

This function releases a lock that you acquired on an instrument session using pi40iv_LockSession.  Refer to pi40iv_LockSession for additional information on session locks.

Parameters

Input
Name Type Description
instrumentHandle ViSession

The ViSession handle that you obtain from the pi40iv_init or pi40iv_InitWithOptions function.  The handle identifies a particular instrument session.
Default Value:  None

Output
Name Type Description
callerHasLock ViBoolean (passed by reference)

This parameter serves as a convenience.  If you do not want to use this parameter, pass VI_NULL.
Use this parameter in complex functions to keep track of whether you obtain a lock and therefore need to unlock the session.
Pass the address of a local ViBoolean variable.  In the declaration of the local variable, initialize it to VI_FALSE.  Pass the address of the same local variable to any other calls you make to pi40iv_LockSession or pi40iv_UnlockSession in the same function.
The parameter is an input/output parameter.  pi40iv_LockSession and pi40iv_UnlockSession each inspect the current value and take the following actions:
- If the value is VI_TRUE, pi40iv_LockSession does not lock the session again.  If the value is VI_FALSE, pi40iv_LockSession obtains the lock and sets the value of the parameter to VI_TRUE.
- If the value is VI_FALSE, pi40iv_UnlockSession does not attempt to unlock the session.  If the value is VI_TRUE, pi40iv_UnlockSession releases the lock and sets the value of the parameter to VI_FALSE.
Thus, you can, call pi40iv_UnlockSession at the end of your function without worrying about whether you actually have the lock.  
Example:
ViStatus TestFunc (ViSession vi, ViInt32 flags)
{
ViStatus error = VI_SUCCESS;
ViBoolean haveLock = VI_FALSE;
if (flags & BIT_1)
{
viCheckErr( pi40iv_LockSession(vi, &haveLock));
viCheckErr( TakeAction1(vi));
if (flags & BIT_2)
{
viCheckErr( pi40iv_UnlockSession(vi, &haveLock));
viCheckErr( TakeAction2(vi));
viCheckErr( pi40iv_LockSession(vi, &haveLock);
}
if (flags & BIT_3)
viCheckErr( TakeAction3(vi));
}
Error:
/*
At this point, you cannot really be sure that
you have the lock.  Fortunately, the haveLock
variable takes care of that for you.          
*/
pi40iv_UnlockSession(vi, &haveLock);
return error;
}

Return Value

Name Type Description
status ViStatus

Returns the status code of this operation.  The status code  either indicates success or describes an error or warning condition.  You examine the status code from each call to an instrument driver function to determine if an error occurred.
To obtain a text description of the status code, call the pi40iv_error_message function.  To obtain additional information about the error condition, call the pi40iv_GetErrorInfo function.  To clear the error information from the driver, call the pi40iv_ClearErrorInfo function.
The general meaning of the status code is as follows:
Value                  Meaning
-------------------------------
0                      Success
Positive Values        Warnings
Negative Values        Errors
This driver defines the following status codes:
Status    Description
-------------------------------------------------
WARNINGS:
/*=CHANGE:===================================================*
Insert Instrument-defined warning codes here.
*================================================END=CHANGE=*/
ERRORS:
/*=CHANGE:===================================================*
Insert Instrument-defined error codes here.
*================================================END=CHANGE=*/
This instrument driver also returns errors and warnings defined by other sources.  The following table defines the ranges of additional status codes that this driver can return.  The table lists the different include files that contain the defined constants for the particular status codes:
Numeric Range (in Hex)   Status Code Types    
-------------------------------------------------
3FFA2000 to 3FFA3FFF     IviSwtch Warnings
3FFA0000 to 3FFA1FFF     IVI      Warnings
3FFF0000 to 3FFFFFFF     VISA     Warnings
3FFC0000 to 3FFCFFFF     VXIPnP   Driver Warnings
BFFA2000 to BFFA3FFF     IviSwtch Errors
BFFA0000 to BFFA1FFF     IVI      Errors
BFFF0000 to BFFFFFFF     VISA     Errors
BFFC0000 to BFFCFFFF     VXIPnP Driver Errors

References

Locking
Utility
Pickering Interfaces PXI/LXI IVI Switch
Alphabetical Function Index
Hierarchical Function Index