From 70dc99a33f1ae34dd27815bf37d87a21507af28b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20St=C3=BCrz?= Date: Fri, 3 Jun 2022 08:46:35 +0200 Subject: [PATCH] Update readme for modbus tool --- libnymea-modbus/tools/README.md | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/libnymea-modbus/tools/README.md b/libnymea-modbus/tools/README.md index 939fd4a..a3fc623 100644 --- a/libnymea-modbus/tools/README.md +++ b/libnymea-modbus/tools/README.md @@ -24,7 +24,7 @@ The basic structure of the modbus register JSON looks like following example: ``` { "className": "MyConnection", - "protocols": [ "TCP" ], + "protocol": "BOTH", "endianness": "BigEndian", "enums": [ { @@ -108,7 +108,6 @@ The source code files will be calld: * `classnameprotocolconnection.cpp` - ## Protocol Depending on the communication protocol, a different base class will be used for the resulting output class. @@ -220,20 +219,16 @@ Example block: ] -# Example +# Autogenerate modbus classes -Change into your plugin sub directory. -Assuming you wrote the registers.json file you can run now following command to generate your modbus class: - -`$ python3 ../modbus/tools/generate-connection.py -j registers.json -o . -c MyModbus` - -You the result will be a header and a source file called: - -* `mymodbustcpconnection.h` -* `mymodbustcpconnection.cpp` - -You can include this class in your project and provide one connection per thing. +In order to get always the latest generated code from this tool, the entire process can be automated. +Assuming you have defined the registers in the `my-registers.json` within your plugin directory, and following lines to your plugin project file and run `qmake`. + # Generate modbus connection + MODBUS_CONNECTIONS += my-registers.json + include(../modbus.pri) +If you want to get information about the autogenerating class process, you can add `MODBUS_TOOLS_CONFIG += VERBOSE` in order to get much more information of the process. +Once you run qmake, in the build directory the autogenerated classes can be found. Also in your project you can find the generated classes for inspection.