pub struct RtuApplicationLayer { /* private fields */ }Implementations§
Source§impl RtuApplicationLayer
impl RtuApplicationLayer
Sourcepub fn new<P: PhysicalLayer + 'static>(
physical: Arc<P>,
options: RtuApplicationLayerOptions,
) -> Arc<Self> ⓘ
pub fn new<P: PhysicalLayer + 'static>( physical: Arc<P>, options: RtuApplicationLayerOptions, ) -> Arc<Self> ⓘ
Build an RTU application layer bound to physical.
Options (all optional; see RtuApplicationLayerOptions for defaults):
interval_between_frames— overrides the default 3.5T computation.FrameInterval::Bits(n)—nbit-times (default 38.5 = 3.5 char times).FrameInterval::Ms(n)— explicit milliseconds.- On serial with
None: baud > 19200 → 1.75 ms (spec fix), elseceil((38.5 * 1000) / baud).
inter_char_timeout— opt-in t1.5. Disabled by default. Same units. On serial: baud > 19200 → 0.75 ms, elseceil((16.5 * 1000) / baud).baud_rate— defaults to 9600 for Serial. Ignored on Net.
Sourcepub fn add_custom_function_code(&self, cfc: CustomFunctionCode)
pub fn add_custom_function_code(&self, cfc: CustomFunctionCode)
Register a custom function code predictor. Required for any non-standard FC; without registration the frame is rejected with a framing error.
pub fn remove_custom_function_code(&self, fc: u8)
Trait Implementations§
Source§impl ApplicationLayer for RtuApplicationLayer
impl ApplicationLayer for RtuApplicationLayer
Source§fn set_role(&self, role: ApplicationRole) -> Result<(), ModbusError>
fn set_role(&self, role: ApplicationRole) -> Result<(), ModbusError>
Bind the application layer to a master/slave role. Must succeed on the
first call and fail (
ModbusError::InvalidState) if a different role
is then assigned. Re-assigning the same role is a no-op (idempotent).Source§fn role(&self) -> Option<ApplicationRole>
fn role(&self) -> Option<ApplicationRole>
Current role, or
None if not yet assigned.Source§fn protocol(&self) -> ApplicationProtocol
fn protocol(&self) -> ApplicationProtocol
Wire protocol implemented by this layer. Used by
ModbusMaster to
validate concurrent configuration at construction time.Source§fn encode(&self, adu: &ApplicationDataUnit) -> Vec<u8> ⓘ
fn encode(&self, adu: &ApplicationDataUnit) -> Vec<u8> ⓘ
Encode an ADU into wire bytes per the protocol’s framing format
(MBAP for TCP, CRC for RTU, hex+LRC for ASCII).
Source§fn decode(&self, data: &[u8]) -> Result<FramedDataUnit, ModbusError>
fn decode(&self, data: &[u8]) -> Result<FramedDataUnit, ModbusError>
Decode a single complete frame back into an ADU. Returned only for
backward compatibility with the previous stateless API; new consumers
should subscribe to
subscribe_framing instead.Source§fn flush(&self)
fn flush(&self)
Drop any per-connection state (decoding buffers, timers). Called by
Master before each request, by Slave between sessions.
Source§fn subscribe_framing(&self) -> Receiver<Framing>
fn subscribe_framing(&self) -> Receiver<Framing>
Subscribe to successfully framed PDUs assembled from the underlying
physical layer.
Source§fn subscribe_framing_error(&self) -> Receiver<ModbusError>
fn subscribe_framing_error(&self) -> Receiver<ModbusError>
Subscribe to framing-level errors (CRC/LRC failure, invalid MBAP
header, etc.). One error per offending physical-layer chunk.
Source§fn destroy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn destroy<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = ()> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Release task handles and drop physical-layer subscriptions.
Source§fn add_custom_function_code(&self, _cfc: CustomFunctionCode)
fn add_custom_function_code(&self, _cfc: CustomFunctionCode)
Register a custom function code predictor. Default is a no-op; only
RtuApplicationLayer overrides this with real behavior.Source§fn remove_custom_function_code(&self, _fc: u8)
fn remove_custom_function_code(&self, _fc: u8)
Remove a previously registered custom function code. Default is a no-op.
Auto Trait Implementations§
impl !Freeze for RtuApplicationLayer
impl RefUnwindSafe for RtuApplicationLayer
impl Send for RtuApplicationLayer
impl Sync for RtuApplicationLayer
impl Unpin for RtuApplicationLayer
impl UnsafeUnpin for RtuApplicationLayer
impl UnwindSafe for RtuApplicationLayer
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more