Struct sawp_modbus::Message

source ·
pub struct Message {
    pub transaction_id: u16,
    pub protocol_id: u16,
    pub unit_id: u8,
    pub function: Function,
    pub access_type: Flags<AccessType>,
    pub category: Flags<CodeCategory>,
    pub data: Data,
    pub error_flags: Flags<ErrorFlags>,
    /* private fields */
}
Expand description

Breakdown of the parsed modbus bytes

Fields§

§transaction_id: u16§protocol_id: u16§unit_id: u8§function: Function§access_type: Flags<AccessType>§category: Flags<CodeCategory>§data: Data§error_flags: Flags<ErrorFlags>

Implementations§

source§

impl Message

source

pub fn matches(&mut self, other: &Message) -> bool

Matches this message with another. Used to validate requests with responses.

source

pub fn get_write_value_at_address(&self, address: u16) -> Option<u16>

Gets the register/coil/input value at the given address, if it has been modified in the transaction. Returns the value as Some(u16) if it is found, otherwise returns None. The address passed in must be offset by 1 to reflect the actual coil/register and not the address found in the PDU. See the protocol reference for more information on addresses.

source

pub fn get_address_range(&self) -> Option<RangeInclusive<u16>>

Gets the address and quantity in the read/write data. If the data does not match and they can’t be found, None is returned. The range returned is offset by 1 to account to reflect the coils/registers that start at 1 instead of in the PDU numbers where they start at 0. More details can be found in the protocol reference

Trait Implementations§

source§

impl Debug for Message

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl From<&Message> for Flags<CodeCategory>

source§

fn from(msg: &Message) -> Self

Converts to this type from the input type.
source§

impl PartialEq<Message> for Message

source§

fn eq(&self, other: &Message) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl StructuralPartialEq for Message

Auto Trait Implementations§

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

const: unstable · source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

const: unstable · source§

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

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

const: unstable · source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

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

const: unstable · 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 Twhere U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.
source§

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

§

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

The type returned in the event of a conversion error.
const: unstable · source§

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

Performs the conversion.