Modbus Simulator 
go install github.com/LaysDragon/Modbus-Simulator modbus_simulator -mode tui
配置文件
本工具通過配置來表示各裝置參數以及連線組織
- deviceType/**
目錄下存放各類型設備的參數配置
- config.yaml
負責組織裝置連線
deviceType/SmartMeter.yaml
name: "SmartMeter"
parameters:
- name: "Voltage"
address: 0
type: "uint16"
function_code: 3 # Holding Register
script: "random(220, 240)"
- name: "Current"
address: 1
type: "float32"
function_code: 4 # Input Register
script: "random(0, 100) / 10.0"
- name: "Status"
address: 0
type: "bool"
function_code: 1 # Coil
script: "true"
config.yaml
devices:
- name: "Meter1"
slave_id: 1
type: "SmartMeter"
# response_delay_script: "100" # ms
monitored_parameters:
- Voltage
- Status
connections:
- name: "LocalServer"
transport_type: "RTU_OVER_TCP"
connection_mode: "DIAL"
address: "localhost:1234"
devices:
- Meter1