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 [ C : modbus_t * ] [ Python : ctypes.POINTER(modbus_t) ]
Specify the pointer to the libmodbus structure.
addr [ C : int ] [ Python : ctypes.c_int ]
Specify the start address to write.
value [ C : uint_16_t ] [ Python : ctypes.c_uint16 ]
Specify the data to be written.
Return values
ret [ 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.
C |
int ret; modbus_t *ctx; ret = modbus_write_register( ctx, 0, 0x55 );
|
Python |
ret = ctypes.c_int ctx = ctypes.POINTER(modbus_t) ret = modbus.modbus_write_register(ctx, 0, 0x55)
|