parse_data_records/
parse_data_records.rs1use m_bus_application_layer::{parse_data_records, DataRecordError};
2
3fn main() -> Result<(), DataRecordError> {
4 let data = [
6 0x03, 0x13, 0x15, 0x31, 0x00, 0x02, 0x5A, 0xD7, 0x04, ];
9
10 for (index, record) in parse_data_records(&data).enumerate() {
11 let record = record?;
12
13 println!("Record {}", index + 1);
14 println!(" value: {:?}", record.value());
15 if let Some(value_information) = record.value_information() {
16 println!(" labels: {:?}", value_information.labels);
17 println!(" scale: 10^{}", value_information.decimal_scale_exponent);
18 println!(" units: {:?}", value_information.units);
19 }
20 println!(" raw bytes: {:02X?}", record.raw_bytes());
21 }
22
23 Ok(())
24}