Ejemplo n.º 1
0
def read_discrete_inputs(slave_id, starting_address, quantity):
    """ Return ADU for Modbus function code 02: Read Discrete Inputs.

    :param slave_id: Number of slave.
    :return: Byte array with ADU.
    """
    function = ReadDiscreteInputs()
    function.starting_address = starting_address
    function.quantity = quantity

    return _create_request_adu(slave_id, function.request_pdu)
Ejemplo n.º 2
0
def read_discrete_inputs(slave_id, starting_address, quantity):
    """ Return ADU for Modbus function code 02: Read Discrete Inputs.

    :param slave_id: Number of slave.
    :return: Byte array with ADU.
    """
    function = ReadDiscreteInputs()
    function.starting_address = starting_address
    function.quantity = quantity

    return _create_request_adu(slave_id, function.request_pdu)
Ejemplo n.º 3
0
def read_discrete_inputs():
    instance = ReadDiscreteInputs()
    instance.starting_address = 0
    instance.quantity = 2

    return instance
Ejemplo n.º 4
0
def test_read_discrete_inputs_response_pdu(read_discrete_inputs):
    response_pdu = read_discrete_inputs.create_response_pdu([1, 0])
    instance = ReadDiscreteInputs.create_from_response_pdu(
        response_pdu, read_discrete_inputs.request_pdu)  # NOQA

    assert instance.data == [1, 0]
Ejemplo n.º 5
0
def test_read_discrete_inputs_request_pdu(read_discrete_inputs):
    instance = ReadDiscreteInputs.create_from_request_pdu(
        read_discrete_inputs.request_pdu)  # NOQA
    assert instance.starting_address == 0
    assert instance.quantity == 2
def read_discrete_inputs():
    instance = ReadDiscreteInputs()
    instance.starting_address = 0
    instance.quantity = 2

    return instance
def test_read_discrete_inputs_response_pdu(read_discrete_inputs):
    response_pdu = read_discrete_inputs.create_response_pdu([1, 0])
    instance = ReadDiscreteInputs.create_from_response_pdu(response_pdu, read_discrete_inputs.request_pdu)  # NOQA

    assert instance.data == [1, 0]
def test_read_discrete_inputs_request_pdu(read_discrete_inputs):
    instance = ReadDiscreteInputs.create_from_request_pdu(read_discrete_inputs.request_pdu)  # NOQA
    assert instance.starting_address == 0
    assert instance.quantity == 2