Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
R413D08 8 Channel Module
This Rust project enables communication with an R413D08 8 Channel Module using Modbus RTU/TCP from the command line. It should also work with the R421A08 relay card because it has the same Modbus commands.
Table of Contents
- Hardware Requirements
- Technical Documentation
- Technical Specifications
- Installation & Compilation
- Command-Line Usage
- Library Usage
- Cargo Features
- License
Hardware Requirements
To use this tool, you need:
- One or more R413D08 8 Channel Module.
- One or more 1-8 Channel Relay Board.
- A USB-to-RS485 converter (for RTU mode).

Technical Documentation
For more detailed information, please refer to the official datasheets available in the docs/ directory:
Technical Specifications R413D08
| Feature | Details |
|---|---|
| Operating Voltage | 5V DC (5V version) or 6-24V DC (12V version) |
| Operating Current | 10-15mA |
| Baud Rates | 9600 |
| Data Format | N, 8, 1 (No parity, 8 data bits, 1 stop bit) |
| Communication Protocol | Modbus RTU/TCP |
Installation & Compilation
Prerequisites
Ensure you have the following dependencies installed before proceeding:
- Rust and Cargo: Install via rustup
- Git: To clone the repository
Building from Source
- Clone the repository:
- Compile the project:
The compiled binary will be available at: - (Optional) Install the binary system-wide:
This installsrelayto$HOME/.cargo/bin, making it accessible from anywhere.
Command-Line Usage
This tool provides a range of commands for device discovery, configuration, and data acquisition.
Connection Types
You can connect to the relay module via Modbus RTU (serial) or TCP.
- RTU (Serial):
- TCP:
Available Commands
Help
To see a full list of commands and options:
Read Commands
- Read Relay Status: Reads the ON/OFF status of all 8 relays.
Set Commands
- Turn a Relay ON:
# Turn on relay 0 - Turn a Relay OFF:
# Turn off relay 3
Library Usage
This project can also be used as a library in your own Rust applications. It provides a high-level, thread-safe SafeClient for easy interaction with the R413D08 module, available in both synchronous and asynchronous versions.
Quick Start: Synchronous Client
Here's a quick example of how to use the synchronous SafeClient to read relay statuses over a TCP connection.
Dependencies
First, add the required dependencies to your project:
Example Usage
use ;
use tcp;
use Slave;
For more advanced use cases, the library also provides low-level, stateless functions in the r413d08_lib::tokio_sync and r413d08_lib::tokio_async modules.
Cargo Features
This crate uses a feature-based system to minimize dependencies. When using it as a library, you should disable default features and select only the components you need.
default: Enablesbin-dependencies, intended for compiling therelaycommand-line tool.
Client Features
tokio-rtu-sync: Synchronous (blocking) RTU client.tokio-tcp-sync: Synchronous (blocking) TCP client.tokio-rtu: Asynchronous (non-blocking) RTU client.tokio-tcp: Asynchronous (non-blocking) TCP client.
High-Level Wrappers
safe-client-sync: A thread-safe, stateful wrapper for synchronous clients.safe-client-async: A thread-safe, stateful wrapper for asynchronous clients.
Utility Features
serde: Implementsserde::Serializeandserde::Deserializefor protocol structs.bin-dependencies: All features required to build therelaybinary.
License
Licensed under either of:
- Apache License, Version 2.0 (LICENSE-APACHE or Apache)
- MIT License (LICENSE-MIT or MIT)
at your option.