mbus-kit
M-Bus and wireless M-Bus (EN 13757) for Rust: read heat, water and gas meters with a sans-I/O, no_std, allocation-free core.
Documentation Β· API reference
π§ Pre-release. Checked against a corpus of 41 real and published telegrams from 20 manufacturers (libmbus, wmbusmeters, jMBus, OMS Annex N), wired and wireless, plain and encrypted. The API may still change before 1.0.
Heat, water, gas and heat-cost-allocator meters across Europe speak M-Bus: wired (EN 13757-2, two-wire bus) or by radio (wireless M-Bus, EN 13757-4, and its OMS profile). Both carry the same application layer (EN 13757-3). mbus-kit turns those bytes into exact, fully described readings:
use Frame;
use Application;
And by radio, encrypted (feature oms):
use Key;
use ;
let key = from_hex.unwrap;
let mut buf = ;
if let Some = open?
What it does
| Layer | Status |
|---|---|
| Wired link layer (EN 13757-2): ACK, short, control and long frames, checksum; resynchronising scan for noisy lines | β parse and encode, incremental (asks for more bytes) |
| Wired master (sans-I/O): complete readout with FCB and retries, secondary addressing with wildcards, bus search, set address, baud rate, clock, application reset; replies only from the addressed meter (optionally bound to its printed ID), and every readout says whether it is complete | β tested against a simulated bus of 250 meters; fuzzed |
Real converters (serial::Bus, std, no dependency): the master over any Read + Write β a USB level converter or a TCP gateway; echo, noise and collisions handled, every wait bounded |
β simulated converter and a real socket |
JSON (json, no_std, no allocation): one object per telegram β meter, authenticity, every record with exact value, unit, storage, tariff |
β every corpus telegram checked by a strict parser; fuzzed |
mbus tool (feature cli, no dependency): decode, read, search, listen, text or --json, sets up serial ports itself |
β |
Receiver sticks (stick, no_std): IMST iM871A, IMST iU891A, Amber AMB8465 β telegrams with RSSI, receive-mode commands |
β checked against real captures |
| Wireless link layer (EN 13757-4): frame formats A and B with CRC-16/EN-13757 per block, or CRCs already removed by the receiver | β decode; encode format A |
Extended link layer (CI 8Cβ8F) and authentication and fragmentation layer (CI 90), with fragment reassembly into your buffer |
β checked against OMS Annex N N.3βN.5 |
Compact frames (CI 79/7B/73) and format frames: values without their layout, expanded with a layout cache you own, checked by the full-frame CRC |
β |
Transport layer: CI 72/7A/78/51, commands 5A/5B, errors 6Eβ70, alarms 71/74/75, 80/8A/8B |
β |
OMS security (feature oms): mode 5 (AES-CBC), mode 7 (KDF, AES-CBC, CMAC verified), mode 10 (AES-CCM, tag verified), ELL AES-CTR; keys zeroized, never printed |
β checked against OMS Annex N and real meters |
| Data records: DIF/DIFE, VIF/VIFE, plain-text VIF, LVAR, filler, manufacturer data | β lazily, without allocating |
Value information: primary, FB, FD, FD FD tables and every combinable VIFE (EN 13757-3:2018), typed |
β
Kind, Modifier; correction factors applied exactly |
| Values: integers (signed and unsigned), BCD (incl. negative and invalid), IEEE reals (exactly, as decimals), dates and times (types G, J, F, I), time offsets (type M) | β
exact Quantity, never floats |
Compact profiles (VIFE 13/1E/1F): monthly or interval history as readings with their dates or offsets |
β checked against OMS Annex G and N.13 |
| Mode 13 (TLS), data types K/L | Not yet |
Design
- Sans-I/O. No serial port, no radio driver, no clock. Feed bytes from an M-Bus level converter, a wM-Bus receiver stick or a capture file.
no_std, no allocator. The default build has no dependencies;omsadds only the RustCrypto AES modes andzeroize. Records borrow from the frame. The library's release build for a Cortex-M contains no panic path, checked in CI.- Exact. Readings are
mantissa Γ 10^exponentwith their unit, never floats. Correction factors are applied exactly; a VIFE the crate cannot model yields no quantity rather than a wrong one. - Honest about radio. Every telegram says what was verified: nothing, decrypted, or authenticated by CMAC or CCM tag. A CRC or a mode-5 decryption is not authentication: both can be forged or modified, and the tests show how.
- Never panics on input. Malformed, truncated and random bytes are errors. Fuzzed.
Try it
mbus decode takes one telegram per line, recognises wired and wireless frames and the
radio format (A, B, CRCs removed) by itself, learns record layouts from full frames to
expand later compact frames, and joins AFL fragments on consecutive lines. With --json,
every command writes one JSON object per telegram:
License
Licensed under either of Apache License, Version 2.0 or MIT license at your option.
Not affiliated with CEN, the OMS Group or any meter manufacturer.