mapcan 0.24.2__tar.gz → 0.25.0__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.
- {mapcan-0.24.2 → mapcan-0.25.0}/.gitignore +4 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/PKG-INFO +3 -3
- {mapcan-0.24.2 → mapcan-0.25.0}/README.md +2 -2
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/cli.md +29 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/format-changelog.md +18 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/format.md +52 -3
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/web.md +2 -2
- {mapcan-0.24.2 → mapcan-0.25.0}/pyproject.toml +1 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/schema/mapcan-part.schema.json +6 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/schema/mapcan.schema.json +6 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/__init__.py +1 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/cli.py +42 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/codegen/c.py +15 -3
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/codegen/common.py +10 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/codegen/py.py +5 -3
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/diff.py +79 -20
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/docmodel.py +3 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/export/dbc.py +3 -2
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/export/eds.py +1 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fmt.py +1 -1
- mapcan-0.25.0/src/mapcan/importers/eds.py +295 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/layout.py +3 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/locale/ru.py +42 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/lsp/edits.py +4 -2
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/model.py +71 -2
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/resolve.py +6 -2
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/validate.py +24 -3
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/app.py +7 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/session.py +6 -2
- mapcan-0.25.0/src/mapcan/web/static/assets/index-Dj2CYSmo.js +39 -0
- mapcan-0.25.0/src/mapcan/web/static/assets/index-Yq5HaFOv.css +1 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/static/index.html +2 -2
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/yamlops.py +2 -1
- mapcan-0.25.0/tests/data/vendor-io.eds +185 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_codegen.py +61 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_diff.py +33 -1
- mapcan-0.25.0/tests/test_eds_import.py +102 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_i18n.py +16 -6
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_lsp_edits.py +5 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_model.py +51 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_validate.py +59 -1
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_web_errors.py +11 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_yamlops.py +8 -0
- mapcan-0.24.2/src/mapcan/web/static/assets/index-CrDV-cv2.css +0 -1
- mapcan-0.24.2/src/mapcan/web/static/assets/index-DbzxbTZB.js +0 -36
- {mapcan-0.24.2 → mapcan-0.25.0}/LICENSE +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/NOTICE +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/THIRD_PARTY_NOTICES.md +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/ci-example.md +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/demo-dark.gif +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/demo-light.gif +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/document-pages-dark.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/document-pages-light.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-demo-dark.gif +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-demo-light.gif +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-hover-dark.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-hover-light.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-map-dark.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-map-light.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-problems-dark.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-problems-light.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-quickfix-dark.gif +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/vscode-quickfix-light.gif +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/web-frame-dark.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/images/web-frame-light.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/logo-dark.svg +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/logo-light.svg +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/templates.md +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/docs/zephyr.md +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/canopen-node.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/j1939.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/minimal.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/tractor/powertrain.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/tractor/tractor.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/vehicle-can.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/zephyr/CMakeLists.txt +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/zephyr/prj.conf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/examples/zephyr/src/main.c +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/schema/mapcan-part-v1.schema.json +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/schema/mapcan-v1.schema.json +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/bits.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/canopen.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/codegen/__init__.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/codegen/zephyr.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/diagnostics.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/export/__init__.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/export/pdf.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/export/text.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/export/xlsx.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/extras.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/OFL-PTSerif.txt +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/OFL.txt +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Sans-Web-Bold.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Sans-Web-BoldItalic.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Sans-Web-Italic.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Sans-Web-Regular.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Serif-Web-Bold.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Serif-Web-BoldItalic.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Serif-Web-Italic.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/fonts/PT_Serif-Web-Regular.ttf +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/i18n.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/importers/__init__.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/importers/dbc.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/launcher.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/loader.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/locale/__init__.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/lsp/__init__.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/lsp/analysis.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/lsp/exports.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/lsp/server.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/protocols.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/schema.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/document.html.j2 +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/document.md.j2 +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/pdf/gost-19.typ +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/pdf/gost-2.105.typ +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/pdf/gost-7.32.typ +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/pdf/lib.typ +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/pdf/mapcan.typ +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/templates/xlsx_style.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/units.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/updates.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/upgrade.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/userconfig.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/__init__.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/devicefile.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/examples.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/newmap.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/static/OFL-Sora.txt +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/src/mapcan/web/static/favicon.svg +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/__init__.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/conftest.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/bit_layouts.json +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/invalid_map.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/legacy.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/logo.png +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/logo.svg +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/reference.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/v1/canopen-node.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/v1/j1939.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/v1/reference.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/v1/vehicle-can.yaml +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/zephyr_stub/zephyr/drivers/can.h +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/data/zephyr_stub/zephyr/kernel.h +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/golden/reference.md +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/golden/reference_bus1.h +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_auth.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_cli.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_device_file.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_direction.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_eds.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_exchange.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_export.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_extras.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_fmt.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_format_v1.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_import.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_include.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_j1939.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_launcher.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_loader_fast.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_lsp.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_lsp_server.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_new_signal.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_source.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_templates.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_titles.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_units.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_updates.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_upgrade.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_web.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_web_session.py +0 -0
- {mapcan-0.24.2 → mapcan-0.25.0}/tests/test_workspace.py +0 -0
|
@@ -20,6 +20,9 @@ env/
|
|
|
20
20
|
htmlcov/
|
|
21
21
|
.tox/
|
|
22
22
|
|
|
23
|
+
# npm workspaces (web, vscode, packages/*): dependencies installed at the root
|
|
24
|
+
node_modules/
|
|
25
|
+
|
|
23
26
|
# Generated output
|
|
24
27
|
out/
|
|
25
28
|
output/
|
|
@@ -45,3 +48,4 @@ examples_ui/
|
|
|
45
48
|
# Browser tests of the web editor
|
|
46
49
|
web/test-results/
|
|
47
50
|
web/playwright-report/
|
|
51
|
+
node_modules
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mapcan
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.25.0
|
|
4
4
|
Summary: A YAML map of CAN signals as the single source of truth: validation, Excel/PDF/Markdown/HTML, DBC, C/Python code
|
|
5
5
|
Project-URL: Homepage, https://github.com/ordu1453/mapcan
|
|
6
6
|
Project-URL: Documentation, https://github.com/ordu1453/mapcan/blob/main/docs/format.md
|
|
@@ -207,7 +207,7 @@ mapcan build my-map.yaml -o build/ # every output at once
|
|
|
207
207
|
| ⚙️ | C: IDs, enums, structs, `pack`/`unpack`; no dynamic memory | `mapcan gen c` |
|
|
208
208
|
| 🐍 | Python module for tests and test benches | `mapcan gen py` |
|
|
209
209
|
| 🔀 | Comparison of two versions, changelog | `mapcan diff` |
|
|
210
|
-
| 📥 | A map from an existing DBC | `mapcan import dbc` |
|
|
210
|
+
| 📥 | A map from an existing DBC, or a CANopen device from its EDS or DCF | `mapcan import dbc`, `mapcan import eds` |
|
|
211
211
|
|
|
212
212
|
<p align="center">
|
|
213
213
|
<picture>
|
|
@@ -281,7 +281,7 @@ multiplexing) and [tractor/](https://github.com/ordu1453/mapcan/blob/main/exampl
|
|
|
281
281
|
## Documentation
|
|
282
282
|
|
|
283
283
|
* **[Map format](https://github.com/ordu1453/mapcan/blob/main/docs/format.md)**: every field, the rules, included files, versioning.
|
|
284
|
-
* **[Command line](https://github.com/ordu1453/mapcan/blob/main/docs/cli.md)**: commands, validation, generated code, document customization, DBC import.
|
|
284
|
+
* **[Command line](https://github.com/ordu1453/mapcan/blob/main/docs/cli.md)**: commands, validation, generated code, document customization, DBC, EDS and DCF import.
|
|
285
285
|
* **[Web editor](https://github.com/ordu1453/mapcan/blob/main/docs/web.md)**: the app, browser mode and its security, keyboard shortcuts, HTTP API.
|
|
286
286
|
* **[VS Code extension](https://github.com/ordu1453/mapcan/blob/main/vscode/README.md)**: features, settings, commands.
|
|
287
287
|
* **[PDF templates](https://github.com/ordu1453/mapcan/blob/main/docs/templates.md)**: ESKD/GOST details, logos, fonts, custom templates.
|
|
@@ -135,7 +135,7 @@ mapcan build my-map.yaml -o build/ # every output at once
|
|
|
135
135
|
| ⚙️ | C: IDs, enums, structs, `pack`/`unpack`; no dynamic memory | `mapcan gen c` |
|
|
136
136
|
| 🐍 | Python module for tests and test benches | `mapcan gen py` |
|
|
137
137
|
| 🔀 | Comparison of two versions, changelog | `mapcan diff` |
|
|
138
|
-
| 📥 | A map from an existing DBC | `mapcan import dbc` |
|
|
138
|
+
| 📥 | A map from an existing DBC, or a CANopen device from its EDS or DCF | `mapcan import dbc`, `mapcan import eds` |
|
|
139
139
|
|
|
140
140
|
<p align="center">
|
|
141
141
|
<picture>
|
|
@@ -209,7 +209,7 @@ multiplexing) and [tractor/](examples/tractor/tractor.yaml) (a map in two files)
|
|
|
209
209
|
## Documentation
|
|
210
210
|
|
|
211
211
|
* **[Map format](docs/format.md)**: every field, the rules, included files, versioning.
|
|
212
|
-
* **[Command line](docs/cli.md)**: commands, validation, generated code, document customization, DBC import.
|
|
212
|
+
* **[Command line](docs/cli.md)**: commands, validation, generated code, document customization, DBC, EDS and DCF import.
|
|
213
213
|
* **[Web editor](docs/web.md)**: the app, browser mode and its security, keyboard shortcuts, HTTP API.
|
|
214
214
|
* **[VS Code extension](vscode/README.md)**: features, settings, commands.
|
|
215
215
|
* **[PDF templates](docs/templates.md)**: ESKD/GOST details, logos, fonts, custom templates.
|
|
@@ -18,6 +18,7 @@ mapcan gen py FILE [-o DIR] [--bus NAME]
|
|
|
18
18
|
mapcan build FILE [-o DIR] [--formats xlsx,pdf,md,html,dbc,eds,c,py] [--pdf-template NAME]
|
|
19
19
|
mapcan diff OLD NEW [--format text|md|json] [--fail-on breaking|any]
|
|
20
20
|
mapcan import dbc FILE.dbc [-o FILE.yaml] [--title TEXT] [--lang en] [--force]
|
|
21
|
+
mapcan import eds FILE.eds|FILE.dcf [-o FILE.yaml] [--node-id N] [--title TEXT] [--lang en] [--force]
|
|
21
22
|
mapcan migrate FILE… [--check] # former field names → current ones, format v1 → v2
|
|
22
23
|
mapcan fmt FILE… [--check] # keys in one order, comments and layout kept
|
|
23
24
|
mapcan schema [-o schema.json] [--part] # --part: schema of an included file
|
|
@@ -188,6 +189,29 @@ becomes a `can` bus with explicit IDs. Value names become identifiers (`Not avai
|
|
|
188
189
|
`NOT_AVAILABLE`, the original text goes to the description), and whatever DBC cannot express is
|
|
189
190
|
reported as a warning.
|
|
190
191
|
|
|
192
|
+
## Importing an EDS or DCF
|
|
193
|
+
|
|
194
|
+
`mapcan import eds` describes a CANopen device from the EDS or DCF (CiA 306) its vendor ships: a
|
|
195
|
+
map with one `canopen` bus and that device, named and titled after `ProductName` (the vendor goes to
|
|
196
|
+
`document.organization`). It brings over:
|
|
197
|
+
|
|
198
|
+
- the TPDOs and RPDOs 1–4 from their communication and mapping parameters (1800/1A00, 1400/1600):
|
|
199
|
+
the COB-ID (an `id` only when it is not the default `$NODEID+base`), the transmission type (event,
|
|
200
|
+
or on request for RTR-only), the inhibit time (`inhibit_ms`), the event timer (`cycle_ms` of a
|
|
201
|
+
TPDO, `timeout_ms` of an RPDO);
|
|
202
|
+
- the mapped objects as signals in their places, with `index`/`subindex`, the data type
|
|
203
|
+
(`INTEGER*` → `twos_complement`, `REAL*` → `float`, strings → `bytes`), the object's name as
|
|
204
|
+
the title (and, in snake case, the signal's name), the limits and a non-zero default value;
|
|
205
|
+
- the producer heartbeat time (1017) as a heartbeat frame.
|
|
206
|
+
|
|
207
|
+
A DCF gives the configured values (`ParameterValue`), the node ID and the bit rate
|
|
208
|
+
(`[DeviceComissioning]`). An EDS has no node ID: `--node-id` sets it, otherwise 1 is used with a
|
|
209
|
+
warning; the bit rate is set only when the device supports one. Warnings list what the map cannot
|
|
210
|
+
hold: dummy entries of a mapping (their bits stay free), PDOs beyond the fourth, synchronous
|
|
211
|
+
transmission types, disabled PDOs (imported as enabled), types of the manufacturer (imported as
|
|
212
|
+
unsigned numbers) and the dictionary objects that no PDO carries. `mapcan export eds` and `mapcan
|
|
213
|
+
import eds` round-trip the PDOs and their objects.
|
|
214
|
+
|
|
191
215
|
## Comparing versions
|
|
192
216
|
|
|
193
217
|
`mapcan diff OLD NEW` lists what changed between two versions of a map and marks the changes that
|
|
@@ -200,7 +224,11 @@ break devices built against the old one (`[breaking]` in text, **breaking:** in
|
|
|
200
224
|
| a frame's ID, CANopen function, PGN, priority, length or IDE changed; a device's node ID or address | timing, transmission mode, sender and receivers |
|
|
201
225
|
| a signal moved or resized; its byte order, representation, encoding, factor or offset changed | titles, descriptions, units of display, initial values |
|
|
202
226
|
| a value renamed or renumbered; a flag moved; the multiplexer or a multiplexer value changed | limits widened or removed |
|
|
203
|
-
| a limit narrowed or added | |
|
|
227
|
+
| a limit narrowed or added | a frame, signal or flag renamed in its place (`renamed`, see below) |
|
|
228
|
+
|
|
229
|
+
A frame, signal or flag that keeps its place and layout under a new name is listed as `renamed`, with its old
|
|
230
|
+
and new [canonical path](format.md#paths-of-signals) (`old` and `new` in JSON), for tools that refer to
|
|
231
|
+
signals by path. The bus does not change; the names in generated code and DBC do.
|
|
204
232
|
|
|
205
233
|
`--fail-on breaking` exits with code 1 when a breaking change is found, `--fail-on any` on any change;
|
|
206
234
|
[ci-example.md](ci-example.md#breaking-changes-in-pull-requests) uses it to check pull requests.
|
|
@@ -5,6 +5,24 @@ Changes of the map format by mapcan version. Up to 0.23 they keep `mapcan: 1`; 0
|
|
|
5
5
|
[Versioning and compatibility](format.md#versioning-and-compatibility). A map that uses a field
|
|
6
6
|
needs at least the version of mapcan that introduced it; former names stay readable.
|
|
7
7
|
|
|
8
|
+
## 0.25
|
|
9
|
+
|
|
10
|
+
- A field of a bit field can be the multiplexer selector (#149): `multiplexer: true` on a flag, as on a signal.
|
|
11
|
+
The bit field holding it has no `mux`. DBC export writes the field as the multiplexer signal; the generated
|
|
12
|
+
C and Python code read the selector from the bit field. Maps without it are unchanged, and so is their
|
|
13
|
+
`layout_crc32`.
|
|
14
|
+
- The canonical path of a frame, signal or flag, `bus.frame.signal.flag`, names it for references from outside
|
|
15
|
+
the map (#100, [Paths of signals](format.md#paths-of-signals)). For it to be unique, a repeated bus name is
|
|
16
|
+
now the error `duplicate-bus-name`. `mapcan diff` reports a frame, signal or flag renamed in its place as
|
|
17
|
+
`renamed` with the old and the new path, instead of a removal and an addition (which were breaking).
|
|
18
|
+
|
|
19
|
+
## 0.24.3
|
|
20
|
+
|
|
21
|
+
- `invalid_raw` of a signed signal accepts the bits of a value (#148): of an 8-bit `twos_complement` signal
|
|
22
|
+
`0xFF` means `-1`, as the code sent on the bus, instead of the error `invalid-overflow`. Values from 2^(n−1)
|
|
23
|
+
to 2^n−1 are read in the signal's representation; signed values are written as before. The editors write
|
|
24
|
+
the values of `invalid_raw` in hex.
|
|
25
|
+
|
|
8
26
|
## 0.24
|
|
9
27
|
|
|
10
28
|
- **Format version 2** (`mapcan: 2`): a signal has four encodings instead of eight (#140), `number`, `enum`,
|
|
@@ -184,7 +184,7 @@ CANopen ID computation:
|
|
|
184
184
|
| `representation` | `number`: how the raw value is read as a number: `unsigned` (default), `twos_complement` (the usual signed integer), `ones_complement`, `sign_magnitude`, or `float` (IEEE 754, see [Floating point](#floating-point)). Generated C and Python code packs and unpacks the value in this representation; ones' complement and sign-magnitude have a symmetric range (−127…127 for 8 bits). DBC stores two's complement only, so the export warns about those two. Formerly `signed` + `signed_code` |
|
|
185
185
|
| `values` | Value table: `{0: NO_DATA, 1: {name: OK, description: "normal"}}` |
|
|
186
186
|
| `value_format` | `dec` \| `hex`: how values are shown in documents |
|
|
187
|
-
| `flags` | Bit field flags: `{bit, bit_length: 1, name, description, values}`; `bit` is the offset from the least significant bit of the field |
|
|
187
|
+
| `flags` | Bit field flags: `{bit, bit_length: 1, name, description, values, multiplexer}`; `bit` is the offset from the least significant bit of the field |
|
|
188
188
|
| `factor`, `offset`, `unit`, `min`, `max` | Physical conversion and range (in physical units) |
|
|
189
189
|
| `multiplexer` | `true` for the multiplexer selector signal |
|
|
190
190
|
| `mux` | Selector value (or list of values) for which the signal is present |
|
|
@@ -233,6 +233,11 @@ SAE J1939-71:
|
|
|
233
233
|
| `not_available` | The sender has no value (the parameter is not supported or not ready) |
|
|
234
234
|
| `error` | The sender has the parameter but reports a fault in it |
|
|
235
235
|
|
|
236
|
+
The values of a signed signal (`representation` other than `unsigned`) may be written either as
|
|
237
|
+
signed numbers or as their bits: of an 8-bit `twos_complement` signal, `0xFF` is the same as `-1` and
|
|
238
|
+
`0x80..0x8F` the same as `-128..-113`. Values from 2^(n−1) to 2^n−1 of an n-bit signal are read as
|
|
239
|
+
bits in the signal's representation; documents and generated code show the signed values.
|
|
240
|
+
|
|
236
241
|
Documents list both. Generated C has `<frame>_<signal>_is_not_available(raw)` and
|
|
237
242
|
`<frame>_<signal>_is_error(raw)`, and a single "not available" value is also
|
|
238
243
|
`<FRAME>_<SIGNAL>_INVALID_RAW`; the Python module has the same functions. DBC has one invalid value
|
|
@@ -331,6 +336,22 @@ signals:
|
|
|
331
336
|
Signals with different `mux` values may occupy the same bits; this is not an overlap. A signal
|
|
332
337
|
without `mux` is present for every selector value.
|
|
333
338
|
|
|
339
|
+
The selector can also be a field of a bit field: `multiplexer: true` on the flag. The bit field itself
|
|
340
|
+
then has no `mux`. In DBC the field is the multiplexer signal; the generated code reads it from the bit field.
|
|
341
|
+
|
|
342
|
+
```yaml
|
|
343
|
+
signals:
|
|
344
|
+
- name: status
|
|
345
|
+
encoding: bitfield
|
|
346
|
+
byte: 0
|
|
347
|
+
byte_length: 1
|
|
348
|
+
flags:
|
|
349
|
+
- {name: ready, bit: 0}
|
|
350
|
+
- {name: page, bit: 4, bit_length: 2, multiplexer: true, values: {0: VOLTAGES, 1: TEMPERATURES}}
|
|
351
|
+
- {name: voltage_data, byte: 1, byte_length: 7, encoding: bytes, mux: 0}
|
|
352
|
+
- {name: temperature_data, byte: 1, byte_length: 7, encoding: bytes, mux: 1}
|
|
353
|
+
```
|
|
354
|
+
|
|
334
355
|
### Protocols and CAN IDs
|
|
335
356
|
|
|
336
357
|
| `protocol` | How the ID is obtained |
|
|
@@ -398,7 +419,8 @@ record. Documents show the object (`OD 0x6041:00`), and `mapcan export eds` writ
|
|
|
398
419
|
heartbeat time (1017, from a heartbeat frame's `cycle_ms`), the communication and mapping
|
|
399
420
|
parameters of each PDO with mapped signals (1400/1600 for RPDOs, 1800/1A00 for TPDOs; COB-ID
|
|
400
421
|
`$NODEID+base`, event timer from `cycle_ms`) and the objects themselves. Gaps between mapped
|
|
401
|
-
signals are filled with dummy objects.
|
|
422
|
+
signals are filled with dummy objects. `mapcan import eds` reads such a file, or a vendor's EDS or
|
|
423
|
+
DCF, back into a map ([cli.md](cli.md#importing-an-eds-or-dcf)).
|
|
402
424
|
|
|
403
425
|
```yaml
|
|
404
426
|
- name: drive_status
|
|
@@ -585,6 +607,31 @@ devices and frames in their places, marked with the file name; their forms are r
|
|
|
585
607
|
editors change the main file only), and clicking such a node in VS Code opens it in its file.
|
|
586
608
|
Included devices can be chosen as senders and receivers of the main file's frames.
|
|
587
609
|
|
|
610
|
+
## Paths of signals
|
|
611
|
+
|
|
612
|
+
A frame, signal or flag is referred to from outside the map (dashboard layouts, plots, alarm
|
|
613
|
+
thresholds, columns of decoded logs) by its **canonical path**, its names joined with dots:
|
|
614
|
+
|
|
615
|
+
| Node | Path | Example |
|
|
616
|
+
|---|---|---|
|
|
617
|
+
| Frame | `bus.frame` | `powertrain.eec1` |
|
|
618
|
+
| Signal | `bus.frame.signal` | `powertrain.eec1.engine_speed` |
|
|
619
|
+
| Field of a bit field | `bus.frame.signal.flag` | `can1.bms_faults.faults.overvoltage` |
|
|
620
|
+
|
|
621
|
+
The path is unique: bus names are unique in the map (`duplicate-bus-name`), frame names on their bus
|
|
622
|
+
wherever the frame is described (`duplicate-frame-name`), and signal and flag names in their frame
|
|
623
|
+
(`duplicate-signal-name`). The device that describes a frame is not part of the path, so moving a frame
|
|
624
|
+
from one device to another, or from a device to the bus, keeps it. Names are identifiers, so a path has
|
|
625
|
+
no other dots. The signals of an SDO exchange have no path.
|
|
626
|
+
|
|
627
|
+
Renaming a bus, frame, signal or flag changes the path. `mapcan diff` reports a frame, signal or flag
|
|
628
|
+
that keeps its place under a new name as **renamed**, with the old and the new path (`old` and `new`
|
|
629
|
+
in `--format json`), so that the references can be updated: a frame with the same ID, length and places
|
|
630
|
+
of its signals, a signal with the same bits, byte order and encoding, a flag with the same bits. Only
|
|
631
|
+
one candidate on each side counts; otherwise the change is a removal and an addition. In the editors,
|
|
632
|
+
**Copy Path** (the tree's context menu in VS Code, the button next to the node's name in the web editor)
|
|
633
|
+
copies the path of the selected node.
|
|
634
|
+
|
|
588
635
|
## Versioning and compatibility
|
|
589
636
|
|
|
590
637
|
`mapcan: 2` is the version of the format, not of the program. What it promises:
|
|
@@ -657,7 +704,7 @@ keep their order.
|
|
|
657
704
|
| Device | `name`, `short`, `title`, `description`, `node_id`, `address`, `frames` |
|
|
658
705
|
| Frame | `name`, `title`, `description`, `comment`, `canopen`, `id`, `extended`, `pgn`, `priority`, `destination`, `length`, `brs`, `direction`, `cycle_ms`, `trigger`, `inhibit_ms`, `timeout_ms`, `sender`, `receivers`, `signals`, `sdo` |
|
|
659
706
|
| Signal | `name`, `title`, `description`, `comment`, `encoding`, `start_bit`, `byte`, `bit`, `bit_length`, `byte_length`, `byte_order`, `representation`, `charset`, `terminator`, `factor`, `offset`, `unit`, `min`, `max`, `values`, `value_format`, `flags`, `multiplexer`, `mux`, `initial`, `source`, `invalid_raw`, `spn`, `index`, `subindex` |
|
|
660
|
-
| Flag | `name`, `bit`, `bit_length`, `description`, `values` |
|
|
707
|
+
| Flag | `name`, `bit`, `bit_length`, `description`, `values`, `multiplexer` |
|
|
661
708
|
| SDO exchange | `name`, `description`, `command`, `index`, `subindex`, `value` |
|
|
662
709
|
|
|
663
710
|
The examples of the repository are kept in this layout.
|
|
@@ -692,6 +739,7 @@ turned off with `--disable CODE` or `lint.disable`.
|
|
|
692
739
|
| `name-collision` | error | Names collide in generated code (differ only in case, or clash with a _phys property) |
|
|
693
740
|
| `name-style` | warning | Name does not match the style rule (lint) |
|
|
694
741
|
| `name-inconsistent` | warning | The same value name is spelled differently |
|
|
742
|
+
| `duplicate-bus-name` | error | Duplicate bus name in the map |
|
|
695
743
|
| `duplicate-device-name` | error | Duplicate device name on the bus |
|
|
696
744
|
| `duplicate-frame-name` | error | Duplicate frame name on the bus |
|
|
697
745
|
| `duplicate-signal-name` | error | Duplicate signal/flag name in the frame |
|
|
@@ -732,6 +780,7 @@ turned off with `--disable CODE` or `lint.disable`.
|
|
|
732
780
|
| `j1939-tp` | info | A PGN longer than 8 bytes is sent with the J1939-21 transport protocol |
|
|
733
781
|
| `canopen-od` | warning | Dictionary object on a signal outside a device's PDO, or outside 0x2000..0x9FFF |
|
|
734
782
|
| `od-duplicate` | warning | The same dictionary object on several signals of a device |
|
|
783
|
+
| `od-subindex-zero` | error | A signal at subindex 0 of an array or a record: subindex 0 holds the number of its entries |
|
|
735
784
|
|
|
736
785
|
### Sender and receivers
|
|
737
786
|
|
|
@@ -208,14 +208,14 @@ The sources are in [web/](../web) (Vue 3 + TypeScript + Vite). The built bundle
|
|
|
208
208
|
|
|
209
209
|
```sh
|
|
210
210
|
mapcan serve my-map.yaml --no-browser # API on :8765
|
|
211
|
+
npm ci # at the root of the repository: all npm workspaces
|
|
211
212
|
cd web
|
|
212
|
-
npm ci
|
|
213
213
|
npm run dev # http://localhost:5173 with hot reload
|
|
214
214
|
npm run build # type check + build into src/mapcan/web/static
|
|
215
215
|
```
|
|
216
216
|
|
|
217
217
|
UI strings are written in English in the source (`t("…")`, `N_("…")`) and serve as keys of the
|
|
218
|
-
Russian translation in [web/src/locale/ru.json](../web/src/locale/ru.json) (backend messages:
|
|
218
|
+
Russian translation in [web/src/locale/ru.json](../web/src/locale/ru.json) (the forms: [packages/forms/src/locale/ru.json](../packages/forms/src/locale/ru.json); backend messages:
|
|
219
219
|
[src/mapcan/locale/ru.py](../src/mapcan/locale/ru.py)); `tests/test_i18n.py` fails if a string has
|
|
220
220
|
no translation or a translation is no longer used.
|
|
221
221
|
After changing `web/src`, rebuild the bundle and commit `src/mapcan/web/static`: CI checks that
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
[project]
|
|
2
2
|
name = "mapcan"
|
|
3
|
-
version = "0.
|
|
3
|
+
version = "0.25.0"
|
|
4
4
|
description = "A YAML map of CAN signals as the single source of truth: validation, Excel/PDF/Markdown/HTML, DBC, C/Python code"
|
|
5
5
|
# readme: built from README.md with absolute links for PyPI (see fancy-pypi-readme below)
|
|
6
6
|
dynamic = ["readme"]
|
|
@@ -386,6 +386,12 @@
|
|
|
386
386
|
"default": null,
|
|
387
387
|
"description": "Value table (value → name) or the name of a table in value_tables.",
|
|
388
388
|
"title": "Values"
|
|
389
|
+
},
|
|
390
|
+
"multiplexer": {
|
|
391
|
+
"default": false,
|
|
392
|
+
"description": "Multiplexer selector: the value of this field tells which signals the frame currently contains, as the multiplexer of a signal does. A frame can have only one selector.",
|
|
393
|
+
"title": "Multiplexer",
|
|
394
|
+
"type": "boolean"
|
|
389
395
|
}
|
|
390
396
|
},
|
|
391
397
|
"required": [
|
|
@@ -468,6 +468,12 @@
|
|
|
468
468
|
"default": null,
|
|
469
469
|
"description": "Value table (value → name) or the name of a table in value_tables.",
|
|
470
470
|
"title": "Values"
|
|
471
|
+
},
|
|
472
|
+
"multiplexer": {
|
|
473
|
+
"default": false,
|
|
474
|
+
"description": "Multiplexer selector: the value of this field tells which signals the frame currently contains, as the multiplexer of a signal does. A frame can have only one selector.",
|
|
475
|
+
"title": "Multiplexer",
|
|
476
|
+
"type": "boolean"
|
|
471
477
|
}
|
|
472
478
|
},
|
|
473
479
|
"required": [
|
|
@@ -580,6 +580,48 @@ def import_dbc_cmd(
|
|
|
580
580
|
typer.echo(_summary(report))
|
|
581
581
|
|
|
582
582
|
|
|
583
|
+
@import_app.command("eds", help=_("EDS or DCF of a CANopen device → YAML map: its PDOs, the dictionary objects mapped "
|
|
584
|
+
"into them, the heartbeat."))
|
|
585
|
+
def import_eds_cmd(
|
|
586
|
+
path: Path = typer.Argument(..., exists=True, dir_okay=False, readable=True, help=_("EDS or DCF file.")),
|
|
587
|
+
out: Optional[Path] = typer.Option(None, "-o", "--output", help=_("YAML map file; <name>.yaml by default.")),
|
|
588
|
+
node_id: Optional[str] = typer.Option(
|
|
589
|
+
None, "--node-id",
|
|
590
|
+
help=_("Node ID of the device (1..127); a DCF gives its own, an EDS none (1 is used then).")),
|
|
591
|
+
title: Optional[str] = typer.Option(None, "--title", help=_("Document title; the product name by default.")),
|
|
592
|
+
lang: str = typer.Option("en", "--lang", help=_("Document language (ISO 639-1 code).")),
|
|
593
|
+
force: bool = typer.Option(False, "--force", help=_("Overwrite an existing file.")),
|
|
594
|
+
) -> None:
|
|
595
|
+
from .i18n import normalize_language
|
|
596
|
+
from .importers.eds import import_eds
|
|
597
|
+
|
|
598
|
+
target = _default_out(path, ".yaml", out)
|
|
599
|
+
if target.exists() and not force:
|
|
600
|
+
typer.secho(_("{path} already exists; give another -o or --force", path=target),
|
|
601
|
+
fg=typer.colors.RED, err=True)
|
|
602
|
+
raise typer.Exit(1)
|
|
603
|
+
doc_lang = normalize_language(lang)
|
|
604
|
+
if doc_lang is None:
|
|
605
|
+
raise typer.BadParameter(_("unknown language: {language}", language=lang))
|
|
606
|
+
node = None
|
|
607
|
+
if node_id is not None:
|
|
608
|
+
try:
|
|
609
|
+
node = int(node_id, 0) # decimal or 0x…, as node_id in a map
|
|
610
|
+
except ValueError:
|
|
611
|
+
node = None
|
|
612
|
+
if node is None or not 1 <= node <= 0x7F:
|
|
613
|
+
raise typer.BadParameter(_("node ID {value} is not 1..127", value=node_id), param_hint="--node-id")
|
|
614
|
+
text, warnings = import_eds(path, node, title, doc_lang)
|
|
615
|
+
for w in warnings:
|
|
616
|
+
_warn(w)
|
|
617
|
+
target.parent.mkdir(parents=True, exist_ok=True)
|
|
618
|
+
target.write_text(text, encoding="utf-8")
|
|
619
|
+
_done(target)
|
|
620
|
+
_res, report = validate_file(target)
|
|
621
|
+
_print_report(report)
|
|
622
|
+
typer.echo(_summary(report))
|
|
623
|
+
|
|
624
|
+
|
|
583
625
|
ALL_FORMATS = ["xlsx", "pdf", "md", "html", "dbc", "eds", "c", "py"]
|
|
584
626
|
|
|
585
627
|
|
|
@@ -17,7 +17,17 @@ from ..i18n import _
|
|
|
17
17
|
from ..layout import layout_crc32
|
|
18
18
|
from ..model import Bus, Frame, MapCan, Signal, enum_entries, text
|
|
19
19
|
from ..units import translate_unit
|
|
20
|
-
from .common import
|
|
20
|
+
from .common import (
|
|
21
|
+
code_text,
|
|
22
|
+
frames_with_layout,
|
|
23
|
+
is_byte_array,
|
|
24
|
+
num,
|
|
25
|
+
physical,
|
|
26
|
+
raw_limits,
|
|
27
|
+
selector_field,
|
|
28
|
+
selector_of,
|
|
29
|
+
storage_bits,
|
|
30
|
+
)
|
|
21
31
|
|
|
22
32
|
HELPERS = r"""
|
|
23
33
|
#ifndef MAPCAN_BITS_HELPERS
|
|
@@ -248,7 +258,9 @@ def _merge_guards(lines: list[str]) -> list[str]:
|
|
|
248
258
|
|
|
249
259
|
def _mux_cond(sel: Signal, values: list[int]) -> str:
|
|
250
260
|
"""The condition of multiplexed signals: the selector equal to one of the values."""
|
|
251
|
-
|
|
261
|
+
field = selector_field(sel)
|
|
262
|
+
value = f"((msg->{field[0]} >> {field[1]}u) & 0x{field[2]:X}u)" if field else f"msg->{sel.name}"
|
|
263
|
+
conds = [f"{value} == {v if sel.signed else _c_int(v)}" for v in values]
|
|
252
264
|
return conds[0] if len(conds) == 1 else " || ".join(f"({c})" for c in conds)
|
|
253
265
|
|
|
254
266
|
|
|
@@ -780,7 +792,7 @@ class CGen:
|
|
|
780
792
|
# Signals of another selector value do not keep what the previous frame had
|
|
781
793
|
unpack.append(f" {name}_init(msg);")
|
|
782
794
|
# The selector is unpacked first: the other signals depend on it.
|
|
783
|
-
order = sorted(f.layout, key=lambda s: not s.
|
|
795
|
+
order = sorted(f.layout, key=lambda s: not s.holds_selector)
|
|
784
796
|
if not f.layout:
|
|
785
797
|
unpack.append(" msg->reserved_ = 0u;")
|
|
786
798
|
for s in order:
|
|
@@ -142,7 +142,16 @@ def frames_with_layout(bus: Bus) -> list[Frame]:
|
|
|
142
142
|
|
|
143
143
|
|
|
144
144
|
def selector_of(frame: Frame) -> Signal | None:
|
|
145
|
-
|
|
145
|
+
"""The multiplexer selector; a field of a bit field comes as a signal of its own bits (Signal.flag_signal)."""
|
|
146
|
+
return frame.selector
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
def selector_field(sel: Signal) -> tuple[str, int, int] | None:
|
|
150
|
+
"""For a selector that is a field of a bit field: the bit field's name, the field's offset and its mask."""
|
|
151
|
+
if sel._selector_of is None:
|
|
152
|
+
return None
|
|
153
|
+
holder, fl = sel._selector_of
|
|
154
|
+
return holder.name, fl.bit, (1 << fl.bit_length) - 1
|
|
146
155
|
|
|
147
156
|
|
|
148
157
|
def raw_limits(s: Signal) -> tuple[int, int] | None:
|
|
@@ -14,7 +14,7 @@ from ..i18n import _
|
|
|
14
14
|
from ..layout import layout_crc32
|
|
15
15
|
from ..model import Bus, Frame, MapCan, enum_entries, text
|
|
16
16
|
from ..units import translate_unit
|
|
17
|
-
from .common import code_text, frames_with_layout, is_byte_array, num, physical, raw_limits, selector_of
|
|
17
|
+
from .common import code_text, frames_with_layout, is_byte_array, num, physical, raw_limits, selector_field, selector_of
|
|
18
18
|
|
|
19
19
|
RUNTIME = '''
|
|
20
20
|
|
|
@@ -246,7 +246,7 @@ class PyGen:
|
|
|
246
246
|
f" if len(data) < {f.length}:",
|
|
247
247
|
f" raise ValueError(f\"{bad_length}\")",
|
|
248
248
|
" msg = cls()"]
|
|
249
|
-
for s in sorted(f.layout, key=lambda s: not s.
|
|
249
|
+
for s in sorted(f.layout, key=lambda s: not s.holds_selector):
|
|
250
250
|
out += self._guard(s, sel, self._unpack_stmt(s, self._enum_cls(f, s)), "msg")
|
|
251
251
|
out.append(" return msg")
|
|
252
252
|
|
|
@@ -277,7 +277,9 @@ class PyGen:
|
|
|
277
277
|
if s.mux is None or sel is None:
|
|
278
278
|
return body
|
|
279
279
|
vals = ", ".join(str(v) for v in s.mux_values)
|
|
280
|
-
|
|
280
|
+
field = selector_field(sel)
|
|
281
|
+
value = f"(({obj}.{field[0]} >> {field[1]}) & 0x{field[2]:X})" if field else f"{obj}.{sel.name}"
|
|
282
|
+
return [f" if {value} in ({vals},):"] + [" " + b for b in body]
|
|
281
283
|
|
|
282
284
|
@staticmethod
|
|
283
285
|
def _pack_stmt(f: Frame, s) -> list[str]:
|
|
@@ -10,7 +10,9 @@ from typing import Any, Literal
|
|
|
10
10
|
from .docmodel import fmt_num, hex_id
|
|
11
11
|
from .model import Bus, Frame, MapCan, Signal, enum_entries, text
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
# renamed: a frame, signal or flag with a new name and the same place and layout; old and new are its canonical
|
|
14
|
+
# paths (bus.frame.signal.flag, docs/format.md), for references from outside the map
|
|
15
|
+
ChangeKind = Literal["added", "removed", "changed", "renamed"]
|
|
14
16
|
Scope = Literal["bus", "device", "frame", "signal", "flag", "value"]
|
|
15
17
|
|
|
16
18
|
|
|
@@ -59,7 +61,7 @@ FRAME_FIELDS = ("can_id", "canopen", "length", "direction", "mode", "cycle_ms",
|
|
|
59
61
|
SIGNAL_FIELDS = ("start_bit", "bit_length", "byte_order", "representation", "encoding", "factor", "offset",
|
|
60
62
|
"unit",
|
|
61
63
|
"min", "max", "initial", "source", "invalid_raw", "multiplexer", "mux", "description")
|
|
62
|
-
FLAG_FIELDS = ("bit", "bit_length", "description")
|
|
64
|
+
FLAG_FIELDS = ("bit", "bit_length", "multiplexer", "description")
|
|
63
65
|
|
|
64
66
|
# Fields whose change makes a device built against the old version send or read the bus differently
|
|
65
67
|
BREAKING_FIELDS = {
|
|
@@ -67,7 +69,7 @@ BREAKING_FIELDS = {
|
|
|
67
69
|
"frame": {"can_id", "canopen", "length", "extended", "pgn", "priority"},
|
|
68
70
|
"signal": {"start_bit", "bit_length", "byte_order", "representation", "encoding", "factor", "offset",
|
|
69
71
|
"multiplexer", "mux"},
|
|
70
|
-
"flag": {"bit", "bit_length"},
|
|
72
|
+
"flag": {"bit", "bit_length", "multiplexer"},
|
|
71
73
|
"value": {"name"},
|
|
72
74
|
}
|
|
73
75
|
|
|
@@ -103,7 +105,9 @@ def is_breaking(c: Change) -> bool:
|
|
|
103
105
|
|
|
104
106
|
def _invalid_text(s: Signal) -> str | None:
|
|
105
107
|
"""invalid_raw as one comparable text: "not_available 0xFF; error 0xFE00..0xFEFF"."""
|
|
106
|
-
|
|
108
|
+
def lit(v: int) -> str:
|
|
109
|
+
return f"0x{v:X}" if v >= 0 else str(v)
|
|
110
|
+
parts = [f"{meaning} " + ", ".join(lit(lo) if lo == hi else f"{lit(lo)}..{lit(hi)}" for lo, hi in ranges)
|
|
107
111
|
for meaning, ranges in s.invalid_ranges.items()]
|
|
108
112
|
return "; ".join(parts) or None
|
|
109
113
|
|
|
@@ -173,28 +177,67 @@ def _diff_bus(d: MapDiff, old: Bus, new: Bus, langs: tuple[str, str]) -> None:
|
|
|
173
177
|
for fld, a, b in _attrs_diff(oa, na, DEVICE_FIELDS):
|
|
174
178
|
d.changes.append(Change("changed", "device", new.name, device=name, field=fld, old=a, new=b))
|
|
175
179
|
|
|
176
|
-
of =
|
|
177
|
-
|
|
180
|
+
of, renamed = _matched(old.all_frames(), new.all_frames(), _frame_key)
|
|
181
|
+
kept = {x.name for x in of.values()}
|
|
178
182
|
for f in old.all_frames():
|
|
179
|
-
if f.name not in
|
|
183
|
+
if f.name not in kept:
|
|
180
184
|
d.changes.append(_frame_change("removed", new.name, f))
|
|
181
185
|
for f in new.all_frames():
|
|
182
186
|
if f.name not in of:
|
|
183
187
|
d.changes.append(_frame_change("added", new.name, f))
|
|
184
188
|
continue
|
|
185
189
|
o = of[f.name]
|
|
190
|
+
if f.name in renamed:
|
|
191
|
+
d.changes.append(_frame_change("renamed", new.name, f, field="name", old=o._ref, new=f._ref))
|
|
186
192
|
for fld, a, b in _attrs_diff(_frame_attrs(o, langs), _frame_attrs(f, langs), FRAME_FIELDS):
|
|
187
193
|
d.changes.append(_frame_change("changed", new.name, f, field=fld, old=a, new=b))
|
|
188
194
|
_diff_signals(d, new.name, o, f, langs)
|
|
189
195
|
|
|
190
196
|
|
|
197
|
+
def _frame_key(f: Frame):
|
|
198
|
+
# A frame is the same when its identifier and the places of its signals are; names of signals may change too
|
|
199
|
+
if f._ref is None or f.can_id is None:
|
|
200
|
+
return None
|
|
201
|
+
return f.can_id, f.extended, f.length, sorted((s.start_bit, s.bit_length, s.byte_order) for s in f.layout)
|
|
202
|
+
|
|
203
|
+
|
|
204
|
+
def _signal_key(s: Signal):
|
|
205
|
+
return None if s._ref is None else (s.start_bit, s.bit_length, s.byte_order, s.encoding)
|
|
206
|
+
|
|
207
|
+
|
|
208
|
+
def _flag_key(fl):
|
|
209
|
+
return fl.bit, fl.bit_length
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
def _matched(old: list, new: list, key) -> tuple[dict, set]:
|
|
213
|
+
"""Old node of each new one, by name ({new name: old node}), and the names of the renamed ones.
|
|
214
|
+
|
|
215
|
+
A node of the old version whose name is gone is renamed to a new name when they are the only removed and the
|
|
216
|
+
only added node with the same key (place and layout); otherwise it stays removed and the other one added.
|
|
217
|
+
"""
|
|
218
|
+
names_old = {x.name for x in old}
|
|
219
|
+
names_new = {x.name for x in new}
|
|
220
|
+
gone = [x for x in old if x.name not in names_new]
|
|
221
|
+
came = [x for x in new if x.name not in names_old]
|
|
222
|
+
keys_gone = [key(x) for x in gone]
|
|
223
|
+
keys_came = [key(x) for x in came]
|
|
224
|
+
out = {x.name: x for x in old if x.name in names_new}
|
|
225
|
+
renamed = set()
|
|
226
|
+
for x, k in zip(gone, keys_gone, strict=True):
|
|
227
|
+
if k is not None and keys_gone.count(k) == 1 and keys_came.count(k) == 1:
|
|
228
|
+
y = came[keys_came.index(k)]
|
|
229
|
+
out[y.name] = x
|
|
230
|
+
renamed.add(y.name)
|
|
231
|
+
return out, renamed
|
|
232
|
+
|
|
233
|
+
|
|
191
234
|
def _diff_signals(d: MapDiff, bus: str, of: Frame, nf: Frame, langs: tuple[str, str]) -> None:
|
|
192
235
|
base = {"bus": bus, "frame": nf.name, "can_id": hex_id(nf.can_id, nf.extended),
|
|
193
236
|
"device": nf.device.name if nf.device else ""}
|
|
194
|
-
os_ =
|
|
195
|
-
|
|
237
|
+
os_, renamed = _matched(of.layout, nf.layout, _signal_key)
|
|
238
|
+
kept = {x.name for x in os_.values()}
|
|
196
239
|
for s in of.layout:
|
|
197
|
-
if s.name not in
|
|
240
|
+
if s.name not in kept:
|
|
198
241
|
d.changes.append(Change("removed", "signal", signal=s.name, **base,
|
|
199
242
|
old=(s.start_bit, s.bit_length)))
|
|
200
243
|
for s in nf.layout:
|
|
@@ -202,6 +245,8 @@ def _diff_signals(d: MapDiff, bus: str, of: Frame, nf: Frame, langs: tuple[str,
|
|
|
202
245
|
d.changes.append(Change("added", "signal", signal=s.name, **base, new=(s.start_bit, s.bit_length)))
|
|
203
246
|
continue
|
|
204
247
|
o = os_[s.name]
|
|
248
|
+
if s.name in renamed:
|
|
249
|
+
d.changes.append(Change("renamed", "signal", signal=s.name, field="name", old=o._ref, new=s._ref, **base))
|
|
205
250
|
for fld, a, b in _attrs_diff(_signal_attrs(o, langs), _signal_attrs(s, langs), SIGNAL_FIELDS):
|
|
206
251
|
d.changes.append(Change("changed", "signal", signal=s.name, field=fld, old=a, new=b, **base))
|
|
207
252
|
# enum values
|
|
@@ -220,18 +265,23 @@ def _diff_signals(d: MapDiff, bus: str, of: Frame, nf: Frame, langs: tuple[str,
|
|
|
220
265
|
old=text(ov[v].description, *langs),
|
|
221
266
|
new=text(nv[v].description, *langs), **base))
|
|
222
267
|
# flags
|
|
223
|
-
ofl =
|
|
224
|
-
|
|
225
|
-
for
|
|
226
|
-
if
|
|
227
|
-
d.changes.append(Change("removed", "flag", signal=s.name, item=
|
|
268
|
+
ofl, renamed_fl = _matched(o.flags or [], s.flags or [], _flag_key)
|
|
269
|
+
kept_fl = {x.name for x in ofl.values()}
|
|
270
|
+
for y in o.flags or []:
|
|
271
|
+
if y.name not in kept_fl:
|
|
272
|
+
d.changes.append(Change("removed", "flag", signal=s.name, item=y.name, old=y.bit, **base))
|
|
228
273
|
for x in s.flags or []:
|
|
229
274
|
if x.name not in ofl:
|
|
230
275
|
d.changes.append(Change("added", "flag", signal=s.name, item=x.name, new=x.bit, **base))
|
|
231
276
|
continue
|
|
232
277
|
y = ofl[x.name]
|
|
233
|
-
|
|
234
|
-
|
|
278
|
+
if x.name in renamed_fl:
|
|
279
|
+
d.changes.append(Change("renamed", "flag", signal=s.name, item=x.name, field="name", old=y._ref,
|
|
280
|
+
new=x._ref, **base))
|
|
281
|
+
oa = {"bit": y.bit, "bit_length": y.bit_length, "multiplexer": y.multiplexer,
|
|
282
|
+
"description": text(y.description, *langs)}
|
|
283
|
+
na = {"bit": x.bit, "bit_length": x.bit_length, "multiplexer": x.multiplexer,
|
|
284
|
+
"description": text(x.description, *langs)}
|
|
235
285
|
for fld, a, b in _attrs_diff(oa, na, FLAG_FIELDS):
|
|
236
286
|
d.changes.append(Change("changed", "flag", signal=s.name, item=x.name, field=fld,
|
|
237
287
|
old=a, new=b, **base))
|
|
@@ -296,14 +346,14 @@ def changed_paths(diff: MapDiff, new: MapCan) -> dict[tuple, NodeStatus]:
|
|
|
296
346
|
|
|
297
347
|
_T = {
|
|
298
348
|
"ru": {
|
|
299
|
-
"added": "добавлен", "removed": "удалён", "changed": "изменён",
|
|
349
|
+
"added": "добавлен", "removed": "удалён", "changed": "изменён", "renamed": "переименован",
|
|
300
350
|
"bus": "шина", "device": "устройство", "frame": "кадр", "signal": "сигнал",
|
|
301
351
|
"flag": "флаг", "value": "значение", "bits": "биты", "byte": "байт",
|
|
302
352
|
"added_n": "добавлено", "removed_n": "удалено", "changed_n": "изменено",
|
|
303
353
|
"none": "Изменений нет.", "breaking": "несовместимо",
|
|
304
354
|
},
|
|
305
355
|
"en": {
|
|
306
|
-
"added": "added", "removed": "removed", "changed": "changed",
|
|
356
|
+
"added": "added", "removed": "removed", "changed": "changed", "renamed": "renamed",
|
|
307
357
|
"bus": "bus", "device": "device", "frame": "frame", "signal": "signal",
|
|
308
358
|
"flag": "flag", "value": "value", "bits": "bits", "byte": "byte",
|
|
309
359
|
"added_n": "added", "removed_n": "removed", "changed_n": "changed",
|
|
@@ -340,7 +390,16 @@ def changelog_lines(diff: MapDiff, lang: str = "ru") -> list[str]:
|
|
|
340
390
|
lines = []
|
|
341
391
|
for c in diff.changes:
|
|
342
392
|
frame = f"{c.can_id} {c.frame}".strip()
|
|
343
|
-
if c.
|
|
393
|
+
if c.kind == "renamed":
|
|
394
|
+
was = c.old.rsplit(".", 1)[-1]
|
|
395
|
+
if c.scope == "frame":
|
|
396
|
+
frame_was = f"{c.can_id} {was}".strip()
|
|
397
|
+
lines.append(f"{T['renamed'].capitalize()} {T['frame']} {frame_was} → {c.frame}")
|
|
398
|
+
elif c.scope == "signal":
|
|
399
|
+
lines.append(f"{frame}: {T['renamed']} {T['signal']} {was} → {c.signal}")
|
|
400
|
+
else:
|
|
401
|
+
lines.append(f"{frame}: {c.signal}: {T['renamed']} {T['flag']} {was} → {c.item}")
|
|
402
|
+
elif c.scope == "bus":
|
|
344
403
|
lines.append(f"{T[c.kind].capitalize()} {T['bus']} {c.bus}")
|
|
345
404
|
elif c.scope == "device":
|
|
346
405
|
if c.kind == "changed":
|