针对工业上位机的通讯测试工具类及实例。包含各类厂商的PLC协议及基础的TCP、串口通讯、IO口通讯等协议通讯功能的实现整合,努力完善中。
PLC-CommunTools is a modern communication debugging/testing tool designed for Windows industrial PLC hardware communication protocols. Built with C# 12 and .NET 8 LTS, it provides comprehensive protocol support, multiple client interfaces, and server-side capabilities with Docker containerization.
# Clone the repository
git clone https://github.com/SmallRob/PLC-CommunTools.git
cd PLC-CommunTools
# Start with Docker Compose
cd docker
docker-compose up -d# Build the solution
dotnet build CommunTools.New.sln
# Run the server
dotnet run --project src/Server/Commun.Server.API/Commun.Server.API.csproj
# Run CLI tool
dotnet run --project src/Clients/Commun.Client.CLI/Commun.Client.CLI.csproj -- --help…| Method | Endpoint | Description |
|---|---|---|
| GET | /api/devices |
Get all devices |
| GET | /api/devices/{id} |
Get device by ID |
| POST | /api/devices |
Create new device |
| PUT | /api/devices/{id} |
Update device |
| DELETE | /api/devices/{id} |
Delete device |
| GET | /api/protocol/protocols |
Get available protocols |
| POST | /api/protocol/{deviceId}/connect |
Connect to device |
| POST | /api/protocol/{deviceId}/disconnect |
Disconnect from device |
| POST | /api/protocol/{deviceId}/send |
Send command to device |
| GET | /api/protocol/{deviceId}/status |
Get connection status |
…| Category | Technology |
|---|---|
| Runtime | .NET 8 LTS |
| Web Framework | ASP.NET Core 8.0 |
| ORM | Entity Framework Core 8.0 |
| Database | SQLite |
| MQTT Client | MQTTnet 5.x |
| CLI Framework | System.CommandLine |
| Containerization | Docker + Docker Compose |
| Reverse Proxy | Nginx |
# Run all tests
dotnet test CommunTools.New.sln
# Run specific test project
dotnet test tests/Commun.Protocols.Tests/Commun.Protocols.Tests.csproj
# Run with verbose output
dotnet test CommunTools.New.sln --verbosity normalgit checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)This project is licensed under the MIT License - see the LICENSE file for details.
PLC-CommunTools 是一个现代化的通讯调试/测试工具,专为 Windows 工业 PLC 硬件通讯协议而设计。基于 C# 12 和 .NET 8 LTS 构建,提供全面的协议支持、多种客户端接口和服务端功能,支持 Docker 容器化部署。
# 克隆仓库
git clone https://github.com/SmallRob/PLC-CommunTools.git
cd PLC-CommunTools
# 使用 Docker Compose 启动
cd docker
docker-compose up -d# 构建解决方案
dotnet build CommunTools.New.sln
# 运行服务端
dotnet run --project src/Server/Commun.Server.API/Commun.Server.API.csproj
# 运行 CLI 工具
dotnet run --project src/Clients/Commun.Client.CLI/Commun.Client.CLI.csproj -- --help# 连接 Modbus 设备
dotnet run --project src/Clients/Commun.Client.CLI/Commun.Client.CLI.csproj -- connect --protocol Modbus --address 192.168.1.100 --port 502
# 读取寄存器值
dotnet run --project src/Clients/Commun.Client.CLI/Commun.Client.CLI.csproj -- read --device --register 100
# 写入寄存器值
dotnet run --project src/Clients/Commun.Client.CLI/Commun.Client.CLI.csproj -- write --device --register 100 --value 12345
# 监控寄存器变化
dotnet run --project src/Clients/Commun.Client.CLI/Commun.Client.CLI.csproj -- monitor --device --register 100 --interval 1000| 方法 | 端点 | 描述 |
|---|---|---|
| GET | /api/devices |
获取所有设备 |
| GET | /api/devices/{id} |
根据 ID 获取设备 |
| POST | /api/devices |
创建新设备 |
| PUT | /api/devices/{id} |
更新设备 |
| DELETE | /api/devices/{id} |
删除设备 |
| GET | /api/protocol/protocols |
获取可用协议 |
| POST | /api/protocol/{deviceId}/connect |
连接设备 |
| POST | /api/protocol/{deviceId}/disconnect |
断开设备连接 |
| POST | /api/protocol/{deviceId}/send |
向设备发送命令 |
| GET | /api/protocol/{deviceId}/status |
获取连接状态 |
…| 类别 | 技术 |
|---|---|
| 运行时 | .NET 8 LTS |
| Web 框架 | ASP.NET Core 8.0 |
| ORM | Entity Framework Core 8.0 |
| 数据库 | SQLite |
| MQTT 客户端 | MQTTnet 5.x |
| CLI 框架 | System.CommandLine |
| 容器化 | Docker + Docker Compose |
| 反向代理 | Nginx |
# 运行所有测试
dotnet test CommunTools.New.sln
# 运行特定测试项目
dotnet test tests/Commun.Protocols.Tests/Commun.Protocols.Tests.csproj
# 运行并显示详细输出
dotnet test CommunTools.New.sln --verbosity normalgit checkout -b feature/amazing-feature)git commit -m 'Add amazing feature')git push origin feature/amazing-feature)本项目采用 MIT 许可证 - 详见 LICENSE 文件。
No open issues yet, or sync has not completed.