Skip to main content

ModbusCtx

Struct ModbusCtx 

Source
pub struct ModbusCtx<'a, H, I, C, D> {
    pub holdings: &'a mut H,
    pub inputs: &'a mut I,
    pub coils: &'a mut C,
    pub ists: &'a mut D,
}
Expand description

ModbusCtx,用于沟通上下文

Fields§

§holdings: &'a mut H§inputs: &'a mut I§coils: &'a mut C§ists: &'a mut D

Implementations§

Source§

impl<'a, H, I, C, D> ModbusCtx<'a, H, I, C, D>

Source

pub fn pharse_pdu<const MAX_QTY: usize>( &mut self, req8: &[u8; 8], out_tx: &mut [u8], out_exc: &mut [u8; 5], ) -> usize

pharse_pdu: 解析固定 8 字节 Modbus RTU 请求,并组装响应/异常 返回值:

  • 正常响应:返回 out_tx 中的长度
  • 异常响应:写入 out_exc,并返回 5
Source

pub fn pharse_frame<const MAX_QTY: usize>( &mut self, req: &[u8], out_tx: &mut [u8], out_exc: &mut [u8; 5], ) -> usize

pharse_frame:处理可变长度 Modbus RTU 请求帧(01/02/03/04/05/06 固定8,15/16 可变) out_tx:成功响应写入缓冲 out_exc:异常响应固定 5 字节缓冲

Auto Trait Implementations§

§

impl<'a, H, I, C, D> Freeze for ModbusCtx<'a, H, I, C, D>

§

impl<'a, H, I, C, D> RefUnwindSafe for ModbusCtx<'a, H, I, C, D>

§

impl<'a, H, I, C, D> Send for ModbusCtx<'a, H, I, C, D>
where H: Send, I: Send, C: Send, D: Send,

§

impl<'a, H, I, C, D> Sync for ModbusCtx<'a, H, I, C, D>
where H: Sync, I: Sync, C: Sync, D: Sync,

§

impl<'a, H, I, C, D> Unpin for ModbusCtx<'a, H, I, C, D>

§

impl<'a, H, I, C, D> UnsafeUnpin for ModbusCtx<'a, H, I, C, D>

§

impl<'a, H, I, C, D> !UnwindSafe for ModbusCtx<'a, H, I, C, D>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.