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
impl Message
sourcepub fn matches(&mut self, other: &Message) -> bool
pub fn matches(&mut self, other: &Message) -> bool
Matches this message with another. Used to validate requests with responses.
sourcepub fn get_write_value_at_address(&self, address: u16) -> Option<u16>
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.
sourcepub fn get_address_range(&self) -> Option<RangeInclusive<u16>>
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