mbus-serial
mbus-serial is a helper crate for modbus-rs.
It provides a standard serial transport implementation for Modbus RTU and Modbus ASCII,
built on top of the shared transport abstractions in mbus-core.
If you want an all-in-one entry point, use modbus-rs.
If you need direct access to serial transport internals, use mbus-serial directly.
Helper Crate Role
mbus-serial is intentionally focused on transport concerns:
- Implements
Transportfrommbus-core. - Connects to real serial ports via the
serialportcrate. - Supports both
SerialMode::RtuandSerialMode::Ascii.
This crate does not implement high-level request/response orchestration by itself.
That logic lives in mbus-client.
What Is Included
StdSerialTransport: concrete serial implementation ofmodbus_rs::Transport.- Serial connection handling (open/close/check connection).
- ADU send/receive support.
- Error mapping from I/O errors to
TransportError. - Utility function to enumerate serial ports.
Public API Surface
The crate currently re-exports:
StdSerialTransport
from:
management::std_serial
Usage
1) Add dependencies
[]
= "0.5.0"
2) Create serial config and transport
use ;
3) List available serial ports
use StdSerialTransport;
Configuration Notes
StdSerialTransport::new(mode)must match the mode inModbusSerialConfig. If they do not match,connectreturnsTransportError::InvalidConfiguration.stop_bitsmust be1or2.response_timeout_mscontrols serial read timeout behavior.
Logging
mbus-serial supports optional logging via the log facade.
- Enable feature:
logging - This only emits through the facade; your application provides a logger backend.
Example dependency setup:
[]
= { = "0.5.0", = ["logging"] }
= "0.11"
Platform Notes
- Uses the
serialportcrate under the hood. - Error behavior can vary by driver/OS.
- Some pseudo-terminals (especially on macOS) may not support all serial parameter operations.
Typical Integration Pattern
In most applications, mbus-serial is used together with mbus-client:
- Build
ModbusConfig::Serial(...). - Instantiate
StdSerialTransport. - Pass transport into
ClientServicesfrommbus-client. - Use client services for function-code operations.
License
Copyright (C) 2025 Raghava Challari
This project is currently licensed under GNU GPL v3.0. See LICENSE for details.
Contact
For questions or support:
- Name: Raghava Ch
- Email: ch.raghava44@gmail.com