niDMM_UnlockSession

NI-DMM C/CVI/VB

niDMM_UnlockSession

ViStatus = niDMM_UnlockSession(ViSession Instrument_Handle, ViBoolean *Caller_Has_Lock)

Purpose

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

Parameters

Input
Name Type Description
Instrument_Handle ViSession Identifies a particular instrument session. You obtain the Instrument_Handle parameter from niDMM_init or niDMM_InitWithOptions. The default is None.
Output
Name Type Description
Caller_Has_Lock ViBoolean* 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.

To use this parameter, complete the following steps:

  1. Pass the address of a local ViBoolean variable.
  2. In the declaration of the local variable, initialize it to VI_FALSE (0).
  3. Pass the address of the same local variable to any other calls you make to niDMM_LockSession or this function in the same function.

The parameter is an input/output parameter. niDMM_LockSession and this function each inspect the current value and take the following actions:

If the value is VI_TRUE (1), niDMM_LockSession does not lock the session again. If the value is VI_FALSE, niDMM_LockSession obtains the lock and sets the value of the parameter to VI_TRUE.

If the value is VI_FALSE, this function does not attempt to unlock the session. If the value is VI_TRUE, this function releases the lock and sets the value of the parameter to VI_FALSE. Thus, you can, call this function 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( NIDMM_LockSession(vi, &haveLock));

viCheckErr( TakeAction1(vi));

if (flags & BIT_2)

{

viCheckErr( NIDMM_UnlockSession(vi, &haveLock));

viCheckErr( TakeAction2(vi));

viCheckErr( NIDMM_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.

*/

niDMM_UnlockSession(vi, &haveLock);

return error;

}

Return Value

Name Type Description
Status ViStatus Reports the Status of this operation. To obtain a text description of the status code, call niDMM_error_message. To obtain additional information concerning the error condition, use niDMM_GetError.