sml-kit
Read German smart meters in Rust. sml-kit decodes SML (Smart Message Language) from a
meter's optical interface or the meter bus behind a smart-meter gateway into exact
readings: sans-I/O, no_std, no allocator, no dependencies.
Documentation · What is SML? · API reference
use ;
// Call with every chunk of bytes from the reading head. Keep one decoder per meter
// (`Decoder::new([0; 1024])`): a frame often arrives across several reads.
Install
To read a real meter you need an infrared reading head on its optical interface (9600 baud, 8N1) and, for power and full-precision energy, the PIN from your meter operator. What is SML? explains both.
Tested against real meters
Every CRC-valid frame of the public libsml-testing collection reads: 216 frames from EMH, ISKRA, DZG, eBZ, Holley, Itron, EasyMeter and Dr. Neuhaus meters, strictly for every meter but one. Three meters deviate from the specification; sml-kit reads them when you name the deviation:
| Meter | Deviation | Option |
|---|---|---|
| Holley DTZ541 (some) | CRC-16/KERMIT instead of X-25 | ParseOptions::lenient() |
| Holley DTZ541-ZDBA, DDZ285 | SML_Time without its choice tag |
ParseOptions::lenient() |
| DZG DVS74 (affected serials) | 356.24 W sent as −299.12 W | .with_dzg_power(true) |
The capture tool tells you which one your meter needs:
Features
| Transport v1 | sans-I/O Decoder over an owned or borrowed buffer; encode_frame |
| Readings in one call | readout, GetListResponse::quantity; exact Quantity with unit |
| Values | OBIS (parse, names), the DLMS unit table, SML_Time, ServerId as printed on the meter |
| Energy direction | direction, signed_power from the status word, for meters that send power without a sign |
| Every message body | Open, Close, GetList, Get/SetProcParameter, GetProfileList/Pack, Attention: typed, read and written |
| Request files | SmlFile: open, requests, close with transaction IDs and CRCs in one call |
Blocking I/O (std) |
io::FrameReader over any std::io::Read |
| Async | the same Decoder in Embassy, Tokio or any runtime, no dependency |
| Simulator | sim::Telegram for tests |
Not supported: verifying SML signatures (they are exposed as bytes), transport version 2 (no device sends it), and IEC 62056-21 text (an older protocol).
Design
- Sans-I/O. No ports or clocks inside: feed bytes from a reading head, a meter bus or a file.
no_std, no allocator, no dependencies. CI checks the Cortex-M release build for panic paths.- Exact. Readings are
mantissa × 10^scalerwith their unit, never floats: a meter reading is evidence for an invoice. - Strict by default. Both CRCs are checked; every deviation a real meter needs is a named option.
- Never panics on input. Malformed, truncated and random bytes are errors; the parsers are fuzzed.
- No secrets in logs. Request passwords print as
<redacted>.
Examples
License
Licensed under either of Apache License, Version 2.0
or MIT license at your option.
The captures in tests/corpus/ keep their own MIT notices.
Not affiliated with the BSI or any meter manufacturer. SML is specified in BSI TR-03109-1, Annex IV.