Skip to content

A cross-platform implementation for modbus client/master used for testing/simulating modbus server/host

Notifications You must be signed in to change notification settings

LysanderT/Modbus-Client-App

Repository files navigation

Modbus Client


Modbus Client is a robust, cross-platform and elegant implementation for modbus master to test modbus server.

Given that there is currently no open-source & cross-platform Modbus client software with GUI available online (either not free or <.exe> type that can only be running on Windows), I implemented one with minimal dependencies (Qt library).

Table of Content

Developing Process

1.FUNCTION

  • construct modbus frame
  • send data
  • determine the time interval of sending data
  • receive data
  • parse and analyze the received data

2.MODE

  • RTU-serial
  • TCP

3.SUPPORTED FUNCTION CODE

  • 0x01
  • 0x02
  • 0x03
  • 0x04
  • 0x05
  • 0x06
  • ...

4.FEATURES

  • export data as csv/excel/txt/xml file
    • csv
    • excel
    • txt
    • xml
  • 'real' progress bar
  • catch the case when server actively terminate the TCP connection
  • clearable send/read logs
  • interactively sorting tableview
  • Automatically detects how the client data is stored (little/big endianness)
  • Choose how the server stores float32 data (little/big endianness)
  • ...

5.BUILD

  • qmake
  • cmake

6.SUPPORTED DATA TYPE

  • int
  • bool
  • float32

7.TEST

  • simulation - (utilized unslave.exe installed on a Windows PC)
  • on real device

8.OPTIMIZATION

  • Decoupling using MVC design pattern (table/model/delegate in qt)
  • Modelize the code
  • Page the setup widget according to the mode
  • Minimize the cell width to make the window look better
  • Merge multiple successive single reading query into one
  • Use the Dom Tree to generate xml file

9.TODO

  • 16/32/64-bit register read/write (process data)
  • page the data according to different display order or sorting
  • export table data as .xml file
  • process float32
  • identify the os/compiler using macro to make it compatible
  • add Demonstration(gif/video) to readme

Perequisites

void prerequisites(){
    download and install the QtCreator; 
    // high-version qt may not have QSerialPort module installed
    if(the version u chose does not include QSerialPort module){
        find QT maintenance tool in the Qt folder;
        use the tool to add the QSerialPort module;
    }
}

You can also use other IDEs like VSCode, but you need to configure the environment by yourself.

For VSCode, you can refer to this to configure the environment.

Usage

git clone -b main https://github.com/LysanderT/Modbus-Client-App ;
void run_with_qmake(){
    double click the ModbusQT.pro file in the Modbus-Client-App folder (which will open the project in Qt Creator);

    click the run button in the bottom left corner of Qt Creator;
}

void run_with_cmake(){
    double click the CMakeLists.txt file in the Modbus-Client-App folder (which will open the project in Qt Creator)
    
    click the run button in the bottom left corner of Qt Creator;
}

You can also package the project into an executable file (which is easy using QT Creator) and run it directly.

Float32

if you want to use float32 data type, you should specify the endianness of the slave (little-edian by default, the endianness of the master if automatically specified).

if you don't know the endianness of the slave, the following code may help.

bool IsBigEndian()
{
  int a = 0x1234;
  char b = *(char *)&a;
  if( b == 0x12)
  {
    return true;
  }
  return false;
}

to use this data type, the register should be at least 32 bit.

Demonstration

should be a video or .gif here

Developing Environment

  • MacOS Ventura 13.1
  • Qt 6.2.3
  • QtCreator 7.0.2
  • CMake 3.26.4

To contribute

  1. fork the repo to your local repo
  2. write/change something in the local repo
  3. back to the original repo and raise Pull Request

👍 any contribution is welcome!

About

A cross-platform implementation for modbus client/master used for testing/simulating modbus server/host

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published