Simple modbus client based on Qt framework
apt install qt5-default libqt5serialbus5-dev
git clone https://github.com/lirik90/modbus_cli.git
cd modbus_cli
qmake
make -j2
./modbus_cli -h
-h, --help Displays help on commandline options.
--help-all Displays help including Qt specific options.
-a, --address <adr> Device address. Default: 1
-t, --type <type> Register type. Default: 4 holding_register
-r, --read Read from device.
-w, --write <values> Write to device. Values comma separated. Example: 1,2,3
--rw, --readwrite <values> Write and read device.
-s, --start <start> Start value address. Default: 0
-c, --count <count> Values read count. Default: 1
--repeat <repeat> Repeat command. -1 is infinity. Default: 0
--timeout <timeout> Modbus response timeout in milliseconds. Default: 1000
--raw <raw> Write raw data (hex)
--func <func> Function code for raw request
--func_hex <func_hex> Function code for raw request (hex)
./modbus_cli -r -t 4 -a 1 -s 1103 -c 2 mtcp://10.10.2.106:502
./modbus_cli -r -t 4 -a 1 -s 0 -c 2 rtu:///dev/ttyUSB0?baudRate=9600
./modbus_cli --address 1 --func_hex 10 --raw 00020001020002 rtu:///dev/ttyS0?baudRate=9600
./modbus_cli -w 15,24,35 -t 4 -a 1 -s 0 rtu:///dev/ttyUSB0?baudRate=9600&dataBits=8&parity=2&stopBits=1&flowControl=0
Can use values 5, 6, 7, or 8
- 0 is NoParity
- 2 is EvenParity
- 3 is OddParity
- 4 is SpaceParity
- 5 is MarkParity
- 1 is OneStop
- 2 is TwoStop
- 3 is OneAndHalfStop
- 0 is NoFlowControl
- 1 is HardwareControl
- 2 is SoftwareControl
- 1 or discrete
- 2 or coils
- 3 or input_register
- 4 or holding_register