IoT Protocol, Modbus
Modbus Protocol #
- 一文看懂 Modbus 协议
- Complete Modbus Guide.
- a good intro to Modbus.
- nice intro to Modbus and Modbus Enron.
Serial Port/Line/Connection Simulator/Emulator #
- Note: Setup / Use (Write & Read) Linux serial ports require root permission
com0com / Null-modem emulator (windows, free) [suggested for win] #
- serial line/connections
a kernel-mode virtual serial port driver for Windows.
download from sourceforge
free virtual serial ports (windows, free & commercial) #
- serial line/connections
- free version limit: port not permanent
- commercial version: support remote virtual paired ports (based on samba?)
tty0tty (linux, free) [suggested for nix] #
- serial line/connections (pair of searial ports)
- need to compile (a bug is fixed by sunny)
https://gitcode.net/sino/tty0tty
The modem status lines are properly emulated, but the “termios” (行规程) settings are not.
virtual serial port driver /vspd (windows, commercial) #
- serial line/connections (pair of searial ports)
Suports 3 modes: null-modem / loopback, standard, customed wire connections.
14 天试用。汉化版: 虚拟串口驱动
vtty (linux, free) #
- serial line/connections (pair of searial ports) (not tested)
https://github.com/anszom/vtty
virtual serial port driver for linux / vspdl (linux, free) #
(having problems to install)
https://tibbo.com/support/downloads/vspdl.html
socat (linux, free, build-in) #
actually, not exactlly a good choice for my need.
Modbus Master & Slave Device Debug/Simulation/Emulation Tools #
mthings (windows, free) [suggested for win] #
- in-app serial line/connections (TCP/UDP only, NO RTU, inside the software only).
- master & slave devices.
5 分钟入门 MThings 视频;
官方 B 站;
官方博客 CSDN;
基于 MThings 搭建模拟主机调试 MODBUS 从机设备.
- 主窗口如图,左上角的菜单是控制右边显示的。
- COM 口是从系统自动识别的,不需要“添加”,MODBUS-RTU 一般配置为无校验(无奇偶校验,因为已有 CRC)。
- 设置完“设备起始地址”和“设备结束地址”后,点击“添加”,然后选择“模拟主机”还是“模拟从机”,点击确定会自动添加两个地址(含)中间范围内所有的地址 所对应的“主机/上位机”或“从机”到左侧边栏。
- 中间左边,[M]表示 master/主机/上位机/client,[S]表示 slave/从机/server。
在数据界面,点击“批量读”后,“同步至其他设备”意思是其他设备也批量读,“循环”选项也会被“同步”。
在数据界面,如果在“批量读”过程中点击“配置”,会停止当前地址(设备)数据的读取,但是不影响其他地址(设备)。即,此停止没有自动“同步”到其他设备。
Ref: 面包板 eet-china, (bak)
modbus poll & modebus slave (windows, commercial) #
- master (Modbus Poll) & slave (Modbus Slave) devices.
developed by Witte Software (modbustools.com).
modbus mechanic (java jar, thus cross-platform) [suggested for nix] #
- master & slave
- GUI & headless
- RTU scanner
Requires: OpenJDK (both jdk and modbusMechanic are pre-compiled)
Simple guide:
sudo java -jar ./ModbusMechanic.jar
Complete guide:
Add a slave/server with registers: select type (TCP vs RTU) & port & baud rate; Tools > Start Slave Simulator (can start many slave devices); setup a register & value type & a value and “Add” (can add many to one slave).
Read:
Option 1. use ModbusMechanic: select type (TCP vs RTU) & port & baud rate (canNOT be the port occupied by slave simulator); set Slave-Node (station address) and Register; set value type; “Transmit Packet”.
Option 2. use other tools, such as modpoll from modbusdriver.com.
modbus-utils / libmodbus-dev #
- master & slave
cd ~
# download src & dev lib
sudo apt install libmodbus-dev
git clone https://github.com/Krzysztow/modbus-utils.git
# install option 1
$ cd modbus-utils
$ git submodule update --init
$ mkdir build
$ cd build
$ cmake ..
$ make
# OR:
# install option 2
cd modbus-utils/modbus_client
gcc -o modbus_client modbus_client.c -lmodbus -I/usr/include/modbus -I$HOME/modbus-utils/common
cd ../modbus_server
gcc -o modbus_server modbus_server.c -lmodbus -I/usr/include/modbus -I$HOME/modbus-utils/common
mbpoll (linux, free) #
- master only (not tested)
- totally free but need to compile from source with some careness.
https://manpages.ubuntu.com/manpages/jammy/en/man1/mbpoll.1.html
modbusdriver.com (cross-platform library, free & commercial) #
- master (modpoll) & slave (diagslave) demo & library
- commercial, 30-day free trial
Pro (free demo): for windows & linux; compile for multi-platforms.
Note: Slave (diagslave) provides fixed all-zero values.
Commercial lib with free master & slave demo:
More Modebus Tools #
- masters:
- free: QModMaster, Modbus Tester, Modpoll from proconX, RMMS (Radzio! Modbus Master Simulator).
- commercial: Simply Modbus Master (RTU and ASCII ), Modbus Poll from modbus tools, ModScan32 from WinTECH.
- salves:
- free: ModRSsim2 was forked from MOD_RSSIM (Windows-based Modbus PLC Simulator), pyModSlave based on Qt (video tutorial).
- commercial: WinModbus (www.winmodbus.com), UnSlave Modbus Slave Simulator.
- libraries
- FreeMODBUS: free with separated ASCII/RTU and TCP.
- libmodbus: BSD 3-clause, for Linux, Mac OS X, FreeBSD, QNX and Win32.
- another list of useful tools
RS 232 vs. 422 vs. 485 (电气规定的区别) #
ref: