Available on crate feature
safe-client-sync and (crate features tokio-rtu-sync or tokio-tcp-sync) only.Expand description
Synchronous tokio-modbus client for the R4DCB08 temperature module.
This module provides a high-level API (SafeClient struct) to interact with
the R4DCB08 8-channel temperature module using Modbus RTU or TCP. It handles
the conversion between Rust types defined in the crate::protocol module and
the raw Modbus register values.
§Example
use r4dcb08_lib::{
protocol::Address,
tokio_sync_safe_client::SafeClient,
};
use tokio_modbus::client::sync::tcp;
use tokio_modbus::Slave;
fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to the device and create a stateful, safe client
let socket_addr = "192.168.1.100:502".parse()?;
let ctx = tcp::connect_slave(socket_addr, Slave(*Address::default()))?;
let mut client = SafeClient::new(ctx);
// Use the client to interact with the device
let temperatures = client.read_temperatures()?;
println!("Successfully read temperatures. Current values: {}", temperatures);
Ok(())
}Structs§
- Safe
Client - Synchronous client for interacting with the R4DCB08 temperature module over Modbus.