bit_write_message
— Bit Write Modbus Messages¶
API Documentation¶
Bit Writing Request/Response¶
TODO write mask request/response
-
class
pymodbus.bit_write_message.
WriteSingleCoilRequest
(address=None, value=None, **kwargs)¶ 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.
-
__init__
(address=None, value=None, **kwargs)¶ Initializes a new instance
Parameters: - address – The variable address to write
- value – The value to write at address
-
__str__
()¶ Returns a string representation of the instance
Returns: A string representation of the instance
-
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
-
get_response_pdu_size
()¶ Func_code (1 byte) + Output Address (2 byte) + Output Value (2 Bytes) :return:
-
-
class
pymodbus.bit_write_message.
WriteSingleCoilResponse
(address=None, value=None, **kwargs)¶ The normal response is an echo of the request, returned after the coil state has been written.
-
__init__
(address=None, value=None, **kwargs)¶ Initializes a new instance
Parameters: - address – The variable address written to
- value – The value written at address
-
__str__
()¶ Returns a string representation of the instance
Returns: A string representation of the instance
-
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, **kwargs)¶ “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.”
-
__init__
(address=None, values=None, **kwargs)¶ Initializes a new instance
Parameters: - address – The starting request address
- values – The values to write
-
__str__
()¶ Returns a string representation of the instance
Returns: A string representation of the instance
-
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, **kwargs)¶ The normal response returns the function code, starting address, and quantity of coils forced.
-
__init__
(address=None, count=None, **kwargs)¶ Initializes a new instance
Parameters: - address – The starting variable address written to
- count – The number of values written
-
__str__
()¶ Returns a string representation of the instance
Returns: A string representation of the instance
-
decode
(data)¶ Decodes a write coils response
Parameters: data – The packet data to decode
-
encode
()¶ Encodes write coils response
Returns: The byte encoded message
-