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§
Structs§
Enums§
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.