Skip to content

For: Qt 5.15.2. A simple fix which allows ModbusTCP handle my custom commands.

Notifications You must be signed in to change notification settings

YuryMalyshev/Qt5SerialBus-ModbusTCP_fix

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Qt5SerialBus-ModbusTCP_fix

For: Qt 5.15.2 (opensource) A simple fix which allows ModbusTCP handle my custom commands.

How to add new custom commands:

  1. Add the command to "enum FunctionCode" in "qmodbuspdu.h" file
  2. Add minimum data size case for the command to a switch case in "static int minimumDataSize(const QModbusPdu &pdu, Type type)" function inside of "qmodbuspdu.cpp".
  3. Register data size calculator inside your main:
QModbusResponse::registerDataSizeCalculator(QModbusPdu::FunctionCode(custom_fun_code), [](const QModbusResponse &)-> int
{
    return 42;
});

(4. Build Qt. The resulting dll (on Windows) will be in \qtbase\bin)


To build Qt follow the instructions from here: GitHub - Qt5

Sometimes the compilation might result in an error (tested on Windows10). Adding -opengl desktop parameter to "configuration" might help.


The files should be placed into "..\qt5\qtserialbus\src\serialbus"

About

For: Qt 5.15.2. A simple fix which allows ModbusTCP handle my custom commands.

Resources

Stars

Watchers

Forks

Languages