register_write_message — Register Write Messages

API Documentation

Register Writing Request/Response Messages

class pymodbus.register_write_message.WriteSingleRegisterRequest(address=None, value=None, **kwargs)

This function code is used to write a single holding register in a remote device.

The Request PDU specifies the address of the register to be written. Registers are addressed starting at zero. Therefore register numbered 1 is addressed as 0.

__init__(address=None, value=None, **kwargs)

Initializes a new instance

Parameters:
  • address – The address to start writing add
  • value – The values to write
__str__()

Returns a string representation of the instance

Returns:A string representation of the instance
decode(data)

Decode a write single register packet packet request

Parameters:data – The request to decode
encode()

Encode a write single register packet packet request

Returns:The encoded packet
execute(context)

Run a write single register request against a datastore

Parameters:context – The datastore to request from
Returns:An initialized response, exception message otherwise
get_response_pdu_size()

Func_code (1 byte) + Register Address(2 byte) + Register Value (2 bytes) :return:

class pymodbus.register_write_message.WriteSingleRegisterResponse(address=None, value=None, **kwargs)

The normal response is an echo of the request, returned after the register contents have been written.

__init__(address=None, value=None, **kwargs)

Initializes a new instance

Parameters:
  • address – The address to start writing add
  • value – The values to write
__str__()

Returns a string representation of the instance

Returns:A string representation of the instance
decode(data)

Decode a write single register packet packet request

Parameters:data – The request to decode
encode()

Encode a write single register packet packet request

Returns:The encoded packet
class pymodbus.register_write_message.WriteMultipleRegistersRequest(address=None, values=None, **kwargs)

This function code is used to write a block of contiguous registers (1 to approx. 120 registers) in a remote device.

The requested written values are specified in the request data field. Data is packed as two bytes per register.

__init__(address=None, values=None, **kwargs)

Initializes a new instance

Parameters:
  • address – The address to start writing to
  • values – The values to write
__str__()

Returns a string representation of the instance

Returns:A string representation of the instance
decode(data)

Decode a write single register packet packet request

Parameters:data – The request to decode
encode()

Encode a write single register packet packet request

Returns:The encoded packet
execute(context)

Run a write single register request against a datastore

Parameters:context – The datastore to request from
Returns:An initialized response, exception message otherwise
class pymodbus.register_write_message.WriteMultipleRegistersResponse(address=None, count=None, **kwargs)

“The normal response returns the function code, starting address, and quantity of registers written.

__init__(address=None, count=None, **kwargs)

Initializes a new instance

Parameters:
  • address – The address to start writing to
  • count – The number of registers to write to
__str__()

Returns a string representation of the instance

Returns:A string representation of the instance
decode(data)

Decode a write single register packet packet request

Parameters:data – The request to decode
encode()

Encode a write single register packet packet request

Returns:The encoded packet