pymbusparser 0.0.4__tar.gz → 0.1.2__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/.github/workflows/rust.yml +47 -12
  2. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/.gitignore +3 -0
  3. pymbusparser-0.1.2/CHANGELOG.md +29 -0
  4. pymbusparser-0.1.2/CONTRIBUTING.md +210 -0
  5. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/Cargo.lock +705 -280
  6. pymbusparser-0.1.2/Cargo.toml +79 -0
  7. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/PKG-INFO +1 -2
  8. pymbusparser-0.1.2/README.md +292 -0
  9. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/benches/bench.rs +10 -6
  10. pymbusparser-0.1.2/crates/m-bus-application-layer/Cargo.toml +25 -0
  11. {pymbusparser-0.0.4/src/user_data → pymbusparser-0.1.2/crates/m-bus-application-layer/src}/data_information.rs +279 -64
  12. {pymbusparser-0.0.4/src/user_data → pymbusparser-0.1.2/crates/m-bus-application-layer/src}/data_record.rs +80 -30
  13. pymbusparser-0.1.2/crates/m-bus-application-layer/src/extended_link_layer.rs +105 -0
  14. pymbusparser-0.1.2/crates/m-bus-application-layer/src/lib.rs +1562 -0
  15. {pymbusparser-0.0.4/src/user_data → pymbusparser-0.1.2/crates/m-bus-application-layer/src}/value_information.rs +926 -348
  16. pymbusparser-0.1.2/crates/m-bus-application-layer/src/variable_user_data.rs +278 -0
  17. pymbusparser-0.1.2/crates/m-bus-core/Cargo.toml +21 -0
  18. pymbusparser-0.1.2/crates/m-bus-core/src/decryption.rs +402 -0
  19. pymbusparser-0.1.2/crates/m-bus-core/src/lib.rs +738 -0
  20. pymbusparser-0.1.2/crates/wired-mbus-link-layer/Cargo.toml +18 -0
  21. pymbusparser-0.0.4/src/frames/mod.rs → pymbusparser-0.1.2/crates/wired-mbus-link-layer/src/lib.rs +20 -112
  22. pymbusparser-0.1.2/crates/wireless-mbus-link-layer/Cargo.toml +19 -0
  23. pymbusparser-0.1.2/crates/wireless-mbus-link-layer/src/lib.rs +190 -0
  24. pymbusparser-0.1.2/docs/index.html +1177 -0
  25. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/docs/m_bus_parser_wasm_pack.js +102 -47
  26. pymbusparser-0.1.2/docs/m_bus_parser_wasm_pack_bg.js +156 -0
  27. pymbusparser-0.1.2/docs/m_bus_parser_wasm_pack_bg.wasm +0 -0
  28. pymbusparser-0.1.2/docs/meter.png +0 -0
  29. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/docs/package.json +4 -3
  30. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/pyproject.toml +1 -1
  31. pymbusparser-0.1.2/python/.gitignore +1 -0
  32. pymbusparser-0.1.2/python/Cargo.toml +20 -0
  33. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/python/src/lib.rs +21 -4
  34. pymbusparser-0.1.2/src/annotate.rs +1761 -0
  35. pymbusparser-0.1.2/src/lib.rs +114 -0
  36. pymbusparser-0.1.2/src/manufacturers.rs +646 -0
  37. pymbusparser-0.1.2/src/mbus_data.rs +1789 -0
  38. pymbusparser-0.0.4/CONTRIBUTING.md +0 -50
  39. pymbusparser-0.0.4/Cargo.toml +0 -65
  40. pymbusparser-0.0.4/README.md +0 -100
  41. pymbusparser-0.0.4/docs/index.html +0 -136
  42. pymbusparser-0.0.4/docs/m_bus_parser_wasm_pack_bg.js +0 -118
  43. pymbusparser-0.0.4/docs/m_bus_parser_wasm_pack_bg.wasm +0 -0
  44. pymbusparser-0.0.4/docs/meter.png +0 -0
  45. pymbusparser-0.0.4/python/Cargo.toml +0 -15
  46. pymbusparser-0.0.4/src/lib.rs +0 -302
  47. pymbusparser-0.0.4/src/user_data/mod.rs +0 -961
  48. pymbusparser-0.0.4/src/user_data/variable_user_data.rs +0 -83
  49. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/.github/dependabot.yml +0 -0
  50. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/.github/workflows/python.yml +0 -0
  51. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/.vscode/launch.json +0 -0
  52. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/.vscode/settings.json +0 -0
  53. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/LICENSE +0 -0
  54. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/README_python.md +0 -0
  55. {pymbusparser-0.0.4/python → pymbusparser-0.1.2/crates/m-bus-application-layer}/.gitignore +0 -0
  56. {pymbusparser-0.0.4 → pymbusparser-0.1.2}/python/README_python.md +0 -0
@@ -14,7 +14,7 @@ on:
14
14
  jobs:
15
15
  build-library:
16
16
  runs-on: ubuntu-latest
17
- if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/cli-v')
17
+ if: github.event_name == 'push' && !startsWith(github.ref, 'refs/tags/cli-v') || github.event_name == 'pull_request'
18
18
  steps:
19
19
  - uses: actions/checkout@v2
20
20
  - name: Set up Rust
@@ -32,7 +32,9 @@ jobs:
32
32
  - name: Build Library
33
33
  run: cargo build --verbose
34
34
  - name: Run Library Tests
35
- run: cargo test --verbose
35
+ run: |
36
+ cargo test --verbose
37
+ cargo test --verbose -F std
36
38
  - name: Run Library Tests with plaintext before with enabled
37
39
  run: cargo test --verbose -F plaintext-before-extension
38
40
  - name: Lint with Clippy
@@ -42,6 +44,7 @@ jobs:
42
44
 
43
45
  build-cli:
44
46
  runs-on: ubuntu-latest
47
+ if: github.event_name == 'push' || github.event_name == 'pull_request'
45
48
  needs: build-library
46
49
  steps:
47
50
  - uses: actions/checkout@v2
@@ -51,22 +54,27 @@ jobs:
51
54
  profile: minimal
52
55
  toolchain: stable
53
56
  override: true
57
+ - name: Check CLI Formatting
58
+ run: |
59
+ cd cli
60
+ cargo fmt -- --check
54
61
  - name: Build CLI
55
62
  run: |
56
- cd cli/src
63
+ cd cli
57
64
  cargo build --verbose
58
65
  - name: Run CLI Tests
59
66
  run: |
60
- cd cli/src
67
+ cd cli
61
68
  cargo test --verbose
62
69
  - name: Lint CLI with Clippy
63
70
  run: |
64
71
  rustup component add clippy
65
- cd cli/src
72
+ cd cli
66
73
  cargo clippy -- -D warnings
67
74
 
68
75
  build-wasm:
69
76
  runs-on: ubuntu-latest
77
+ if: github.event_name == 'push' || github.event_name == 'pull_request'
70
78
  needs: build-library
71
79
  steps:
72
80
  - uses: actions/checkout@v2
@@ -76,21 +84,24 @@ jobs:
76
84
  profile: minimal
77
85
  toolchain: stable
78
86
  override: true
87
+ - name: Check WASM Formatting
88
+ run: |
89
+ cd wasm
90
+ cargo fmt -- --check
79
91
  - name: Build WASM
80
92
  run: |
81
93
  cd wasm
82
94
  cargo build --verbose
83
- - name: Run CLI Tests
95
+ - name: Run WASM Tests
84
96
  run: |
85
97
  cd wasm
86
98
  cargo test --verbose
87
- - name: Lint CLI with Clippy
99
+ - name: Lint WASM with Clippy
88
100
  run: |
89
101
  rustup component add clippy
90
102
  cd wasm
91
103
  cargo clippy -- -D warnings
92
104
 
93
-
94
105
  publish-library:
95
106
  needs: build-library
96
107
  runs-on: ubuntu-latest
@@ -123,17 +134,21 @@ jobs:
123
134
  override: true
124
135
  - name: Publish CLI to crates.io
125
136
  run: |
126
- cd cli/src
137
+ cd cli
127
138
  cargo publish --token ${{ secrets.CRATESTOKEN }}
139
+
128
140
  publish-wasm:
129
141
  needs: build-wasm
130
142
  runs-on: ubuntu-latest
131
143
  permissions:
132
144
  id-token: write
133
- contents: read
145
+ contents: write
134
146
  if: startsWith(github.ref, 'refs/tags/wasm-v')
135
147
  steps:
136
148
  - uses: actions/checkout@v4
149
+ with:
150
+ fetch-depth: 0
151
+ token: ${{ secrets.GITHUB_TOKEN }}
137
152
  - name: Set up Rust
138
153
  uses: actions-rs/toolchain@v1
139
154
  with:
@@ -157,8 +172,28 @@ jobs:
157
172
  npm install
158
173
  npm ci
159
174
  - name: Publish to npm
160
- run: |
175
+ run: |
161
176
  cd wasm/pkg
162
177
  npm publish --provenance --access public
163
178
  env:
164
- NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
179
+ NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
180
+ - name: Create new artifacts for website
181
+ run: |
182
+ rm -rf wasm/pkg
183
+ cd wasm
184
+ wasm-pack build --target web
185
+ - name: Copy wasm artifacts to docs
186
+ run: |
187
+ cp wasm/pkg/m_bus_parser_wasm_pack.js docs/
188
+ cp wasm/pkg/m_bus_parser_wasm_pack_bg.js docs/
189
+ cp wasm/pkg/m_bus_parser_wasm_pack_bg.wasm docs/
190
+ cp wasm/pkg/package.json docs/
191
+ - name: Commit updated wasm artifacts
192
+ env:
193
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
194
+ run: |
195
+ git config user.name "github-actions"
196
+ git config user.email "github-actions@github.com"
197
+ git add docs/m_bus_parser_wasm_pack.js docs/m_bus_parser_wasm_pack_bg.js docs/m_bus_parser_wasm_pack_bg.wasm docs/meter.png docs/package.json
198
+ git commit -m "Update docs wasm artifacts" || echo "No changes to commit"
199
+ git push origin HEAD:main
@@ -12,3 +12,6 @@ Cargo.lock
12
12
 
13
13
  # MSVC Windows builds of rustc generate these, which store debugging information
14
14
  *.pdb
15
+
16
+ # Mac
17
+ .DS_Store
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [0.1.2] - 2026-06-09
11
+
12
+ - Added support for CI 0x78 frames without a transport layer header.
13
+ - Improved WASM docs hex view alignment and ASCII column spacing.
14
+ - Deduplicated byte hover labels in the WASM docs hex view.
15
+ - Updated RustCrypto and serde XML dependencies.
16
+
17
+ ## [0.1.1] - 2026-05-14
18
+
19
+ - Added byte-level frame annotations and interactive hex view support for the WASM site.
20
+ - Added and corrected VIF/VIFE labels, units, extension handling, and special-function parsing.
21
+ - Improved LVAR text decoding with ISO/IEC 8859-1 handling.
22
+ - Added package metadata and versioned path dependencies for crate publishing.
23
+
24
+ ## [0.1.0]
25
+
26
+ - wmbus parsing capabilities
27
+ - preperation for decryption
28
+ - breaking changes to API for using the lib
29
+ - refacatoring things into core to be shared by wireless and wired parsing parts
@@ -0,0 +1,210 @@
1
+ # Contributing
2
+
3
+ Contributions are welcome and appreciated — whether it's a bug report, a new feature, a test frame, or a documentation fix. Don't hesitate to open an issue or ask questions.
4
+
5
+ ---
6
+
7
+ ## Table of Contents
8
+
9
+ - [Getting oriented](#getting-oriented)
10
+ - [Setting up](#setting-up)
11
+ - [Project structure](#project-structure)
12
+ - [Making changes](#making-changes)
13
+ - [Testing](#testing)
14
+ - [CI checks](#ci-checks)
15
+ - [Opening a pull request](#opening-a-pull-request)
16
+ - [Good first contributions](#good-first-contributions)
17
+ - [Releasing](#releasing)
18
+ - [Code of conduct](#code-of-conduct)
19
+
20
+ ---
21
+
22
+ ## Getting oriented
23
+
24
+ Before diving into the code, build some intuition for what the parser does:
25
+
26
+ 1. Open the [live parser](https://maebli.github.io/m-bus-parser/) in your browser.
27
+ 2. Go to `tests/rscada/test-frames/` in this repo and open any `.hex` file — for example:
28
+ ```
29
+ 68 3C 3C 68 08 08 72 78 03 49 11 77 04 0E 16 0A 00 00 00 0C 78 78 03 49 11
30
+ 04 13 31 D4 00 00 42 6C 00 00 44 13 00 00 00 00 04 6D 0B 0B CD 13 02 27 00
31
+ 00 09 FD 0E 02 09 FD 0F 06 0F 00 01 75 13 D3 16
32
+ ```
33
+ 3. Paste it into tmbus and explore the decoded output.
34
+ 4. Compare with what this parser produces:
35
+ ```bash
36
+ cargo run -p m-bus-parser-cli -- parse -d "68 3C 3C 68 ..." -t table
37
+ ```
38
+
39
+ The corresponding `.xml` file in the same folder shows the expected parsed values.
40
+
41
+ Useful background reading:
42
+ - [M-Bus application layer documentation](https://m-bus.com/documentation-wired/06-application-layer) — good starting point even though it's not the latest spec
43
+ - [OMS specification](https://oms-group.org/en/open-metering-system/oms-specification) — the current reference for wMBus
44
+
45
+ ---
46
+
47
+ ## Setting up
48
+
49
+ **Prerequisites:** Rust toolchain, git.
50
+
51
+ ```bash
52
+ # Install Rust if you don't have it
53
+ curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
54
+
55
+ # Clone the repo
56
+ git clone https://github.com/maebli/m-bus-parser.git
57
+ cd m-bus-parser
58
+
59
+ # Run all tests to confirm everything works
60
+ cargo test --all-features
61
+
62
+ # Build the CLI
63
+ cargo build -p m-bus-parser-cli
64
+
65
+ # Try parsing a frame
66
+ cargo run -p m-bus-parser-cli -- parse \
67
+ -d "68 3C 3C 68 08 08 72 78 03 49 11 77 04 0E 16 0A 00 00 00 0C 78 78 03 49 11 04 13 31 D4 00 00 42 6C 00 00 44 13 00 00 00 00 04 6D 0B 0B CD 13 02 27 00 00 09 FD 0E 02 09 FD 0F 06 0F 00 01 75 13 D3 16" \
68
+ -t table
69
+ ```
70
+
71
+ Optional — rebuild the WebAssembly package:
72
+ ```bash
73
+ cargo install wasm-pack
74
+ wasm-pack build wasm --target web --out-dir ../docs
75
+ ```
76
+
77
+ ---
78
+
79
+ ## Project structure
80
+
81
+ ```
82
+ m-bus-parser/
83
+ ├── src/ # Main library (serialize_mbus_data, output formats)
84
+ │ ├── mbus_data.rs # All output format functions (table, json, yaml, csv, mermaid)
85
+ │ └── manufacturers.rs # FLAG manufacturer code lookup (std-only)
86
+ ├── crates/
87
+ │ ├── m-bus-core/ # Shared types (ManufacturerCode, FrameError, …)
88
+ │ ├── m-bus-application-layer/# Application layer parsing (DIF/VIF, data records)
89
+ │ ├── wired-mbus-link-layer/ # Wired frame parsing (long/short/control frames)
90
+ │ └── wireless-mbus-link-layer/ # Wireless frame parsing + Format A CRC stripping
91
+ ├── cli/ # CLI binary (m-bus-parser-cli)
92
+ ├── wasm/ # WebAssembly bindings (wasm-bindgen)
93
+ ├── python/ # Python bindings (PyO3)
94
+ ├── docs/ # GitHub Pages web app + compiled WASM
95
+ ├── tests/
96
+ │ └── rscada/test-frames/ # Real-world .hex test frames + expected .xml output
97
+ └── examples/
98
+ └── cortex-m/ # Embedded no_std example
99
+ ```
100
+
101
+ The `src/` crate is the public API. It ties together the inner crates and provides the `serialize_mbus_data(data, format, key)` function used by the CLI, WASM, and Python bindings.
102
+
103
+ ---
104
+
105
+ ## Making changes
106
+
107
+ 1. **Create a branch** from `main`:
108
+ ```bash
109
+ git checkout -b fix/your-fix
110
+ # or
111
+ git checkout -b feature/your-feature
112
+ ```
113
+
114
+ 2. **Make your changes.** Some common areas:
115
+ - Adding a missing VIF/DIF code → `crates/m-bus-application-layer/`
116
+ - Fixing a parsing bug → relevant inner crate
117
+ - Adding a manufacturer → `src/manufacturers.rs` (add a new `match` arm)
118
+ - Improving an output format → `src/mbus_data.rs`
119
+ - Adding a CI field type → `crates/m-bus-application-layer/`
120
+
121
+ 3. **Add a test** if applicable. For a new device frame, add a `.hex` file to `tests/rscada/test-frames/` and a corresponding test.
122
+
123
+ ---
124
+
125
+ ## Testing
126
+
127
+ ```bash
128
+ # Run all tests
129
+ cargo test --all-features
130
+
131
+ # Run tests for a specific crate
132
+ cargo test -p m-bus-application-layer
133
+
134
+ # Run a specific test by name
135
+ cargo test test_mermaid_expected_output
136
+ ```
137
+
138
+ Test frames in `tests/rscada/test-frames/` are real-world captures from devices. The `.hex` file is the raw frame; the `.xml` file is the expected parsed output.
139
+
140
+ ---
141
+
142
+ ## CI checks
143
+
144
+ The CI pipeline runs these checks — make sure they all pass before opening a PR:
145
+
146
+ ```bash
147
+ # Formatting
148
+ cargo fmt --check
149
+
150
+ # Lints (zero warnings policy)
151
+ cargo clippy --all-targets --all-features -- -D warnings
152
+
153
+ # Tests
154
+ cargo test --all-features
155
+
156
+ # no_std build (embedded target)
157
+ cargo build --target thumbv7m-none-eabi --no-default-features
158
+ ```
159
+
160
+ To auto-fix formatting and simple clippy suggestions:
161
+ ```bash
162
+ cargo fmt
163
+ cargo clippy --fix --all-features
164
+ ```
165
+
166
+ ---
167
+
168
+ ## Opening a pull request
169
+
170
+ 1. Push your branch and open a PR against `main`
171
+ 2. Fill in the PR description — what changed and why
172
+ 3. Make sure CI is green
173
+ 4. A maintainer will review and merge
174
+
175
+ Commit message convention (loosely followed):
176
+ ```
177
+ feat: add VIF code 0x3E
178
+ fix: handle missing CRC in Format A frames
179
+ docs: improve contributing guide
180
+ ```
181
+
182
+ ---
183
+
184
+ ## Good first contributions
185
+
186
+ - **Add a missing manufacturer** — check `src/manufacturers.rs`. If you encounter a 3-letter code that returns `None`, look it up in the [DLMS FLAG ID directory](https://www.dlms.com/flag-id-directory/) and add it.
187
+ - **Add a test frame** — capture a real device frame, add it to `tests/rscada/test-frames/` with the expected output, and wire it into the test suite.
188
+ - **Implement a missing CI type** — the list of unimplemented CI fields is in the README. Pick one and implement it in `crates/m-bus-application-layer/`.
189
+ - **Improve error messages** — many parse errors are just `Unimplemented`; a more descriptive message helps users.
190
+
191
+ ---
192
+
193
+ ## Releasing
194
+
195
+ Releases bump the version in all four crates:
196
+
197
+ ```bash
198
+ cargo release version patch --execute
199
+ cd python && cargo release version patch --execute && cd ..
200
+ cd wasm && cargo release version patch --execute && cd ..
201
+ cd cli && cargo release version patch --execute && cd ..
202
+ ```
203
+
204
+ Then push the tags and let CI publish to crates.io / npm / PyPI.
205
+
206
+ ---
207
+
208
+ ## Code of conduct
209
+
210
+ This project follows the [Rust Code of Conduct](https://www.rust-lang.org/policies/code-of-conduct). Be kind and constructive.