Package: objdictgen
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 theCANopencommunication protocol.This repo is located:https://github.com/laerdal/python-objdictgenobjdictgen 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-laerdalobjdictgen 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. Theodgexecutable is installed. It supports
reading and writing OD files in.jsonformat, in legacy XML.odand.edsfiles. It can generate c code for use with the canfestival library.MotivationThe biggest improvement with the new tool over the original implementation is
the introduction of a new.jsonbased 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.odgwill process the file in a repeatable
manner, making it possible support diffing of the.jsonfile output.odgremains 100% compatible with the legacy.odformat 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-ascInstallTo install into a virtual environmentvenv. 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 thisvenv/Scripts/odg.exewill exist and can be called
from anywhere to run it.Python 2To run theobjdicteditGUI, 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: Thepy.exetool is only shipped with recent Python 3.odgcommand-line toolodgis a command-line tool which is installed when the python packageobjdictgenis installed.Invocation:$ odg <options>
$ python -mobjdictgen <options>   # <-- If odg is unavailableodg --helpandodg <command> --helpexists 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 ODLegacy commandsThe legacy commandsobjdictgenandobjdicteditare still available. The
same commands are available underodg genandodg editrespectively. Note
that Python 2 is required to runobjdicteditdue to the dependency on the
old wxpython library.JSON schemasrc/objdictgen/schema/od.schema.jsonprovides a JSON schema for the JSON OD format. This can be used for validation
in editors.To use the schema inVS Code, the following configuration must be added to
yoursettings.json. After this is is installed, IntelliSense will show field
descriptions, help with values and validate the file."json.schemas":[{"fileMatch":["**.json"],"url":"./src/objdictgen/schema/od.schema.json"}],"files.associations":{"*.json":"jsonc"}ConversionThe recommended way to convert existing/legacy.odfiles to the new JSON
format is:$ odg generate <file.od> <file.json> --fix --drop-unused [--nosort]The--fixoption 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-unusedwill remove any unusedprofileandDS-302parameter that might be used in the file.LicenseObjdictgen has been based on the python tool included in CanFestival. This
original work from CanFestival is:Copyright (C): Edouard TISSERANT, Francis DUPIN and Laurent BESSARDThe Python 3 port and tool improvements have been implemented underCopyright (C) 2022-2023 Svein Seldal, Laerdal Medical AS