Function
Uses the function code Write Coil (code 05) to write 1 bit to the Coil area.
Format
ret = modbus_write_bit( ctx , addr , status )
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.
status [ C : int ] [ Python : ctypes.c_int ]
Specify 0 or 1 for the data to be written.
Return values
ret [ C : int ] [ Python : ctypes.c_int ]
If the function succeeds, 0 is returned.
If the function fails, -1 is returned.
Remarks
Uses the function code Write Coil (code 05) to write 1 bit to the Coil area.
Example
Writes 1 to the bit at address 0.
C |
int ret; modbus_t *ctx; ret = modbus_write_bit( ctx, 0, 1 );
|
Python |
ret = ctypes.c_int ctx = ctypes.POINTER(modbus_t) ret = modbus.modbus_write_bit(ctx, 0, 1)
|