Skip to main content

EDS parser library for ODVA's CIP® protocol family (EtherNet/IP®, DeviceNet®, etc.)

Project description

EDS pie

EDS parser library for ODVA's CIP® protocol family(EtherNet/IP®, DeviceNet®,...)

python version3

The following are trademarks of ODVA:

CIP, CIP Energy, CIP Motion, CIP Security, CIP Safety, CIP Sync, CompoNet, ControlNet, DeviceNet, EtherNet/IP, QuickConnect.

Visit http://www.odva.org for product information and publications

What is an EDS

An Electronic Data Sheet (EDS), in the context of industrial communication, is a plain-text file that describes a device in terms of its parameters, capabilities, and I/O data structure. It provides all information necessary to identify the device, access its data, and configure its parameters when the device supports communication protocols such as CIP or CANopen.

What does EDS Pie offer?

  • Parsing EDS text files into a structured, hierarchical representation of sections, entries, and fields, as defined by the CIP specification
  • Programmatic creation, modification, and removal of sections, entries, and fields
  • Serialization of in-memory EDS objects back into a valid EDS plain-text file
  • Converting EDS data to JSON fromat

Setup

pip install eds_pie

Usage

EDS Pie consists of two primary components: a parser/serializer and a semantic checker.

To validate the contents of an Electronic Datasheet correctly, EDS Pie relies on protocol-specific reference definitions. These references describe the valid sections, entries, and fields as specified by ODVA for each supported protocol.

Current Implementation

The current implementation provides a reference library only for EtherNet/IP, located at: eds_pie/references/ethernetip_lib.json

Adding Support for Other Protocols

To support additional protocols—such as DeviceNet—a corresponding protocol-specific reference must be added to the eds_pie/references/ directory.

Requirements for the reference:

  • Must be in JSON format.
  • Must strictly conform to the schema defined in: eds_pie/references/edslib_schema.json

Once such a reference is added, EDS Pie can process and semantically validate EDS files for the corresponding protocol without further changes to the core codebase.

# Demo1.py

from eds_pie import CIP_EDS

with open('demo.eds', 'r') as src:
    eds_content = src.read()

eds = CIP_EDS(eds_content)
print("EDS Protocol: {}".format(eds.protocol or "Generic"))  

eds.list() # Lists all objects in the EDS file 
# or
print(eds) # Print the serialized EDS

image-demo1

API Reference

EDS object

  • EDS.get_section( section_keyword, class_id ) # Get a section object by it's keyword or it's classId
  • EDS.get_entry( section_keyword, entry_keyword ) # Get an Entry object
  • EDS.get_field( section_keyword, entry_keyword, field_index ) # Get a Field Object by its index
  • EDS.get_value( section_keyword, entry_keyword, field_index=0 ) # Get the value of a field
  • EDS.has_section( section_keyword )
  • EDS.has_entry( section_keyword, entry_keyword )
  • EDS.has_field( section_keyword, entry_keyword, field_index )
  • EDS.add_section( section_keyword, hcomment="", fcomment="" )
  • EDS.add_entry( section_keyword, entry_keyword, hcomment="", fcomment="" )
  • EDS.add_field( section_keyword, entry_keyword, field_value, [field_data_type]=None, hcomment="", fcomment="" ) # field_data_type must be one of defined CIP_TYPES from cip_eds_types module
  • EDS.list() # Lists all objects in the EDS
  • EDS.validate() # Performs semantic validation of the EDS data structure. Validation is automatically executed after each parsing operation. It may also be invoked explicitly at any time to validate the current state of the EDS contents.
  • EDS.save( filename, [overwrite]=False ) # To save the EDS contents into a file
  • EDS.str() # Or str(eds) returns a pretty print string representation of the EDS objects
  • EDS.protocol # CIP Protocol recognized during the parsing
  • EDS.sections # Representation of all EDS sections as a dictionary of {section_keyword: section_object}
  • EDS.hcomment # EDS File Header comment
  • EDS.fcomment # End comment of the EDS file
  • EDS.to_json() # Export EDS data to as a JSON object

Section object

  • Section.get_entry( entry_keyword )
  • Section.get_field( entry_keyword, field_index )
  • Section.get_value( entry_keyword, field_index=0 )
  • Section.has_entry( entry_keyword )
  • Section.add_entry( entry_keyword, hcomment="", fcomment="" )
  • Section.list()
  • Section.entries # Representation of all EDS entries as a dictionary of {entry_keyword: entry_object}
  • Section.name # Full descriptive name of the Section
  • Section.hcomment # This is the comment appears before the Section
  • Section.fcomment # This is the section appears after the section on the same line

Entry object

  • Entry.get_field( field_index )
  • Entry.get_value( field_index )
  • Entry.add_field( field_value, [field_data_type]=None, hcomment="", fcomment="" ) # field_data_type must be one of defined CIP_TYPES from cip_eds_types module
  • Entry.list()
  • Entry.name # Full descriptive name of the Entry
  • Entry.fields # Representation of all EDS fields in as a list
  • Entry.hcomment # This is the comment appears before an Entry

Field object

  • Field.name # Full descriptive name of the Field
  • Field.value # Field value in the form of python types (str, int,...)
  • Field.data # CIP_TYPES object that holds the actuall value of the field
  • Field.data_types # A list of valid data types (if any) for this specific field. This comes from the reference libraries
  • Field.hcomment # This is the comment appears before a Field
  • Field.fcomment # This is the comment appears after a Field

Debug mode

To retrieve the maximum information about the parsing process, set the logging level of eds_pie to DEBUG. In the debug mode, a list of parsed tokens will be displayed.

import logging

logging.basicConfig(level=logging.DEBUG,
    format='%(asctime)s - %(name)s.%(levelname)-8s %(message)s')
logger = logging.getLogger(__name__)

from eds_pie import eds_pie

with open('demo.eds', 'r') as srcfile:
    eds_content = srcfile.read()
eds = CIP_EDS(eds_content)

image-debugmode

Contributing

EDS Pie is designed to be extensible and collaborative. Contributions are appreciated in several forms, including:

  • Adding new protocol-specific reference libraries.
  • Improving or extending the functionality.
  • Enhancing documentation or providing usage examples.

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

eds_pie-1.2.0.tar.gz (26.1 kB view details)

Uploaded Source

Built Distribution

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

eds_pie-1.2.0-py3-none-any.whl (27.0 kB view details)

Uploaded Python 3

File details

Details for the file eds_pie-1.2.0.tar.gz.

File metadata

  • Download URL: eds_pie-1.2.0.tar.gz
  • Upload date:
  • Size: 26.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for eds_pie-1.2.0.tar.gz
Algorithm Hash digest
SHA256 4b7953782ad1c5d9f7450fd4cd676ef56adaff0d6dd27abed86663c121b07200
MD5 31f7d07b9a7d7f9c48a293f01da5b0d2
BLAKE2b-256 9d09f332688894077c3f363e9bb3190649dd2579af16d53b840b12ac02bd009d

See more details on using hashes here.

File details

Details for the file eds_pie-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: eds_pie-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 27.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.10.7

File hashes

Hashes for eds_pie-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 e0a901f21c45bd458e568f103ae3144186e8c99c3dde5146e2b41286196b23be
MD5 0c9907da915cf2b5fcef57528ba3682e
BLAKE2b-256 9672b4896bdc1a932d5910a12a19ef4ee4fa66859bbf95810070538f178fa517

See more details on using hashes here.

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