Coder Social home page Coder Social logo

exrom / eddly Goto Github PK

View Code? Open in Web Editor NEW

This project forked from hydrogentimespi/eddly

1.0 0.0 0.0 16 KB

Eddly is a python-module for parsing electronic device description (edd) files for HART according to IEC 61804

License: MIT License

Python 100.00%

eddly's Introduction

eddly

Introduction

Eddly is a python-based parsing library for the electronic device description language (edd). The edd describes how to configure and communicate with a field device. It is standardized with IEC 61804. Find more details at https://en.wikipedia.org/wiki/Device_Description_Language

This library can read a *.ddl file and generate a python data structure from it. This may be used for generating documentation (menu trees, command lists,...) or writing a communication tool for a field device. It uses the python-based parsing framework SLY (thanks to David Beazley) and the C99 preprocessor pcpp (thanks to Niall Douglas and David Beazley). It requires the use of Python 3.6 or greater.

License

This work is distributed under the MIT license. See LICENSE for details.

Features

  • supports C-like preprocessing (#include, #define,...) with preprocessed output for debugging
  • can read standard dc8 text libraries and handle [text_ref] references
  • basic parsing support for COMMANDs, VARIABLEs, MENUs with focus on HART. Other edd keywords (IMPORT, METHOD, GRID, IF, ELSE,...) currently unsupported.
  • print menu tree in ascii-art.

How it works

A main *.ddl file is provided as input.

  • Step 1: file is given to the preprocessor pcpp (#include files, remove /* comments */, replace #define macros,...)
  • Step 2: preprocessed output is passed to SLY's lexer (identify tokens like 'COMMAND', 'LABEL', numbers, strings,...)
  • Step 3: lexed tokens are parsed by SLY's parser
  • Step 4: dicts for commands, variables, menues are generated for further processing.

The demo.py file will print

# Edd meta data: manufacturer 255, device type 38911, dd revision 1, device revision 1
# commands
{   'write_configuration': {   'NUMBER': 555,
                               'OPERATION': 'WRITE',
                               'TRANSACTIONS': {   0: {   'REQUEST': [   'config_data']}}}}
# variables
{   'sensor_unit': {   'CLASS': ['LOCAL', 'DYNAMIC'],
                       'FORMAT': 'UNSIGNED_INTEGER',
                       'HANDLING': ['READ', 'WRITE'],
                       'SIZE': 1},
    'sensor_value': {   'CLASS': ['LOCAL', 'DYNAMIC'],
                        'FORMAT': 'FLOAT',
                        'HANDLING': ['READ', 'WRITE'],
                        'LABEL': 'Measurement'}}
# menues
{   'configuration_menu': {   'ITEMS': ['sensor_value', 'sensor_unit'],
                              'LABEL': 'Configuration menu'},
    'diagnostics_menu': {   'ITEMS': ['"device status"', '"process status"'],
                            'LABEL': 'Diagnostics menu'},
    'root_menu': {   'ITEMS': ['configuration_menu', 'diagnostics_menu'],
                     'LABEL': 'Main menu'}}
   Main menu
   ├─── Configuration menu
   │    ├─── Measurement
   │    └─── sensor_unit
   └─── Diagnostics menu
        ├─── device status
        └─── process status

Installation

Install required external modules with

pip install sly pcpp

TODO

  • improve handling and ignoring of unsupported keywords; get rid of sly WARNING messages. Parsing currently fails if ignored keyword is the last in pp'ed input

Caution

This is a hobby project and a proof-of-concept. Only a fraction of the edd language is implemented. It is far away from implementing the whole IEC 61804, so it is not standard conformant. What is implemented may be wrong.
Use it on your own risk!

Contribution

Welcome. Thanks to all contributors.

eddly's People

Contributors

hydrogentimespi avatar

Stargazers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.