# `register_read_message` — Register Read Messages

## API Documentation

### Register Reading Request/Response

class `pymodbus.register_read_message.``ReadRegistersRequestBase`(address, count, **kwargs)

  Base class for reading a modbus register

  `__init__`(address, count, **kwargs)

    Initializes a new instance

    Parameters:

    - address – The address to start the read from
    - count – The number of registers to read

  `encode`()

    Encodes the request packet

    Returns: | The encoded packet

  `decode`(data)

    Decode a register request packet

    Parameters: | data – The request to decode

  `get_response_pdu_size`()

    Func_code (1 byte) + Byte Count(1 byte) + 2 * Quantity of Coils (n Bytes) :return:

  `__str__`()

    Returns a string representation of the instance

    Returns: | A string representation of the instance

class `pymodbus.register_read_message.``ReadRegistersResponseBase`(values, **kwargs)

  Base class for responsing to a modbus register read

  `__init__`(values, **kwargs)

    Initializes a new instance

    Parameters: | values – The values to write to

  `encode`()

    Encodes the response packet

    Returns: | The encoded packet

  `decode`(data)

    Decode a register response packet

    Parameters: | data – The request to decode

  `getRegister`(index)

    Get the requested register

    Parameters: | index – The indexed register to retrieve
    Returns: | The request register

  `__str__`()

    Returns a string representation of the instance

    Returns: | A string representation of the instance

class `pymodbus.register_read_message.``ReadHoldingRegistersRequest`(address=None, count=None, **kwargs)

  This function code is used to read the contents of a contiguous block of holding registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore registers numbered 1-16 are addressed as 0-15.

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

    Initializes a new instance of the request

    Parameters:

    - address – The starting address to read from
    - count – The number of registers to read from address

  `execute`(context)

    Run a read holding request against a datastore

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

class `pymodbus.register_read_message.``ReadHoldingRegistersResponse`(values=None, **kwargs)

  This function code is used to read the contents of a contiguous block of holding registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore registers numbered 1-16 are addressed as 0-15.

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

    Initializes a new response instance

    Parameters: | values – The resulting register values

class `pymodbus.register_read_message.``ReadInputRegistersRequest`(address=None, count=None, **kwargs)

  This function code is used to read from 1 to approx. 125 contiguous input registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore input registers numbered 1-16 are addressed as 0-15.

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

    Initializes a new instance of the request

    Parameters:

    - address – The starting address to read from
    - count – The number of registers to read from address

  `execute`(context)

    Run a read input request against a datastore

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

class `pymodbus.register_read_message.``ReadInputRegistersResponse`(values=None, **kwargs)

  This function code is used to read from 1 to approx. 125 contiguous input registers in a remote device. The Request PDU specifies the starting register address and the number of registers. In the PDU Registers are addressed starting at zero. Therefore input registers numbered 1-16 are addressed as 0-15.

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

    Initializes a new response instance

    Parameters: | values – The resulting register values

class `pymodbus.register_read_message.``ReadWriteMultipleRegistersRequest`(**kwargs)

  This function code performs a combination of one read operation and one write operation in a single MODBUS transaction. The write operation is performed before the read.

  Holding registers are addressed starting at zero. Therefore holding registers 1-16 are addressed in the PDU as 0-15.

  The request specifies the starting address and number of holding registers to be read as well as the starting address, number of holding registers, and the data to be written. The byte count specifies the number of bytes to follow in the write data field.”

  `__init__`(**kwargs)

    Initializes a new request message

    Parameters:

    - read_address – The address to start reading from
    - read_count – The number of registers to read from address
    - write_address – The address to start writing to
    - write_registers – The registers to write to the specified address

  `encode`()

    Encodes the request packet

    Returns: | The encoded packet

  `decode`(data)

    Decode the register request packet

    Parameters: | data – The request to decode

  `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) + Byte Count(1 byte) + 2 * Quantity of Coils (n Bytes) :return:

  `__str__`()

    Returns a string representation of the instance

    Returns: | A string representation of the instance

class `pymodbus.register_read_message.``ReadWriteMultipleRegistersResponse`(values=None, **kwargs)

  The normal response contains the data from the group of registers that were read. The byte count field specifies the quantity of bytes to follow in the read data field.

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

    Initializes a new instance

    Parameters: | values – The register values to write

  `encode`()

    Encodes the response packet

    Returns: | The encoded packet

  `decode`(data)

    Decode the register response packet

    Parameters: | data – The response to decode

  `__str__`()

    Returns a string representation of the instance

    Returns: | A string representation of the instance