pymbusparser 0.7.0__tar.gz → 0.7.4__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 (100) hide show
  1. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/dependabot.yml +3 -0
  2. pymbusparser-0.7.4/.github/workflows/c.yml +75 -0
  3. pymbusparser-0.7.4/.github/workflows/java.yml +68 -0
  4. pymbusparser-0.7.4/.github/workflows/mutation-testing.yml +47 -0
  5. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/workflows/rust.yml +2 -0
  6. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/Cargo.lock +29 -14
  7. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/Cargo.toml +5 -5
  8. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/PKG-INFO +1 -1
  9. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/Cargo.toml +3 -3
  10. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/application_message.rs +3 -0
  11. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/data_information.rs +21 -0
  12. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/lib.rs +93 -5
  13. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/value_information.rs +35 -0
  14. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/tests/application_messages.rs +41 -1
  15. pymbusparser-0.7.4/crates/m-bus-application-layer/tests/application_reset.rs +34 -0
  16. pymbusparser-0.7.4/crates/m-bus-application-layer/tests/record_decoding.rs +34 -0
  17. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/Cargo.toml +2 -2
  18. pymbusparser-0.7.4/crates/m-bus-core/src/authentication.rs +108 -0
  19. pymbusparser-0.7.4/crates/m-bus-core/src/decryption/mode7.rs +145 -0
  20. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/src/decryption.rs +35 -28
  21. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/src/lib.rs +1 -0
  22. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/wired-mbus-link-layer/Cargo.toml +2 -2
  23. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/wired-mbus-link-layer/src/lib.rs +16 -1
  24. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/wireless-mbus-link-layer/Cargo.toml +2 -2
  25. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/index.html +840 -139
  26. pymbusparser-0.7.4/docs/input-format.js +23 -0
  27. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/m_bus_parser_wasm_pack.js +13 -0
  28. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/m_bus_parser_wasm_pack_bg.wasm +0 -0
  29. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/tls-session.js +14 -1
  30. pymbusparser-0.7.4/java/build-native.py +52 -0
  31. pymbusparser-0.7.4/java/pom.xml +148 -0
  32. pymbusparser-0.7.4/java/src/main/java/io/github/maebli/mbus/MbusException.java +15 -0
  33. pymbusparser-0.7.4/java/src/main/java/io/github/maebli/mbus/MbusParser.java +144 -0
  34. pymbusparser-0.7.4/java/src/main/java/io/github/maebli/mbus/NativeLibrary.java +55 -0
  35. pymbusparser-0.7.4/java/src/main/java/io/github/maebli/mbus/OutputFormat.java +15 -0
  36. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/python/Cargo.toml +2 -2
  37. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/annotate.rs +30 -0
  38. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/output.rs +17 -1
  39. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/ISSUE_TEMPLATE/manufacturer-parser.yml +0 -0
  40. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/scripts/render-bench-page.py +0 -0
  41. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/scripts/restore-benchmark-history.sh +0 -0
  42. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/scripts/test-bench-charts.cjs +0 -0
  43. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/workflows/parser-resources.yml +0 -0
  44. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.github/workflows/python.yml +0 -0
  45. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.gitignore +0 -0
  46. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.vscode/launch.json +0 -0
  47. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/.vscode/settings.json +0 -0
  48. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/CHANGELOG.md +0 -0
  49. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/CONTRIBUTING.md +0 -0
  50. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/LICENSE +0 -0
  51. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/README.md +0 -0
  52. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/README_python.md +0 -0
  53. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/README.md +0 -0
  54. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/bench.rs +0 -0
  55. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/corpus.rs +0 -0
  56. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/full_decode.rs +0 -0
  57. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/full_parse_fixture.rs +0 -0
  58. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/instructions.py +0 -0
  59. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/measure-corpus.py +0 -0
  60. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/test_instructions.py +0 -0
  61. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/benches/test_measure_corpus.py +0 -0
  62. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/.gitignore +0 -0
  63. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/README.md +0 -0
  64. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/examples/parse_data_records.rs +0 -0
  65. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/compact.rs +0 -0
  66. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/data_record.rs +0 -0
  67. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/extended_link_layer.rs +0 -0
  68. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/src/variable_user_data.rs +0 -0
  69. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/tests/compact.rs +0 -0
  70. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/tests/ell_iii.rs +0 -0
  71. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/tests/select_slave.rs +0 -0
  72. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/tests/send_data.rs +0 -0
  73. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-application-layer/tests/value_information_serialization.rs +0 -0
  74. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/src/decryption/mode10.rs +0 -0
  75. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/src/decryption/mode13.rs +0 -0
  76. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/src/hex.rs +0 -0
  77. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/tests/fixtures/mode13.rs +0 -0
  78. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/tests/mode10.rs +0 -0
  79. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/m-bus-core/tests/mode13.rs +0 -0
  80. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/crates/wireless-mbus-link-layer/src/lib.rs +0 -0
  81. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/dev/bench/data.js +0 -0
  82. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/dev/bench/index.html +0 -0
  83. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/emeter.png +0 -0
  84. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/m_bus_parser_wasm_pack_bg.js +0 -0
  85. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/docs/meter.png +0 -0
  86. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/pyproject.toml +0 -0
  87. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/python/.gitignore +0 -0
  88. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/python/README_python.md +0 -0
  89. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/python/py.typed +0 -0
  90. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/python/pymbusparser.pyi +0 -0
  91. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/python/src/lib.rs +0 -0
  92. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/python/tests/test_bindings.py +0 -0
  93. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/lib.rs +0 -0
  94. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/manufacturers.rs +0 -0
  95. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/mbus_data.rs +0 -0
  96. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/output/application.rs +0 -0
  97. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/output/messages.rs +0 -0
  98. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/output/tls.rs +0 -0
  99. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/output/tls_session.rs +0 -0
  100. {pymbusparser-0.7.0 → pymbusparser-0.7.4}/src/rscada_xml.rs +0 -0
@@ -13,3 +13,6 @@ updates:
13
13
  directory: "/" # Location of package manifests
14
14
  schedule:
15
15
  interval: "weekly"
16
+ ignore:
17
+ - dependency-name: "bincode"
18
+ update-types: ["version-update:semver-major"]
@@ -0,0 +1,75 @@
1
+ name: C bindings
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ['c-v*']
7
+ paths: ['c/**', 'src/**', 'crates/**', 'Cargo.toml', 'Cargo.lock', '.github/workflows/c.yml']
8
+ pull_request:
9
+ branches: [main]
10
+ paths: ['c/**', 'src/**', 'crates/**', 'Cargo.toml', 'Cargo.lock', '.github/workflows/c.yml']
11
+ workflow_dispatch:
12
+
13
+ permissions:
14
+ contents: read
15
+
16
+ jobs:
17
+ build:
18
+ strategy:
19
+ fail-fast: false
20
+ matrix:
21
+ include:
22
+ - runner: ubuntu-24.04
23
+ target: x86_64-unknown-linux-gnu
24
+ - runner: ubuntu-24.04-arm
25
+ target: aarch64-unknown-linux-gnu
26
+ - runner: macos-15-intel
27
+ target: x86_64-apple-darwin
28
+ - runner: macos-26
29
+ target: aarch64-apple-darwin
30
+ - runner: windows-2025
31
+ target: x86_64-pc-windows-msvc
32
+ runs-on: ${{ matrix.runner }}
33
+ steps:
34
+ - uses: actions/checkout@v7
35
+ - uses: dtolnay/rust-toolchain@stable
36
+ with:
37
+ targets: ${{ matrix.target }}
38
+ components: rustfmt, clippy
39
+ - uses: actions/setup-python@v7
40
+ with:
41
+ python-version: '3.12'
42
+ - run: cargo fmt -p m-bus-parser-c -- --check
43
+ - run: cargo clippy -p m-bus-parser-c --no-deps -- -D warnings
44
+ - run: cargo build --locked -p m-bus-parser-c --release --target ${{ matrix.target }}
45
+ - name: Compile the C example and package libraries
46
+ run: python c/package.py --target ${{ matrix.target }}
47
+ - uses: actions/upload-artifact@v7
48
+ with:
49
+ name: c-${{ matrix.target }}
50
+ path: target/c-dist/*
51
+ if-no-files-found: error
52
+
53
+ publish:
54
+ if: startsWith(github.ref, 'refs/tags/c-v')
55
+ needs: build
56
+ runs-on: ubuntu-24.04
57
+ permissions:
58
+ contents: write
59
+ steps:
60
+ - uses: actions/download-artifact@v8
61
+ with:
62
+ pattern: c-*
63
+ merge-multiple: true
64
+ path: dist
65
+ - name: Publish native libraries
66
+ env:
67
+ GH_TOKEN: ${{ github.token }}
68
+ GH_REPO: ${{ github.repository }}
69
+ RELEASE_TAG: ${{ github.ref_name }}
70
+ run: |
71
+ if gh release view "$RELEASE_TAG" >/dev/null 2>&1; then
72
+ gh release upload "$RELEASE_TAG" dist/*
73
+ else
74
+ gh release create "$RELEASE_TAG" dist/* --verify-tag --title "C bindings $RELEASE_TAG" --notes "C shared and static libraries, public header, and runnable example. Each archive includes a SHA-256 checksum file."
75
+ fi
@@ -0,0 +1,68 @@
1
+ name: Java bindings
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ tags: ['java-v*']
7
+ paths: ['java/**', 'c/**', 'src/**', 'crates/**', 'Cargo.toml', 'Cargo.lock', '.github/workflows/java.yml']
8
+ pull_request:
9
+ paths: ['java/**', 'c/**', 'src/**', 'crates/**', 'Cargo.toml', 'Cargo.lock', '.github/workflows/java.yml']
10
+ workflow_dispatch:
11
+
12
+ permissions:
13
+ contents: read
14
+
15
+ jobs:
16
+ build:
17
+ strategy:
18
+ fail-fast: false
19
+ matrix:
20
+ runner: [ubuntu-24.04, ubuntu-24.04-arm, macos-15-intel, macos-26, windows-2025]
21
+ runs-on: ${{ matrix.runner }}
22
+ steps:
23
+ - uses: actions/checkout@v7
24
+ - uses: dtolnay/rust-toolchain@stable
25
+ - uses: actions/setup-java@v6
26
+ with:
27
+ distribution: temurin
28
+ java-version: '25'
29
+ - uses: actions/setup-python@v7
30
+ with:
31
+ python-version: '3.12'
32
+ - name: Build binding and run the packaged example
33
+ run: mvn --batch-mode --no-transfer-progress -f java/pom.xml verify
34
+ - uses: actions/upload-artifact@v7
35
+ with:
36
+ name: java-native-${{ matrix.runner }}
37
+ path: java/target/native-resources/
38
+ if-no-files-found: error
39
+
40
+ publish:
41
+ if: startsWith(github.ref, 'refs/tags/java-v')
42
+ needs: build
43
+ runs-on: ubuntu-24.04
44
+ environment: maven-central
45
+ steps:
46
+ - uses: actions/checkout@v7
47
+ - uses: actions/setup-java@v6
48
+ with:
49
+ distribution: temurin
50
+ java-version: '25'
51
+ server-id: central
52
+ server-username: MAVEN_CENTRAL_USERNAME
53
+ server-password: MAVEN_CENTRAL_PASSWORD
54
+ - uses: actions/setup-python@v7
55
+ with:
56
+ python-version: '3.12'
57
+ - uses: actions/download-artifact@v8
58
+ with:
59
+ pattern: java-native-*
60
+ merge-multiple: true
61
+ path: java/target/native-resources
62
+ - name: Publish signed Java and native artifacts to Maven Central
63
+ env:
64
+ MAVEN_CENTRAL_USERNAME: ${{ secrets.MAVEN_CENTRAL_USERNAME }}
65
+ MAVEN_CENTRAL_PASSWORD: ${{ secrets.MAVEN_CENTRAL_PASSWORD }}
66
+ MAVEN_GPG_KEY: ${{ secrets.MAVEN_GPG_PRIVATE_KEY }}
67
+ MAVEN_GPG_PASSPHRASE: ${{ secrets.MAVEN_GPG_PASSPHRASE }}
68
+ run: mvn --batch-mode --no-transfer-progress -f java/pom.xml -Prelease -Dnative.prebuilt=true deploy
@@ -0,0 +1,47 @@
1
+ name: Mutation testing
2
+
3
+ on:
4
+ pull_request:
5
+ branches: [main]
6
+ paths:
7
+ - '**/*.rs'
8
+ - '.github/workflows/mutation-testing.yml'
9
+
10
+ permissions:
11
+ contents: read
12
+
13
+ concurrency:
14
+ group: mutation-testing-${{ github.event.pull_request.number }}
15
+ cancel-in-progress: true
16
+
17
+ jobs:
18
+ mutants:
19
+ runs-on: ubuntu-24.04
20
+ timeout-minutes: 60
21
+ steps:
22
+ - uses: actions/checkout@v7
23
+ with:
24
+ fetch-depth: 2
25
+ persist-credentials: false
26
+
27
+ - name: Get changed Rust lines from the pull request
28
+ run: git diff HEAD^1 HEAD -- '*.rs' > "$RUNNER_TEMP/changes.diff"
29
+
30
+ - name: Install cargo-mutants
31
+ uses: taiki-e/install-action@75a7c0f87bd666af3cdb75c5b9e9d03ab6044e6f
32
+ with:
33
+ tool: cargo-mutants@27.1.0
34
+
35
+ - name: Test mutations on changed lines
36
+ run: >-
37
+ cargo mutants --workspace --cargo-arg=--workspace --cargo-arg=--locked
38
+ --features m-bus-parser/std,m-bus-parser/decryption
39
+ --in-diff "$RUNNER_TEMP/changes.diff"
40
+
41
+ - name: Upload mutation results
42
+ if: ${{ !cancelled() }}
43
+ uses: actions/upload-artifact@v7
44
+ with:
45
+ name: mutation-results
46
+ path: mutants.out/
47
+ if-no-files-found: ignore
@@ -118,6 +118,8 @@ jobs:
118
118
  run: |
119
119
  cd wasm
120
120
  wasm-pack test --headless --firefox
121
+ - name: Test Mode 7 WebAssembly bindings
122
+ run: wasm-pack test --node wasm --test mode7
121
123
  - name: Lint WASM with Clippy
122
124
  run: |
123
125
  rustup component add clippy
@@ -20,9 +20,9 @@ dependencies = [
20
20
 
21
21
  [[package]]
22
22
  name = "aes"
23
- version = "0.9.3"
23
+ version = "0.9.4"
24
24
  source = "registry+https://github.com/rust-lang/crates.io-index"
25
- checksum = "35f0f96ce78e38c3dc6d8948aa8163d06385be74000f3c7a95bf1eef35d3ea32"
25
+ checksum = "fc0fc36d7440d015b45468ba08a21e80e056ebbd014c611c6298bb7503e04bd1"
26
26
  dependencies = [
27
27
  "cipher",
28
28
  "cpubits",
@@ -125,6 +125,12 @@ version = "1.4.0"
125
125
  source = "registry+https://github.com/rust-lang/crates.io-index"
126
126
  checksum = "ace50bade8e6234aa140d9a2f552bbee1db4d353f69b8217bc503490fc1a9f26"
127
127
 
128
+ [[package]]
129
+ name = "base64"
130
+ version = "0.23.1"
131
+ source = "registry+https://github.com/rust-lang/crates.io-index"
132
+ checksum = "ac07cdecf99051d9a5238b80f35af32cdeba5b336e55d957b318b50137e18da5"
133
+
128
134
  [[package]]
129
135
  name = "bincode"
130
136
  version = "1.3.3"
@@ -829,7 +835,7 @@ checksum = "04cbf5b083de1c7e0222a7a51dbfdba1cbe1c6ab0b15e29fff3f6c077fd9cd9f"
829
835
 
830
836
  [[package]]
831
837
  name = "m-bus-application-layer"
832
- version = "0.7.0"
838
+ version = "0.7.4"
833
839
  dependencies = [
834
840
  "bincode",
835
841
  "bitflags 2.13.2",
@@ -840,7 +846,7 @@ dependencies = [
840
846
 
841
847
  [[package]]
842
848
  name = "m-bus-core"
843
- version = "0.7.0"
849
+ version = "0.7.4"
844
850
  dependencies = [
845
851
  "aes",
846
852
  "aes-gcm",
@@ -854,7 +860,7 @@ dependencies = [
854
860
 
855
861
  [[package]]
856
862
  name = "m-bus-manufacturer"
857
- version = "0.7.0"
863
+ version = "0.7.4"
858
864
  dependencies = [
859
865
  "m-bus-application-layer",
860
866
  "m-bus-core",
@@ -862,7 +868,7 @@ dependencies = [
862
868
 
863
869
  [[package]]
864
870
  name = "m-bus-parser"
865
- version = "0.7.0"
871
+ version = "0.7.4"
866
872
  dependencies = [
867
873
  "bindgen",
868
874
  "bitflags 2.13.2",
@@ -877,17 +883,26 @@ dependencies = [
877
883
  "serde_derive",
878
884
  "serde_json",
879
885
  "serde_norway",
880
- "unicode-width 0.2.2",
886
+ "unicode-width 0.2.3",
881
887
  "walkdir",
882
888
  "wired-mbus-link-layer",
883
889
  "wireless-mbus-link-layer",
884
890
  "zeroize",
885
891
  ]
886
892
 
893
+ [[package]]
894
+ name = "m-bus-parser-c"
895
+ version = "0.7.4"
896
+ dependencies = [
897
+ "m-bus-parser",
898
+ "serde_json",
899
+ ]
900
+
887
901
  [[package]]
888
902
  name = "m-bus-parser-cli"
889
- version = "0.7.0"
903
+ version = "0.7.4"
890
904
  dependencies = [
905
+ "base64",
891
906
  "clap",
892
907
  "hex",
893
908
  "m-bus-parser",
@@ -896,7 +911,7 @@ dependencies = [
896
911
 
897
912
  [[package]]
898
913
  name = "m-bus-parser-wasm-pack"
899
- version = "0.7.0"
914
+ version = "0.7.4"
900
915
  dependencies = [
901
916
  "console_error_panic_hook",
902
917
  "js-sys",
@@ -1063,7 +1078,7 @@ dependencies = [
1063
1078
 
1064
1079
  [[package]]
1065
1080
  name = "pymbusparser"
1066
- version = "0.7.0"
1081
+ version = "0.7.4"
1067
1082
  dependencies = [
1068
1083
  "hex",
1069
1084
  "m-bus-parser",
@@ -1477,9 +1492,9 @@ checksum = "7dd6e30e90baa6f72411720665d41d89b9a3d039dc45b8faea1ddd07f617f6af"
1477
1492
 
1478
1493
  [[package]]
1479
1494
  name = "unicode-width"
1480
- version = "0.2.2"
1495
+ version = "0.2.3"
1481
1496
  source = "registry+https://github.com/rust-lang/crates.io-index"
1482
- checksum = "b4ac048d71ede7ee76d585517add45da530660ef4390e49b098733c6e897f254"
1497
+ checksum = "ca718471876992059f251e33aafc334346ada08042b7661dd1fe313a9bced557"
1483
1498
 
1484
1499
  [[package]]
1485
1500
  name = "universal-hash"
@@ -1717,7 +1732,7 @@ checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
1717
1732
 
1718
1733
  [[package]]
1719
1734
  name = "wired-mbus-link-layer"
1720
- version = "0.7.0"
1735
+ version = "0.7.4"
1721
1736
  dependencies = [
1722
1737
  "defmt",
1723
1738
  "m-bus-core",
@@ -1726,7 +1741,7 @@ dependencies = [
1726
1741
 
1727
1742
  [[package]]
1728
1743
  name = "wireless-mbus-link-layer"
1729
- version = "0.7.0"
1744
+ version = "0.7.4"
1730
1745
  dependencies = [
1731
1746
  "crc16",
1732
1747
  "defmt",
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "m-bus-parser"
3
- version = "0.7.0"
3
+ version = "0.7.4"
4
4
  edition = "2021"
5
5
  description = "A library for parsing M-Bus frames"
6
6
  license = "MIT"
@@ -54,10 +54,10 @@ serde = { version = "1.0", features = ["derive"], optional = true }
54
54
  unicode-width = { version = "0.2", optional = true }
55
55
  bitflags = "2.8.0"
56
56
  defmt = { version = "1.0.1", optional = true }
57
- wired-mbus-link-layer = { version = "0.7.0", path = "crates/wired-mbus-link-layer" }
58
- wireless-mbus-link-layer = { version = "0.7.0", path = "crates/wireless-mbus-link-layer" }
59
- m-bus-core = { version = "0.7.0", path = "crates/m-bus-core" }
60
- m-bus-application-layer = { version = "0.7.0", path = "crates/m-bus-application-layer" }
57
+ wired-mbus-link-layer = { version = "0.7.4", path = "crates/wired-mbus-link-layer" }
58
+ wireless-mbus-link-layer = { version = "0.7.4", path = "crates/wireless-mbus-link-layer" }
59
+ m-bus-core = { version = "0.7.4", path = "crates/m-bus-core" }
60
+ m-bus-application-layer = { version = "0.7.4", path = "crates/m-bus-application-layer" }
61
61
 
62
62
  [workspace]
63
63
  members = ["python", "crates/m-bus-application-layer", "crates/wired-mbus-link-layer", "crates/wireless-mbus-link-layer", "crates/m-bus-core"]
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: pymbusparser
3
- Version: 0.7.0
3
+ Version: 0.7.4
4
4
  Classifier: Development Status :: 4 - Beta
5
5
  Classifier: Programming Language :: Python :: 3
6
6
  Classifier: Programming Language :: Rust
@@ -1,6 +1,6 @@
1
1
  [package]
2
2
  name = "m-bus-application-layer"
3
- version = "0.7.0"
3
+ version = "0.7.4"
4
4
  edition = "2021"
5
5
  description = "M-Bus application layer parser (DIF/VIF, data records)"
6
6
  license = "MIT"
@@ -24,7 +24,7 @@ plaintext-before-extension = []
24
24
  serde = { version = "1.0", features = ["derive"], optional = true }
25
25
  defmt = { version = "1.0.1", optional = true }
26
26
  bitflags = "2.8.0"
27
- m-bus-core = { version = "0.7.0", path = "../m-bus-core" }
27
+ m-bus-core = { version = "0.7.4", path = "../m-bus-core" }
28
28
 
29
29
  [dev-dependencies]
30
- bincode = "1.3.3"
30
+ bincode = "=1.3.3"
@@ -124,6 +124,8 @@ pub struct ApplicationMessage<'a> {
124
124
  pub protocol: ApplicationProtocol,
125
125
  pub transport_header: TransportHeader,
126
126
  pub extended_link_layer: Option<crate::extended_link_layer::ExtendedLinkLayer>,
127
+ #[cfg_attr(feature = "serde", serde(borrow, skip_serializing))]
128
+ pub authentication: Option<&'a [u8]>,
127
129
  pub payload: &'a [u8],
128
130
  }
129
131
 
@@ -243,6 +245,7 @@ impl<'a> ApplicationMessage<'a> {
243
245
  protocol,
244
246
  transport_header,
245
247
  extended_link_layer: None,
248
+ authentication: None,
246
249
  payload: data
247
250
  .get(1 + header_size..)
248
251
  .ok_or(ApplicationLayerError::InsufficientData)?,
@@ -638,6 +638,14 @@ fn bcd_to_value_floating(
638
638
  }
639
639
 
640
640
  fn integer_to_value_internal(data: &[u8], byte_size: usize) -> Data<'_> {
641
+ let is_empty_integer = byte_size == 0;
642
+ if is_empty_integer {
643
+ return Data {
644
+ value: Some(DataType::Number(0.0)),
645
+ size: 0,
646
+ };
647
+ }
648
+
641
649
  let mut data_value = 0i64;
642
650
  let mut shift = 0;
643
651
  for byte in data.iter().take(if byte_size > 8 { 8 } else { byte_size }) {
@@ -1539,4 +1547,17 @@ mod tests {
1539
1547
  }
1540
1548
  );
1541
1549
  }
1550
+
1551
+ #[test]
1552
+ fn test_variable_length_zero_byte_integer_is_zero() {
1553
+ let lvar_integer_with_zero_bytes = [0xE0];
1554
+ let result = DataFieldCoding::VariableLength.parse(&lvar_integer_with_zero_bytes, None);
1555
+ assert_eq!(
1556
+ result,
1557
+ Ok(Data {
1558
+ value: Some(DataType::Number(0.0)),
1559
+ size: 1
1560
+ })
1561
+ );
1562
+ }
1542
1563
  }
@@ -52,6 +52,7 @@ pub use application_message::{
52
52
  ApplicationMessage, ApplicationPayload, ApplicationProtocol, TransportHeader,
53
53
  };
54
54
  use extended_link_layer::ExtendedLinkLayer;
55
+ use m_bus_core::authentication::AuthenticationHeader;
55
56
 
56
57
  /// Parses an application-layer user data block beginning with a CI field.
57
58
  pub fn parse_application_layer(data: &[u8]) -> Result<UserDataBlock<'_>, ApplicationLayerError> {
@@ -482,8 +483,7 @@ impl fmt::Display for ApplicationResetSubcode {
482
483
  impl ApplicationResetSubcode {
483
484
  #[must_use]
484
485
  pub const fn from(value: u8) -> Self {
485
- match value & 0b1111 {
486
- // Extracting the lower 4 bits
486
+ match value >> 4 {
487
487
  0b0000 => Self::All(value),
488
488
  0b0001 => Self::UserData(value),
489
489
  0b0010 => Self::SimpleBilling(value),
@@ -566,6 +566,8 @@ pub enum UserDataBlock<'a> {
566
566
  },
567
567
  VariableDataStructureWithLongTplHeader {
568
568
  extended_link_layer: Option<ExtendedLinkLayer>,
569
+ #[cfg_attr(feature = "serde", serde(borrow, skip_serializing))]
570
+ authentication: Option<&'a [u8]>,
569
571
  long_tpl_header: LongTplHeader,
570
572
  #[cfg_attr(feature = "serde", serde(skip_serializing))]
571
573
  variable_data_block: &'a [u8],
@@ -573,6 +575,8 @@ pub enum UserDataBlock<'a> {
573
575
 
574
576
  VariableDataStructureWithShortTplHeader {
575
577
  extended_link_layer: Option<ExtendedLinkLayer>,
578
+ #[cfg_attr(feature = "serde", serde(borrow, skip_serializing))]
579
+ authentication: Option<&'a [u8]>,
576
580
  short_tpl_header: ShortTplHeader,
577
581
  #[cfg_attr(feature = "serde", serde(skip_serializing))]
578
582
  variable_data_block: &'a [u8],
@@ -590,6 +594,52 @@ pub enum UserDataBlock<'a> {
590
594
  }
591
595
 
592
596
  impl<'a> UserDataBlock<'a> {
597
+ #[inline(never)]
598
+ fn parse_authenticated(data: &'a [u8]) -> Result<Self, ApplicationLayerError> {
599
+ let authentication = AuthenticationHeader::parse(data)?;
600
+ let mut block = Self::try_from(authentication.transport)?;
601
+ if !block.transport_payload().is_some_and(|(header, _)| {
602
+ header.configuration_field.security_mode() == m_bus_core::SecurityMode::AesCbc128IvZero
603
+ }) {
604
+ return Err(ApplicationLayerError::InvalidPayload {
605
+ field: "authenticated security mode",
606
+ });
607
+ }
608
+ match &mut block {
609
+ Self::VariableDataStructureWithLongTplHeader {
610
+ authentication: target,
611
+ ..
612
+ }
613
+ | Self::VariableDataStructureWithShortTplHeader {
614
+ authentication: target,
615
+ ..
616
+ } => *target = Some(data),
617
+ Self::ApplicationMessage(message)
618
+ if message.transport_header.short_header().is_some() =>
619
+ {
620
+ message.authentication = Some(data);
621
+ }
622
+ _ => {
623
+ return Err(ApplicationLayerError::InvalidPayload {
624
+ field: "authenticated transport",
625
+ })
626
+ }
627
+ }
628
+ Ok(block)
629
+ }
630
+
631
+ pub fn authentication(&self) -> Option<AuthenticationHeader<'a>> {
632
+ let data = match self {
633
+ Self::VariableDataStructureWithLongTplHeader { authentication, .. }
634
+ | Self::VariableDataStructureWithShortTplHeader { authentication, .. } => {
635
+ *authentication
636
+ }
637
+ Self::ApplicationMessage(message) => message.authentication,
638
+ _ => None,
639
+ }?;
640
+ AuthenticationHeader::parse(data).ok()
641
+ }
642
+
593
643
  #[cfg(feature = "decryption-mode-13")]
594
644
  pub fn mode13_payload(
595
645
  &self,
@@ -608,7 +658,6 @@ impl<'a> UserDataBlock<'a> {
608
658
  Ok(Some(payload))
609
659
  }
610
660
 
611
- #[cfg(feature = "decryption-mode-13")]
612
661
  pub fn transport_payload(&self) -> Option<(&ShortTplHeader, &'a [u8])> {
613
662
  match self {
614
663
  Self::VariableDataStructureWithLongTplHeader {
@@ -663,6 +712,9 @@ impl<'a> UserDataBlock<'a> {
663
712
  Self::VariableDataStructureWithLongTplHeader {
664
713
  long_tpl_header, ..
665
714
  } => Some(long_tpl_header.is_encrypted()),
715
+ Self::VariableDataStructureWithShortTplHeader {
716
+ short_tpl_header, ..
717
+ } => Some(short_tpl_header.is_encrypted()),
666
718
  Self::ApplicationMessage(message) => Some(message.transport_header.is_encrypted()),
667
719
  _ => None,
668
720
  }
@@ -733,6 +785,7 @@ impl<'a> UserDataBlock<'a> {
733
785
  long_tpl_header.short_tpl_header.decrypt_payload(
734
786
  variable_data_block,
735
787
  context,
788
+ self.authentication(),
736
789
  provider,
737
790
  output,
738
791
  )
@@ -796,7 +849,13 @@ impl<'a> UserDataBlock<'a> {
796
849
  access_number: short_tpl_header.access_number,
797
850
  };
798
851
 
799
- short_tpl_header.decrypt_payload(variable_data_block, context, provider, output)
852
+ short_tpl_header.decrypt_payload(
853
+ variable_data_block,
854
+ context,
855
+ self.authentication(),
856
+ provider,
857
+ output,
858
+ )
800
859
  }
801
860
  Self::VariableDataStructureWithLongTplHeader { .. }
802
861
  | Self::ApplicationMessage(ApplicationMessage {
@@ -918,11 +977,30 @@ impl ShortTplHeader {
918
977
  &self,
919
978
  data: &[u8],
920
979
  context: crate::decryption::KeyContext,
980
+ authentication: Option<AuthenticationHeader<'_>>,
921
981
  provider: &K,
922
982
  output: &mut [u8],
923
983
  ) -> Result<usize, crate::decryption::DecryptionError> {
924
984
  use crate::decryption::EncryptedPayload;
925
985
 
986
+ #[cfg(not(feature = "decryption-mode-7"))]
987
+ let _ = authentication;
988
+ #[cfg(feature = "decryption-mode-7")]
989
+ if context.security_mode == m_bus_core::SecurityMode::AesCbc128IvZero {
990
+ use crate::decryption::{DecryptionError, Mode7Payload};
991
+ let authentication = authentication.ok_or(DecryptionError::UnsupportedConfiguration)?;
992
+ let control = ControlInformation::from(self.control_information)
993
+ .map_err(|_| DecryptionError::UnknownEncryptionState)?;
994
+ return Mode7Payload {
995
+ data,
996
+ context,
997
+ configuration: self.configuration_field,
998
+ from_meter: matches!(Direction::from(control), Direction::SlaveToMaster),
999
+ authentication: &authentication,
1000
+ }
1001
+ .decrypt_into(provider, output);
1002
+ }
1003
+
926
1004
  #[cfg(feature = "decryption-mode-10")]
927
1005
  if matches!(context.security_mode, m_bus_core::SecurityMode::AesCcm128) {
928
1006
  use crate::decryption::{DecryptionError, Mode10Payload};
@@ -950,6 +1028,9 @@ impl<'a> TryFrom<&'a [u8]> for UserDataBlock<'a> {
950
1028
  type Error = ApplicationLayerError;
951
1029
 
952
1030
  fn try_from(data: &'a [u8]) -> Result<Self, ApplicationLayerError> {
1031
+ if data.first() == Some(&0x90) {
1032
+ return Self::parse_authenticated(data);
1033
+ }
953
1034
  if data.is_empty() {
954
1035
  return Err(ApplicationLayerError::MissingControlInformation);
955
1036
  }
@@ -1036,6 +1117,7 @@ impl<'a> TryFrom<&'a [u8]> for UserDataBlock<'a> {
1036
1117
  .get(13..data.len())
1037
1118
  .ok_or(ApplicationLayerError::InsufficientData)?,
1038
1119
  extended_link_layer: None,
1120
+ authentication: None,
1039
1121
  })
1040
1122
  }
1041
1123
  ControlInformation::ResponseWithFixedDataStructure => {
@@ -1117,6 +1199,7 @@ impl<'a> TryFrom<&'a [u8]> for UserDataBlock<'a> {
1117
1199
  .get(data_block_offset..data.len())
1118
1200
  .ok_or(ApplicationLayerError::InsufficientData)?,
1119
1201
  extended_link_layer: None,
1202
+ authentication: None,
1120
1203
  })
1121
1204
  }
1122
1205
  ControlInformation::SynchronizeSlave
@@ -1192,20 +1275,24 @@ impl<'a> TryFrom<&'a [u8]> for UserDataBlock<'a> {
1192
1275
  Ok(UserDataBlock::VariableDataStructureWithLongTplHeader {
1193
1276
  long_tpl_header,
1194
1277
  variable_data_block,
1278
+ authentication,
1195
1279
  ..
1196
1280
  }) => Ok(UserDataBlock::VariableDataStructureWithLongTplHeader {
1197
1281
  extended_link_layer,
1198
1282
  long_tpl_header,
1199
1283
  variable_data_block,
1284
+ authentication,
1200
1285
  }),
1201
1286
  Ok(UserDataBlock::VariableDataStructureWithShortTplHeader {
1202
1287
  short_tpl_header,
1203
1288
  variable_data_block,
1289
+ authentication,
1204
1290
  ..
1205
1291
  }) => Ok(UserDataBlock::VariableDataStructureWithShortTplHeader {
1206
1292
  extended_link_layer,
1207
1293
  short_tpl_header,
1208
1294
  variable_data_block,
1295
+ authentication,
1209
1296
  }),
1210
1297
  Ok(UserDataBlock::VariableDataStructureWithoutTplHeader {
1211
1298
  variable_data_block,
@@ -1237,6 +1324,7 @@ impl<'a> TryFrom<&'a [u8]> for UserDataBlock<'a> {
1237
1324
 
1238
1325
  Ok(UserDataBlock::VariableDataStructureWithShortTplHeader {
1239
1326
  extended_link_layer: Some(ell),
1327
+ authentication: None,
1240
1328
  short_tpl_header,
1241
1329
  variable_data_block: data
1242
1330
  .get(app_data_offset..)
@@ -1376,7 +1464,7 @@ mod tests {
1376
1464
  assert_eq!(
1377
1465
  result,
1378
1466
  Ok(UserDataBlock::ResetAtApplicationLevel {
1379
- subcode: ApplicationResetSubcode::All(0x10)
1467
+ subcode: ApplicationResetSubcode::UserData(0x10)
1380
1468
  })
1381
1469
  );
1382
1470
  }