bit_write_message — Bit Write Modbus Messages

Module author: Galen Collins <bashwork@gmail.com>

Section author: Galen Collins <bashwork@gmail.com>

API Documentation

Bit Writing Request/Response

TODO write mask request/response

class pymodbus.bit_write_message.WriteSingleCoilRequest(address=None, value=None)

This function code is used to write a single output to either ON or OFF in a remote device.

The requested ON/OFF state is specified by a constant in the request data field. A value of FF 00 hex requests the output to be ON. A value of 00 00 requests it to be OFF. All other values are illegal and will not affect the output.

The Request PDU specifies the address of the coil to be forced. Coils are addressed starting at zero. Therefore coil numbered 1 is addressed as 0. The requested ON/OFF state is specified by a constant in the Coil Value field. A value of 0XFF00 requests the coil to be ON. A value of 0X0000 requests the coil to be off. All other values are illegal and will not affect the coil.

decode(data)

Decodes a write coil request

Parameters:data – The packet data to decode
encode()

Encodes write coil request

Returns:The byte encoded message
execute(context)

Run a write coil request against a datastore

Parameters:context – The datastore to request from
Returns:The populated response or exception message
class pymodbus.bit_write_message.WriteSingleCoilResponse(address=None, value=None)

The normal response is an echo of the request, returned after the coil state has been written.

decode(data)

Decodes a write coil response

Parameters:data – The packet data to decode
encode()

Encodes write coil response

Returns:The byte encoded message
class pymodbus.bit_write_message.WriteMultipleCoilsRequest(address=None, values=None)

“This function code is used to force each coil in a sequence of coils to either ON or OFF in a remote device. The Request PDU specifies the coil references to be forced. Coils are addressed starting at zero. Therefore coil numbered 1 is addressed as 0.

The requested ON/OFF states are specified by contents of the request data field. A logical ‘1’ in a bit position of the field requests the corresponding output to be ON. A logical ‘0’ requests it to be OFF.”

decode(data)

Decodes a write coils request

Parameters:data – The packet data to decode
encode()

Encodes write coils request

Returns:The byte encoded message
execute(context)

Run a write coils request against a datastore

Parameters:context – The datastore to request from
Returns:The populated response or exception message
class pymodbus.bit_write_message.WriteMultipleCoilsResponse(address=None, count=None)

The normal response returns the function code, starting address, and quantity of coils forced.

decode(data)

Decodes a write coils response

Parameters:data – The packet data to decode
encode()

Encodes write coils response

Returns:The byte encoded message