Voltage Modbus
High-performance Modbus TCP/RTU library for Rust, designed for industrial automation and IoT applications.
Features
- Async/await with Tokio
- Modbus TCP and RTU protocols
- Zero unsafe code
- Generic client architecture (TCP/RTU share application logic)
Installation
For RTU (serial) support:
= { = "0.4", = ["rtu"] }
Quick Start
TCP Client
use ;
use Duration;
async
RTU Client
use ;
use Duration;
async
Supported Function Codes
| Code | Function | Status |
|---|---|---|
| 0x01 | Read Coils | ✅ |
| 0x02 | Read Discrete Inputs | ✅ |
| 0x03 | Read Holding Registers | ✅ |
| 0x04 | Read Input Registers | ✅ |
| 0x05 | Write Single Coil | ✅ |
| 0x06 | Write Single Register | ✅ |
| 0x0F | Write Multiple Coils | ✅ |
| 0x10 | Write Multiple Registers | ✅ |
Architecture
┌─────────────────────────────────────────────────┐
│ Application Layer │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ ModbusTcpClient │ │ ModbusRtuClient │ │
│ └────────┬────────┘ └────────┬────────┘ │
│ └──────────┬───────────┘ │
│ ┌──────────┴───────────┐ │
│ │ GenericModbusClient │ │
│ │ (Shared PDU Logic) │ │
│ └──────────────────────┘ │
└─────────────────────────────────────────────────┘
┌─────────────────────────────────────────────────┐
│ Transport Layer │
│ ┌─────────────────┐ ┌─────────────────┐ │
│ │ TcpTransport │ │ RtuTransport │ │
│ └─────────────────┘ └─────────────────┘ │
└─────────────────────────────────────────────────┘
TCP and RTU share identical PDU (Protocol Data Unit), differing only in transport framing.
Documentation
License
MIT License - see LICENSE for details.