Crates.io | dsmr-parse |
lib.rs | dsmr-parse |
version | 0.4.2 |
created_at | 2025-07-05 17:59:31.881827+00 |
updated_at | 2025-07-05 18:40:17.815687+00 |
description | Library for parsing DSMR telegrams |
homepage | |
repository | https://github.com/twistedfall/dsmr-parse |
max_upload_size | |
id | 1739353 |
size | 54,564 |
Support the project | Documentation
Run:
cargo add dsmr-parse
Or add to your Cargo.toml:
[dependencies]
dsmr-parse = "0.4.2"
A small library for parsing DSMR 5 (Dutch Smart Meter Requirements) telegrams from Dutch electricity meters.
The central struct is [Telegram] with its single method [Telegram::read_from]. Pass anything that implements std::io::Read
to it, and it will try to read a valid and conforming DSMR telegram with the correct CRC from it.
use dsmr_parse::Telegram;
// Open serial port (example path)
let port = serialport::new("/dev/ttyUSB0", 115_200);
// Parse telegram
match Telegram::read_from(port.open().unwrap()) {
Ok(Some(telegram)) => println!("Read telegram: {telegram:?}"),
Ok(None) => eprintln!("No complete telegram read"),
Err(e) => eprintln!("Parse error: {e}"),
}
use dsmr_parse::Telegram;
let telegram_data = b"/XMX5LGBBFG1009394887\r\n\r\n1-3:0.2.8(42)\r\n0-0:1.0.0(190101125431W)\r\n1-0:1.8.1(004169.415*kWh)\r\n!1234\r\n";
match Telegram::read_from(telegram_data.as_slice()) {
Ok(Some(telegram)) => println!("Read telegram: {telegram:?}"),
Ok(None) => println!("No complete telegram in data"),
Err(e) => eprintln!("Parse error: {e}"),
}
MIT OR Apache-2.0