Unify header information across all output formats - #106
Merged
Conversation
All output formats (table, csv, json, yaml) previously extracted frame and header information independently, each with its own copy of the parse-and-decrypt logic. The copies had drifted apart: wireless frames with a short TPL header (the common wM-Bus case) produced empty header columns in CSV even though the table showed the link-layer address, manufacturer, access number, status and security mode, and the JSON and YAML outputs exposed only raw internals with no decoded security mode or readable header fields. Replace the per-format duplication with a single parse path that builds a normalized FrameSummary (frame type, function, address, identification number, manufacturer with name lookup, access number, status, security mode, version, device type, encryption state and data records). Header fields resolve from the long TPL header, then the short TPL header, then the wireless link layer. - table and csv now render from the shared summary, so they can no longer disagree; csv gains the previously missing wireless header fields, a Manufacturer Name column and a unified column set for all frame types - json and yaml keep their full structured dump for backwards compatibility and gain an embedded summary section with the decoded, human-readable header and record values - encrypted frames without a key now consistently report the encrypted payload instead of emitting garbage records in csv - decryption logic is shared with the hexview path instead of being repeated five times All deployments (cli, wasm, python) route through serialize_mbus_data and pick this up without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Each output format (
table,csv,json,yaml) re-implemented frame parsing, decryption and field extraction independently (~1,100 duplicated lines inmbus_data.rs), and the copies had drifted apart:configuration_field: raw: 9504,manufacturer_code: code: ['E','L','S'],status: '') with no decoded security mode or readable header fields.Fix
One shared parse-and-decrypt path now builds a normalized
FrameSummary(frame type, function, address, identification number, manufacturer incl. name lookup, access number, status, security mode, version, device type, encryption state, records). Header fields resolve long TPL header → short TPL header → wireless link layer.Manufacturer Namecolumn and one unified column set for all frame types.summarysection with the decoded header and record values:encrypted_payload_hexinstead of garbage records.Since CLI, wasm and Python all route through
serialize_mbus_data, every deployment picks this up without changes.Behavioral changes
Manufacturer Namecolumn; wireless rows now share the wired column set (Function/Addresscolumns,Addressempty for wireless); wireless header fields are filled.Is globally Unique Idrow dropped;FunctionusesDisplayinstead ofDebug(SndNkinstead ofSndNk { prm: false }); identification numbers render as digits instead ofIdentificationNumber { number: … }.summarykey;manufacturer_infonow also appears for wired frames when the code resolves via the short-TPL/link-layer path.Possible follow-ups (not in this PR)
manufacturer_infokey in JSON/YAML in favor ofsummary.manufacturer(kept for now for compatibility).summary.records[].valueinto structuredvalue/exponent/unit/quantityfields instead of the table-style string, once the display format is settled.frame.databyte arrays as hex strings in the raw dump (breaking change for JSON consumers).Testing
cargo test --features std,decryptionand--features std— all green (34 tests, incl. 6 new: wireless CSV header fields, encrypted-without-key CSV, decrypted CSV records,summarypresence in JSON/YAML, and a cross-format agreement test that asserts every header value appears in all four formats for wired, short-TPL wireless and no-TPL wireless frames).cargo check --workspace(cli, wasm, python), no-default-features build, clippy and fmt clean.