# RtuSimulator **Repository Path**: wangchaogitee/rtu-simulator ## Basic Information - **Project Name**: RtuSimulator - **Description**: No description available - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: main - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2026-04-29 - **Last Updated**: 2026-04-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # RTU 设备模拟器 这个程序用于模拟外部 Modbus RTU 设备,配合网关程序做完整联调。 ## 默认模拟值 - BMU功耗:初始化为 `234 kWh`,内部按 `234000 Wh` 写入 Holding Register 71~72,float32 ABCD。 - BMU温度/湿度:默认约 `25.0℃ / 50.0%RH`。 - A侧容量箱:默认约 `24.6℃ / 49.2%RH`。 - B侧容量箱:默认约 `25.4℃ / 51.0%RH`。 为了更接近现场,程序会自动让温湿度在设定值附近轻微波动。Web 页面滑块设置的是“中心值”,RTU 寄存器实际输出值会围绕该中心值跳动。 BMU功耗是累计电能,程序默认从 234kWh 起步,运行后缓慢增加,避免累计电能出现不合理的上下跳变。 ## 运行 ```bash go mod tidy go build -o rtu_sim.exe main.go ./rtu_sim.exe ``` 浏览器打开: ```text http://127.0.0.1:8080 ``` ## 串口配置 根据你的 USB 转 485 实际串口号修改 `config.yaml`: ```yaml port: "COM5" port: "COM6" port: "COM7" port: "COM8" ``` Linux 下可以改为: ```yaml port: "/dev/ttyUSB0" port: "/dev/ttyUSB1" ```