Skip to main content

CanFestival Object Dictionary tool

Project description

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 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/.jsonc format, in legacy XML .od and .eds files. It can generate c code for use with the canfestival library.

Install

To use this package Python3 must be installed. Use the package manager of choice to install the package in a virtual manager. We recommend the uv package manager.

Using uv (one of many methods)

$ uv venv
$ uv pip install objdictgen[ui]  # [ui] will install GUI tools
$ uv run odg

Using pip (for Windows)

$ py -3 -mvenv venv
$ venv/Scripts/pip install objdictgen[ui]

After this venv/Scripts/odg.exe (on Windows) or venv\bin\odg executable exists and can be called directly to run the command.

The objdictgen[ui] suffix will install the wx dependency needed for the UI odg edit. If no UI is needed, this suffix can be omitted.

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 no longer available. The commands are available under odg gen and odg edit respectively.

JSON schema

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.schemas": [
      {
        "fileMatch": [
          "**.jsonc"
        ],
        "url": "./src/objdictgen/schema/od.schema.json"
      }
    ],

Conversion

The recommended way to convert existing/legacy .od files to the new JSON format is:

$ odg generate <file.od> <file.jsonc> --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.

Motivation

The biggest improvement with the new tool over the original implementation is the introduction of a new .jsonc based format to store the object dictionary. The JSON format is well-known and easy to read. The tool use jsonc, allowing comments in the json file. odg will process the file in a repeatable manner, making it possible support diffing of the .jsonc 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 python 2 and and this is a port to python 3.

This tool is a fork from upstream canfestival-3-asc repo:

https://github.com/Laerdal/canfestival-3-asc

Making objdictedit excutable

To be able build an executable that can be run from anywhere:

$ pip install pyinstaller
$ pyinstaller packaging/objdictedit.spec

The file dist/objdictedit.exe can now be used anywhere. It does not need any pre-installed software.

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-2025 Svein Seldal, Laerdal Medical AS

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

objdictgen-3.5.4.tar.gz (217.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

objdictgen-3.5.4-py3-none-any.whl (150.2 kB view details)

Uploaded Python 3

File details

Details for the file objdictgen-3.5.4.tar.gz.

File metadata

  • Download URL: objdictgen-3.5.4.tar.gz
  • Upload date:
  • Size: 217.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for objdictgen-3.5.4.tar.gz
Algorithm Hash digest
SHA256 e3c925eaffa04d5c063b4823681b71404af06fab50d0d82045278b2492766b24
MD5 adfa3b409dd8228275a61cfe6c7898cb
BLAKE2b-256 73c25b05f2be3290e294f1c0e04da6a2b2c2742530533c238d9d663cb3b613c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for objdictgen-3.5.4.tar.gz:

Publisher: publish.yml on Laerdal/python-objdictgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file objdictgen-3.5.4-py3-none-any.whl.

File metadata

  • Download URL: objdictgen-3.5.4-py3-none-any.whl
  • Upload date:
  • Size: 150.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for objdictgen-3.5.4-py3-none-any.whl
Algorithm Hash digest
SHA256 d53eabc24c612b81aa192ff63f023bd370f380c8a81fec4c0b95e0292c980526
MD5 e73d60ef93687282b8bdfdfe233c1f57
BLAKE2b-256 d43be4007b76660bfa80d5fd8859898bb746ecdc1bd95c40d1edd72afe272c3d

See more details on using hashes here.

Provenance

The following attestation bundles were made for objdictgen-3.5.4-py3-none-any.whl:

Publisher: publish.yml on Laerdal/python-objdictgen

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page