Esempio n. 1
0
def test_create_function_from_response_pdu():
    read_coils = ReadCoils()
    read_coils.starting_address = 1
    read_coils.quantity = 9

    req_pdu = read_coils.request_pdu
    resp_pdu = struct.pack('>BBB', 1, 1, 3)

    assert isinstance(create_function_from_response_pdu(resp_pdu, req_pdu),
                      ReadCoils)
def test_create_function_from_response_pdu():
    read_coils = ReadCoils()
    read_coils.starting_address = 1
    read_coils.quantity = 9

    req_pdu = read_coils.request_pdu
    resp_pdu = struct.pack('>BBB', 1, 1, 3)

    assert isinstance(create_function_from_response_pdu(resp_pdu, req_pdu),
                      ReadCoils)
Esempio n. 3
0
def read_coils(slave_id, starting_address, quantity):
    """ Return ADU for Modbus function code 01: Read Coils.

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

    return _create_request_adu(slave_id, function.request_pdu)
Esempio n. 4
0
def read_coils(slave_id, starting_address, quantity):
    """ Return ADU for Modbus function code 01: Read Coils.

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

    return _create_request_adu(slave_id, function.request_pdu)
Esempio n. 5
0
def read_coils():
    instance = ReadCoils()
    instance.starting_address = 100
    instance.quantity = 3

    return instance
def read_coils():
    instance = ReadCoils()
    instance.starting_address = 100
    instance.quantity = 3

    return instance