modbus.setLock()
modbus.setLock(locked) → boolean
Locks/unlocks the slave data table so clients never read a half-updated table.
Lock the table before updating it from your script, then unlock so clients can
read and write again. modbus.setLock(true) returns true when the lock was
acquired.
Arguments
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| locked | boolean | yes | — | true to lock the table, false to unlock. |
Returns
boolean
true when the lock state was applied.
Example
if(modbus.setLock(true)){
mbData.seek(0);
mbData.write("F32BADC", [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]);
mbData.write("U32BADC", 23.33);
modbus.setLock(false);
}