Function
Uses the function code Write Register (code 06) to write 1 register to the holding register area.
Format
ret = modbus_write_register( ctx , addr , value )
Parameters
ctx [ VB.NET: IntPtr ] [ C, C++: modbus_t * ] [ C#: IntPtr ] [ Python: ctypes.POINTER(modbus_t) ]
Specify the pointer to the libmodbus structure.
addr [ VB.NET: Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
Specify the start address to write.
value [ VB.NET: UShort ] [ C, C++: uint_16_t ] [ C#: ushort ] [ Python: ctypes.c_uint16 ]
Specify the data to be written.
Return values
ret [ VB.NET:Integer ] [ C, C++: int ] [ C#: int ] [ Python: ctypes.c_int ]
If the function succeeds, the number of registers that were successfully written is returned.
If the function fails, -1 is returned.
Remarks
Uses the function code Write Register (code 06) to write 1 register to the holding register area.
Example
Writes 0x55 to the register at address 0.
VB.NET |
Dim ret As Integer Dim ctx As IntPtr ret = modbus_write_register(ctx, 0, &H55)
|
C, C++ |
int ret; modbus_t *ctx; ret = modbus_write_register( ctx, 0, 0x55 );
|
C# |
int ret; IntPtr ctx; ret = modbus.WriteRegister(ctx, 0, 0x55);
|
Python |
ret = ctypes.c_int ctx = ctypes.POINTER(modbus_t) ret = modbus.modbus_write_register(ctx, 0, 0x55)
|