Skip to main content

Crate m_bus_application_layer

Crate m_bus_application_layer 

Source
Expand description

Parser for the M-Bus application layer defined by EN 13757-3.

Use parse_application_layer when the input starts with a control information (CI) field. Use parse_data_records when the transport header has already been removed and the input starts with a DIF/VIF data record.

§Parse data records directly

use m_bus_application_layer::{
    data_information::DataType, parse_data_records, DataRecordError,
};

fn main() -> Result<(), DataRecordError> {
    // 24-bit integer, volume in m³ with a 10^-3 scale.
    let data = [0x03, 0x13, 0x15, 0x31, 0x00];
    let mut records = parse_data_records(&data);
    let record = records.next().expect("one data record")?;

    assert_eq!(record.value(), Some(&DataType::Number(12_565.0)));
    assert_eq!(record.raw_bytes(), &data);
    Ok(())
}

Re-exports§

pub use variable_user_data::DataRecordError;
pub use self::data_record::DataRecord;

Modules§

data_information
data_record
decryption
extended_link_layer
value_information
variable_user_data

Structs§

Counter
DataRecords
LongTplHeader
ShortTplHeader
StatusField

Enums§

ApplicationLayerError
ApplicationResetSubcode
ControlInformation
Direction
UserDataBlock

Functions§

parse_application_layer
Parses an application-layer user data block beginning with a CI field.
parse_data_records
Parses DIF/VIF data records after any CI and transport headers were removed.
parse_data_records_with_header
Parses DIF/VIF data records using context from a long transport header.