Ejemplo n.º 1
0
def write_multiple_coils(slave_id, starting_address, values):
    """ Return ADU for Modbus function code 15: Write Multiple Coils.

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

    return _create_request_adu(slave_id, function.request_pdu)
Ejemplo n.º 2
0
def write_multiple_coils(slave_id, starting_address, values):
    """ Return ADU for Modbus function code 15: Write Multiple Coils.

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

    return _create_request_adu(slave_id, function.request_pdu)
Ejemplo n.º 3
0
def write_multiple_coils():
    function_code = 15
    starting_address = 100
    quantity = 10
    byte_count = 2
    values = (2, 1)

    pdu = struct.pack('>BHHBBB', function_code, starting_address, quantity,
                      byte_count, *values)
    return WriteMultipleCoils.create_from_request_pdu(pdu)
Ejemplo n.º 4
0
def write_multiple_coils():
    instance = WriteMultipleCoils()
    instance.starting_address = 100
    instance.values = [1, 0]

    return instance
Ejemplo n.º 5
0
def test_write_multiple_coils_response_pdu(write_multiple_coils):
    response_pdu = write_multiple_coils.create_response_pdu()
    instance = WriteMultipleCoils.create_from_response_pdu(response_pdu)

    assert instance.starting_address == 100
    assert instance.data == 2
Ejemplo n.º 6
0
def test_write_multiple_coils_request_pdu(write_multiple_coils):
    instance = WriteMultipleCoils.create_from_request_pdu(
        write_multiple_coils.request_pdu)  # NOQA

    assert instance.starting_address == 100
    assert instance.values == [1, 0]
def write_multiple_coils():
    instance = WriteMultipleCoils()
    instance.starting_address = 100
    instance.values = [1, 0]

    return instance
def test_write_multiple_coils_response_pdu(write_multiple_coils):
    response_pdu = write_multiple_coils.create_response_pdu()
    instance = WriteMultipleCoils.create_from_response_pdu(response_pdu)

    assert instance.starting_address == 100
    assert instance.data == 2
def test_write_multiple_coils_request_pdu(write_multiple_coils):
    instance = WriteMultipleCoils.create_from_request_pdu(write_multiple_coils.request_pdu)  # NOQA

    assert instance.starting_address == 100
    assert instance.values == [1, 0]