# Objdictgen (`odg`)
This is python tools for working with Object Dictionary (OD) files for
the CanFestival communication library. CanFestival is an open source
implementation of the [CANopen](https://www.can-cia.org/canopen/)
communication protocol.
This repo is located:
> https://github.com/laerdal/python-objdictgen
objdictgen includes tools to generate c code that works in tandem with a
canfestival library. This tool has been built to work together with the
Laerdal Medical fork for the canfestival library:
> https://github.com/laerdal/canfestival-laerdal
objdictgen is a tool to parse, view and manipulate files containing object
dictionary (OD). An object dictionary is entries with data and configuration
in CANopen devices. The `odg` executable is installed. It supports
reading and writing OD files in `.json` format, in legacy XML `.od` and `.eds`
files. It can generate c code for use with the canfestival library.
## Motivation
The biggest improvement with the new tool over the original implementation is
the introduction of a new `.json` based format to store the object dictionary.
The JSON format is well-known and easy to read. The tool supports jsonc,
allowing comments in the json file. `odg` will process the file in a repeatable
manner, making it possible support diffing of the `.json` file output. `odg`
remains 100% compatible with the legacy `.od` format on both input and output.
The original objdictedit and objdictgen tool were written in legacy python2 and
and this is a port to python3. The package still remains compatible with
python2, as python2 is required for running the UI tools.
This tool is a fork from upstream canfestival-3-asc repo:
> https://github.com/laerdal/canfestival-3-asc
## Install
To install into a virtual environment `venv`. Check out this repo and go to
the top in a command-prompt (here assuming Windows and git bash):
$ py -3 -mvenv venv
$ venv/Scripts/python -mpip install --upgrade pip wheel setuptools
$ venv/Scripts/pip install .
After this `venv/Scripts/odg.exe` will exist and can be called
from anywhere to run it.
### Python 2
To run the `objdictedit` GUI, wxPython is required and it is only available
for Python 2.7. Download and install both.
* https://www.python.org/downloads/release/python-2716/
* https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/
To setup the virtual environment run (assuming git bash):
$ py.exe -2 -mvirtualenv --system-site-packages venv-27
$ venv-27/Scripts/python -mpip install --upgrade pip wheel setuptools
$ venv-27/Scripts/pip install .
NOTE: The `py.exe` tool is only shipped with recent Python 3.
## `odg` command-line tool
`odg` is a command-line tool which is installed when the python package
`objdictgen` is installed.
Invocation:
$ odg <options>
$ python -mobjdictgen <options> # <-- If odg is unavailable
`odg --help` and `odg <command> --help` exists and shows the command options.
The most useful commands are:
$ odg list <od-files...> # List contents of the OD
$ odg convert <od-file1> <od-file2> # Convert OD file
$ odg convert <od-file> <c-file> # Convert OD to c code
$ odg diff <od-file1> <od-file2> # Show differences between OD
### Legacy commands
The legacy commands `objdictgen` and `objdictedit` are still available. The
same commands are available under `odg gen` and `odg edit` respectively. Note
that Python 2 is required to run `objdictedit` due to the dependency on the
old wxpython library.
## JSON schema
[src/objdictgen/schema/od.schema.json](src/objdictgen/schema/od.schema.json)
provides a JSON schema for the JSON OD format. This can be used for validation
in editors.
To use the schema in **VS Code**, the following configuration must be added to
your `settings.json`. After this is is installed, IntelliSense will show field
descriptions, help with values and validate the file.
```json
"json.schemas": [
{
"fileMatch": [
"**.json"
],
"url": "./src/objdictgen/schema/od.schema.json"
}
],
"files.associations": {
"*.json": "jsonc"
}
```
## Conversion
The recommended way to convert existing/legacy `.od` files to the new JSON
format is:
$ odg generate <file.od> <file.json> --fix --drop-unused [--nosort]
The `--fix` option might be necessary if the OD-file contains internal
inconsistencies. It is safe to run this option as it will not delete any active
parameters. The `--drop-unused` will remove any unused *profile* and *DS-302*
parameter that might be used in the file.
## License
Objdictgen has been based on the python tool included in CanFestival. This
original work from CanFestival is:
Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD
The Python 3 port and tool improvements have been implemented under
Copyright (C) 2022-2023 Svein Seldal, Laerdal Medical AS
Raw data
{
"_id": null,
"home_page": "https://github.com/laerdal-svg/python-objdictgen",
"name": "objdictgen",
"maintainer": "",
"docs_url": null,
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
"maintainer_email": "",
"keywords": "build,development,canfestival,canopen,objdictgen",
"author": "Svein Seldal",
"author_email": "sveinse@seldal.com",
"download_url": "https://files.pythonhosted.org/packages/48/8b/1a1f4301a636cc77e76893235b5cdda2fb8d769c319936442778b40fe69a/objdictgen-3.3.post1.tar.gz",
"platform": null,
"description": "# Objdictgen (`odg`)\n\nThis is python tools for working with Object Dictionary (OD) files for\nthe CanFestival communication library. CanFestival is an open source\nimplementation of the [CANopen](https://www.can-cia.org/canopen/)\ncommunication protocol.\n\nThis repo is located:\n\n> https://github.com/laerdal/python-objdictgen\n\nobjdictgen includes tools to generate c code that works in tandem with a\ncanfestival library. This tool has been built to work together with the\nLaerdal Medical fork for the canfestival library:\n\n> https://github.com/laerdal/canfestival-laerdal\n\nobjdictgen is a tool to parse, view and manipulate files containing object\ndictionary (OD). An object dictionary is entries with data and configuration\nin CANopen devices. The `odg` executable is installed. It supports\nreading and writing OD files in `.json` format, in legacy XML `.od` and `.eds`\nfiles. It can generate c code for use with the canfestival library.\n\n\n## Motivation\n\nThe biggest improvement with the new tool over the original implementation is\nthe introduction of a new `.json` based format to store the object dictionary.\nThe JSON format is well-known and easy to read. The tool supports jsonc,\nallowing comments in the json file. `odg` will process the file in a repeatable\nmanner, making it possible support diffing of the `.json` file output. `odg`\nremains 100% compatible with the legacy `.od` format on both input and output.\n\nThe original objdictedit and objdictgen tool were written in legacy python2 and\nand this is a port to python3. The package still remains compatible with\npython2, as python2 is required for running the UI tools.\n\nThis tool is a fork from upstream canfestival-3-asc repo:\n\n> https://github.com/laerdal/canfestival-3-asc\n\n\n## Install\n\nTo install into a virtual environment `venv`. Check out this repo and go to\nthe top in a command-prompt (here assuming Windows and git bash):\n\n $ py -3 -mvenv venv\n $ venv/Scripts/python -mpip install --upgrade pip wheel setuptools\n $ venv/Scripts/pip install .\n\nAfter this `venv/Scripts/odg.exe` will exist and can be called\nfrom anywhere to run it.\n\n\n### Python 2\n\nTo run the `objdictedit` GUI, wxPython is required and it is only available\nfor Python 2.7. Download and install both.\n\n * https://www.python.org/downloads/release/python-2716/\n * https://sourceforge.net/projects/wxpython/files/wxPython/2.8.12.1/\n\nTo setup the virtual environment run (assuming git bash):\n\n $ py.exe -2 -mvirtualenv --system-site-packages venv-27\n $ venv-27/Scripts/python -mpip install --upgrade pip wheel setuptools\n $ venv-27/Scripts/pip install .\n\nNOTE: The `py.exe` tool is only shipped with recent Python 3.\n\n\n## `odg` command-line tool\n\n`odg` is a command-line tool which is installed when the python package\n`objdictgen` is installed.\n\nInvocation:\n\n $ odg <options>\n $ python -mobjdictgen <options> # <-- If odg is unavailable\n\n`odg --help` and `odg <command> --help` exists and shows the command options.\nThe most useful commands are:\n\n $ odg list <od-files...> # List contents of the OD\n $ odg convert <od-file1> <od-file2> # Convert OD file\n $ odg convert <od-file> <c-file> # Convert OD to c code\n $ odg diff <od-file1> <od-file2> # Show differences between OD\n\n\n### Legacy commands\n\nThe legacy commands `objdictgen` and `objdictedit` are still available. The\nsame commands are available under `odg gen` and `odg edit` respectively. Note\nthat Python 2 is required to run `objdictedit` due to the dependency on the\nold wxpython library.\n\n\n## JSON schema\n\n[src/objdictgen/schema/od.schema.json](src/objdictgen/schema/od.schema.json)\nprovides a JSON schema for the JSON OD format. This can be used for validation\nin editors.\n\nTo use the schema in **VS Code**, the following configuration must be added to\nyour `settings.json`. After this is is installed, IntelliSense will show field\ndescriptions, help with values and validate the file.\n\n```json\n \"json.schemas\": [\n {\n \"fileMatch\": [\n \"**.json\"\n ],\n \"url\": \"./src/objdictgen/schema/od.schema.json\"\n }\n ],\n \"files.associations\": {\n \"*.json\": \"jsonc\"\n }\n```\n\n\n## Conversion\n\nThe recommended way to convert existing/legacy `.od` files to the new JSON\nformat is:\n\n $ odg generate <file.od> <file.json> --fix --drop-unused [--nosort]\n\nThe `--fix` option might be necessary if the OD-file contains internal\ninconsistencies. It is safe to run this option as it will not delete any active\nparameters. The `--drop-unused` will remove any unused *profile* and *DS-302*\nparameter that might be used in the file.\n\n\n## License\n\nObjdictgen has been based on the python tool included in CanFestival. This\noriginal work from CanFestival is:\n\n Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARD\n\nThe Python 3 port and tool improvements have been implemented under\n\n Copyright (C) 2022-2023 Svein Seldal, Laerdal Medical AS\n",
"bugtrack_url": null,
"license": "",
"summary": "CanFestival object dictionary tools",
"version": "3.3.post1",
"project_urls": {
"Homepage": "https://github.com/laerdal-svg/python-objdictgen"
},
"split_keywords": [
"build",
"development",
"canfestival",
"canopen",
"objdictgen"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "28d27f6fbfbec49e35133e798a64a2701d84854c3d71ce6969de701f32c62601",
"md5": "7fe92e43366392770f4fbbc73e0c7928",
"sha256": "3630c46a3c1d01e3a933beaaa97cd9501b544f5bc2c08598c81ec4fa83adfc03"
},
"downloads": -1,
"filename": "objdictgen-3.3.post1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7fe92e43366392770f4fbbc73e0c7928",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
"size": 135579,
"upload_time": "2023-07-09T09:24:52",
"upload_time_iso_8601": "2023-07-09T09:24:52.772524Z",
"url": "https://files.pythonhosted.org/packages/28/d2/7f6fbfbec49e35133e798a64a2701d84854c3d71ce6969de701f32c62601/objdictgen-3.3.post1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "488b1a1f4301a636cc77e76893235b5cdda2fb8d769c319936442778b40fe69a",
"md5": "11903a6050c655ade6e34bb4df7a2472",
"sha256": "b15d235a7184d3fe097087682c9c30025d8871efcc4c1d54d4ff6d97c5ec9b5c"
},
"downloads": -1,
"filename": "objdictgen-3.3.post1.tar.gz",
"has_sig": false,
"md5_digest": "11903a6050c655ade6e34bb4df7a2472",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*, <4",
"size": 129501,
"upload_time": "2023-07-09T09:24:54",
"upload_time_iso_8601": "2023-07-09T09:24:54.453516Z",
"url": "https://files.pythonhosted.org/packages/48/8b/1a1f4301a636cc77e76893235b5cdda2fb8d769c319936442778b40fe69a/objdictgen-3.3.post1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-07-09 09:24:54",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "laerdal-svg",
"github_project": "python-objdictgen",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "objdictgen"
}