- New public API: moved to async/await and tokio v0.2.x
- Removed unmaintained dependency
tokio-proto
- Make
Exception
andExceptionResponse
public - Fixed
WriteSingleCoil
reponse to include data - Hide server traits
Service
/NewService
traits behindserver
feature - Hide TCP server implementation behind
tcp-server-unstable
feature - Improved documentation
Due to the move to async/await and tokio v0.2.x you'll need to adjust your current code. Here are some lines as example:
-let mut core = Core::new().unwrap();
-let handle = core.handle();
let socket_addr = "127.0.0.1:5502".parse().unwrap();
-let task = tcp::connect(&handle, socket_addr).and_then(move |ctx|
- ctx.read_input_registers(0x1000, 7).and_then(move |data|
- // ...
- )
-);
+let mut ctx = tcp::connect(socket_addr).await?;
+let data = ctx.read_input_registers(0x1000, 7).await?;
- Added missing implementation of
disconnect()
for TCP clients - Upgraded tokio-serial to version 3.3
- Disabled the default features of tokio-serial to exclude an unused dependency on libudev inherited from mio-serial
- Fixed reading coils: Truncate response payload to match the requested number of coils or discrete inputs.
- Client: Added a
Disconnect
request as poison pill for stopping the client service and to release the underlying transport - Added utilities to share a single Modbus context within a thread for communicating with multiple devices
- Added utility functions to disconnect and reconnect stale connections after errors
- Minimal Rust version:
1.34.0
Extending the Request
enum with the new variant Disconnect
might break
existing code. This variant is only used internally within the client and
will never be sent across the wire and can safely be ignored by both clients
and servers!
- RTU client: Use a generic async transport instead of
Serial
- New public API
- Client: Change devices while connected
- TCP Client: Connect to RTU devices via gateway (unit identifier)
- RTU Client: Try to recover from frame errors
-
Make all public crate exports accessible in the new
prelude
module- use tokio_modbus::*; + use tokio_modbus::prelude::*;
-
Rename and relocate client traits
- client::ModbusClient + client::Client
- client::SyncModbusClient + client::sync::Client
-
Rename and relocate Client structs into Context
- client::Client + client::Context
- client::SyncClient + client::sync::Context
-
Split
Client
trait intoClient
+Reader
+Writer
traits -
Use free functions in (nested) submodules for creating/connecting a client context
- Client::connect_tcp(...); + tcp::connect(...) or tcp::connect_device(...);
- Client::connect_rtu(...); + rtu::connect_device(...);
- SyncClient::connect_tcp(...); + sync::tcp::connect(...) or sync::tcp::connect_device(...);
- SyncClient::connect_rtu(...); + sync::rtu::connect_device(...);
-
Reorder parameters of asynchronous connect() functions, i.e. the Tokio handle is always the first parameter
-
Move TCP server into submodule
- Server::new_tcp(socket_addr).serve(...); + tcp::Server::new(socket_addr).serve(...);
- fix decoding of incomplete RTU frames
- fix compilation with
features = ["rtu"]
- refactor: use
tokio-codec
- refactor: use
put_u16_be
instead ofput_u16::<BigEndian>
- refactor: prepare for compilation with
edition = "2018"
- fix codec: create buffers with correct capacity
- add simple tcp server implementation
- add sync clients
- use tokio-serial v0.6.x
- Changed Client API
- use tokio_modbus::{Client, TcpClient}; + use tokio_modbus::*;
- RtuClient::connect(port, server_addr, &handle) + Client::connect_rtu(port, server_addr, &handle)
- TcpClient::connect(&addr, &handle) + Client::connect_tcp(&addr, &handle)
- initial implementation