示例#1
0
def write_multiple_registers(slave_id, starting_address, values):
    """ Return ADU for Modbus function code 16: Write Multiple Registers.

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

    return _create_request_adu(slave_id, function.request_pdu)
示例#2
0
def write_multiple_registers(slave_id, starting_address, values):
    """ Return ADU for Modbus function code 16: Write Multiple Registers.

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

    return _create_request_adu(slave_id, function.request_pdu)
示例#3
0
def write_multiple_registers():
    function_code = 16
    starting_address = 100
    quantity = 3
    byte_count = 6
    values = [1337, 15, 128]

    pdu = struct.pack('>BHHBHHH', function_code, starting_address, quantity,
                      byte_count, *values)
    return WriteMultipleRegisters.create_from_request_pdu(pdu)
示例#4
0
def write_multiple_registers():
    instance = WriteMultipleRegisters()
    instance.starting_address = 50
    instance.values = [1337, 15, 128]

    return instance
示例#5
0
def test_write_multiple_registers_response_pdu(write_multiple_registers):
    response_pdu = write_multiple_registers.create_response_pdu()
    instance = WriteMultipleRegisters.create_from_response_pdu(response_pdu)

    assert instance.starting_address == 50
    assert instance.data == 3
示例#6
0
def test_write_multiple_registers_request_pdu(write_multiple_registers):
    instance = WriteMultipleRegisters.create_from_request_pdu(
        write_multiple_registers.request_pdu)  # NOQA

    assert instance.starting_address == 50
    assert instance.values == [1337, 15, 128]
def write_multiple_registers():
    instance = WriteMultipleRegisters()
    instance.starting_address = 50
    instance.values = [1337, 15, 128]

    return instance
def test_write_multiple_registers_response_pdu(write_multiple_registers):
    response_pdu = write_multiple_registers.create_response_pdu()
    instance = WriteMultipleRegisters.create_from_response_pdu(response_pdu)

    assert instance.starting_address == 50
    assert instance.data == 3
def test_write_multiple_registers_request_pdu(write_multiple_registers):
    instance = WriteMultipleRegisters.create_from_request_pdu(write_multiple_registers.request_pdu)  # NOQA

    assert instance.starting_address == 50
    assert instance.values == [1337, 15, 128]