A Rust Modbus library.
A simple Modbus TCP Server:
```rust,no_run use std::error::Error;
use futures::SinkExt; use tokio::net::{TcpListener, TcpStream}; use tokiostream::StreamExt; use tokioutil::codec::Framed;
use easy_modbus::{Frame, codec::TcpServerCodec};
async fn main() -> Result<(), Box
loop {
let (stream, _) = server.accept().await?;
tokio::spawn(async move {
if let Err(e) = process(stream).await {
println!("failed to process connection; error = {}", e);
}
});
}
}
async fn process(stream: TcpStream) -> Result<(), Box
A simple Modbus TCP Client:
``` rust,no_run use std::error::Error;
use futures::SinkExt; use tokio::net::TcpStream; use tokiostream::StreamExt; use tokioutil::codec::Framed;
use easy_modbus::{Frame, codec::TcpClientCodec};
async fn main() -> Result<(), Box
transport.send(request).await?;
while let Some(response) = transport.next().await {
match response {
Ok(response) => {
println!("{:?}", response);
}
Err(e) => {
return Err(e.into());
}
}
}
Ok(())
} ```
This project is licensed under the [MIT license].