FieldTalk™ Modbus Master .NET Library

MbusMasterFunctions.maskWriteRegister Method 

Modbus function 22 (16 hex), Mask Write Register.

[Visual Basic]
Public Function maskWriteRegister( _
   ByVal slaveAddr As Integer, _
   ByVal regAddr As Integer, _
   ByVal andMask As UInt16, _
   ByVal orMask As UInt16 _
) As Integer
[C#]
public int maskWriteRegister(
   int slaveAddr,
   int regAddr,
   ushort andMask,
   ushort orMask
);

Parameters

slaveAddr
Modbus address of slave device or unit identifier (Range: 1 - 255)
regAddr
Register address (Range: 1 - $10000)
andMask
Mask to be applied as a logic AND to the register
orMask
Mask to be applied as a logic OR to the register

Return Value

BusProtocolErrors.FTALK_SUCCESS on success or error code. See BusProtocolErrors for possible error codes.

Remarks

Masks bits according to an AND and an OR mask into a single output register (holding register, 4:00000 reference). Masking is done as follows: retVal = (currentVal AND andMask) OR (orMask AND andMask)

Note    No broadcast supported

See Also

MbusMasterFunctions Class | FieldTalk Namespace