ljean / modbus-tk

Create Modbus app easily with Python
Other
557 stars 211 forks source link

support easy integration of custom function codes #149

Closed sebastian-bantel closed 2 years ago

sebastian-bantel commented 3 years ago

custom function codes can be easily send by setting "pdu", "data_format" and "expected_length"

example caller code for custom function codes:

def Execute_CustomFunctionCode(customFunctionCode):

    pdu = struct.pack('>BBHHI', customFunctionCode, 0x01, 0x0000, 0xffff, 0x00000010)
    expected_length = 11
    data_format = ">BHHH"

    regs = client.execute(0x01,
        defines.RAW,
        0x0000,
        pdu = pdu, data_format = data_format, expected_length = expected_length)

    return regs