NurApiTagSetLock Method

Set memory lock for tag

Definition

Namespace: NurApiDotNet
Assembly: NordicID.NurApi.Net (in NordicID.NurApi.Net.dll) Version: 4.0.0
C#
public void SetLock(
	uint passwd,
	uint memoryMask,
	uint action
)

Parameters

passwd  UInt32
Password for secured operations. Password is always needed.
memoryMask  UInt32
Which memories to lock. Memory mask flags: LOCK_USERMEM, LOCK_TIDMEM, LOCK_EPCMEM, LOCK_ACCESSPWD, LOCK_KILLPWD
action  UInt32
Action to perform for memories. Memory lock action: LOCK_OPEN, LOCK_PERMAWRITE, LOCK_SECURED, LOCK_PERMALOCK

Example

Note: prior to locking, the access password needs to beset with e.g. SetAccessPassword(UInt32, Boolean, UInt32).

Example of locking user memory only for writing:

C#
// Use in try-catch, may throw NurApiException.
void ProtectUserMemory(NurApi.Tag aTag, uint password)
{
    aTag.SetLock(password, NurApi.LOCK_USERMEM, NurApi.LOCK_SECURED);
}
Example of locking the whole password memory for reading and writing, the tag has not been programmed with a password yet:

C#
// Use in try-catch, may throw NurApiException.
void ProtectPasswordMemory(NurApi.Tag aTag, uint password)
{
    // Write...
    aTag.SetAccessPassword(0, false, password);
    // ...and lock.
    aTag.SetLock(password, NurApi.LOCK_ACCESSPWD | NurApi.LOCK_KILLPWD, NurApi.LOCK_SECURED);
}

See Also