ldfparser


Nameldfparser JSON
Version 0.25.0 PyPI version JSON
download
home_pagehttps://github.com/c4deszes/ldfparser
SummaryLDF Language support for Python
upload_time2024-04-28 09:25:13
maintainerNone
docs_urlNone
authorBalazs Eszes
requires_python!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,<4
licenseMIT
keywords lin ldf
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # LDF Parser

[![Workflow](https://github.com/c4deszes/ldfparser/workflows/CI/badge.svg?branch=master)](https://github.com/c4deszes/ldfparser/actions)
[![Github Pages](https://img.shields.io/static/v1?style=flat&logo=github&label=gh-pages&color=green&message=deployed)](https://c4deszes.github.io/ldfparser/)
[![PyPI version](https://badge.fury.io/py/ldfparser.svg)](https://pypi.org/project/ldfparser/)
[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ldfparser.svg)](https://pypi.org/project/ldfparser/)
[![codecov.io](https://codecov.io/github/c4deszes/ldfparser/coverage.svg?branch=master)](https://codecov.io/github/c4deszes/ldfparser?branch=master)
[![Total alerts](https://img.shields.io/lgtm/alerts/g/c4deszes/ldfparser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/c4deszes/ldfparser/alerts/)
[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/c4deszes/ldfparser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/c4deszes/ldfparser/context:python)
![GitHub last commit](https://img.shields.io/github/last-commit/c4deszes/ldfparser)
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)

> This tool is able parse LIN Description Files, retrieve signal names and frames from them, as well as encoding messages using frame definitions and decoding them.

---

## Disclaimers

The library is still in a pre-release state, therefore features may break between minor versions.
For this reason it's recommended that productive environments pin to the exact version of the
library and do an integration test or review when updating the version. Breaking changes and how to
migrate to the new version will be documented in the
[changelog](https://github.com/c4deszes/ldfparser/blob/master/CHANGELOG.md) and on the
[Github releases page](https://github.com/c4deszes/ldfparser/releases).

The tool has been written according the LIN standards [1.3](docs/external/LIN_1.3.pdf),
[2.0](docs/external/LIN_2.0.pdf), [2.1](docs/external/LIN_2.1.pdf) and [2.2A](docs/external/LIN_2.2A.pdf),
but due to errors in the documentation there's no guarantee that the library will be able to parse your LDF.
In such cases if possible first verify the LDF with a commercial tool such as Vector LDF Explorer or the
tool that was used to create the LDF.  If the LDF seems to be correct then open a new issue.
I also recommend trying the LDF to JSON conversion mechanism, see if that succeeds.

The LIN standard is now known as [ISO 17987](https://www.iso.org/standard/61222.html) which
clears up some of the confusing parts in the 2.2A specification. Since this new standard is not
freely available **this library won't support the modifications present in ISO 17987**. I don't
think it's going to a huge problem because the LIN 2.2A released in 2010 has overall better adoption.

The LDF usually contains sensitive information, if you need to open an issue related to the parser
then try to provide either an anonymized version with signals and frames obfuscated or just the
relevant segments in an example LDF when opening issues.

---

## Installation

You can install this library from PyPI using pip.

```bash
pip install ldfparser
```

---

## Examples

```python
import ldfparser
import binascii

# Load LDF
ldf = ldfparser.parse_ldf(path = "network.ldf")
frame = ldf.get_unconditional_frame('Frame_1')

# Get baudrate from LDF
print(ldf.get_baudrate())

# Encode signal values into frame
message = frame.encode_raw({"Signal_1": 123, "Signal_2": 0})
print(binascii.hexlify(message))
>>> 0x7B00

# Decode message into dictionary of signal names and values
received = bytearray([0x7B, 0x00])
print(frame.decode(received))
>>> {"Signal_1": 123, "Signal_2": 0}

# Encode signal values through converters
message = frame.encode({"MotorRPM": 100, "FanState": "ON"})
print(binascii.hexlify(message))
>>> 0xFE01
```

More examples can be found in the [examples directory](./examples).

---

## Documentation

Documentation is published to [Github Pages](https://c4deszes.github.io/ldfparser/).

---

## Features

+ Semantic validation of LDF files

+ Retrieve header information (version, baudrate)

+ Retrieve Signal and Frame information

+ Retrieve Signal encoding types and use them to convert values

+ Retrieve Node attributes

+ Retrieve schedule table information

+ Command Line Interface

+ Capturing comments

+ Encode and decode standard diagnostic frames

+ Saving LDF object as an `.ldf` file (experimental)

### Known issues / missing features

+ Certain parsing related errors are unintuitive

+ Checksum calculation for frames

+ Token information is not preserved

---

## Development

Install the library locally by running `pip install -e .[dev]`

[Pytest](https://pytest.org/) is used for testing, to execute all tests run `pytest -m 'not snapshot'`

[Flake8](https://flake8.pycqa.org/en/latest/) is used for linting, run `flake8` to print out all linting errors.

---

## Contributors

[@c4deszes](https://github.com/c4deszes) (Author)

---

## Credits

Inspired by [uCAN-LIN LinUSBConverter](https://github.com/uCAN-LIN/LinUSBConverter), specifically the LDF parsing mechanism via [Lark](https://github.com/lark-parser/lark). Previously the library included most of the lark file, parsing code and examples, since 0.5.0 they've been completely rewritten to better accomodate the different LIN standards.

---

## License

[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/c4deszes/ldfparser",
    "name": "ldfparser",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,<4",
    "maintainer_email": null,
    "keywords": "LIN, LDF",
    "author": "Balazs Eszes",
    "author_email": "c4deszes@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/93/3a/ed6d13cb1c5e4c6f03084c3ad1236167cdf10dd5546239e594bc3147b9c3/ldfparser-0.25.0.tar.gz",
    "platform": null,
    "description": "# LDF Parser\n\n[![Workflow](https://github.com/c4deszes/ldfparser/workflows/CI/badge.svg?branch=master)](https://github.com/c4deszes/ldfparser/actions)\n[![Github Pages](https://img.shields.io/static/v1?style=flat&logo=github&label=gh-pages&color=green&message=deployed)](https://c4deszes.github.io/ldfparser/)\n[![PyPI version](https://badge.fury.io/py/ldfparser.svg)](https://pypi.org/project/ldfparser/)\n[![PyPI - Python Version](https://img.shields.io/pypi/pyversions/ldfparser.svg)](https://pypi.org/project/ldfparser/)\n[![codecov.io](https://codecov.io/github/c4deszes/ldfparser/coverage.svg?branch=master)](https://codecov.io/github/c4deszes/ldfparser?branch=master)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/c4deszes/ldfparser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/c4deszes/ldfparser/alerts/)\n[![Language grade: Python](https://img.shields.io/lgtm/grade/python/g/c4deszes/ldfparser.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/c4deszes/ldfparser/context:python)\n![GitHub last commit](https://img.shields.io/github/last-commit/c4deszes/ldfparser)\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n> This tool is able parse LIN Description Files, retrieve signal names and frames from them, as well as encoding messages using frame definitions and decoding them.\n\n---\n\n## Disclaimers\n\nThe library is still in a pre-release state, therefore features may break between minor versions.\nFor this reason it's recommended that productive environments pin to the exact version of the\nlibrary and do an integration test or review when updating the version. Breaking changes and how to\nmigrate to the new version will be documented in the\n[changelog](https://github.com/c4deszes/ldfparser/blob/master/CHANGELOG.md) and on the\n[Github releases page](https://github.com/c4deszes/ldfparser/releases).\n\nThe tool has been written according the LIN standards [1.3](docs/external/LIN_1.3.pdf),\n[2.0](docs/external/LIN_2.0.pdf), [2.1](docs/external/LIN_2.1.pdf) and [2.2A](docs/external/LIN_2.2A.pdf),\nbut due to errors in the documentation there's no guarantee that the library will be able to parse your LDF.\nIn such cases if possible first verify the LDF with a commercial tool such as Vector LDF Explorer or the\ntool that was used to create the LDF.  If the LDF seems to be correct then open a new issue.\nI also recommend trying the LDF to JSON conversion mechanism, see if that succeeds.\n\nThe LIN standard is now known as [ISO 17987](https://www.iso.org/standard/61222.html) which\nclears up some of the confusing parts in the 2.2A specification. Since this new standard is not\nfreely available **this library won't support the modifications present in ISO 17987**. I don't\nthink it's going to a huge problem because the LIN 2.2A released in 2010 has overall better adoption.\n\nThe LDF usually contains sensitive information, if you need to open an issue related to the parser\nthen try to provide either an anonymized version with signals and frames obfuscated or just the\nrelevant segments in an example LDF when opening issues.\n\n---\n\n## Installation\n\nYou can install this library from PyPI using pip.\n\n```bash\npip install ldfparser\n```\n\n---\n\n## Examples\n\n```python\nimport ldfparser\nimport binascii\n\n# Load LDF\nldf = ldfparser.parse_ldf(path = \"network.ldf\")\nframe = ldf.get_unconditional_frame('Frame_1')\n\n# Get baudrate from LDF\nprint(ldf.get_baudrate())\n\n# Encode signal values into frame\nmessage = frame.encode_raw({\"Signal_1\": 123, \"Signal_2\": 0})\nprint(binascii.hexlify(message))\n>>> 0x7B00\n\n# Decode message into dictionary of signal names and values\nreceived = bytearray([0x7B, 0x00])\nprint(frame.decode(received))\n>>> {\"Signal_1\": 123, \"Signal_2\": 0}\n\n# Encode signal values through converters\nmessage = frame.encode({\"MotorRPM\": 100, \"FanState\": \"ON\"})\nprint(binascii.hexlify(message))\n>>> 0xFE01\n```\n\nMore examples can be found in the [examples directory](./examples).\n\n---\n\n## Documentation\n\nDocumentation is published to [Github Pages](https://c4deszes.github.io/ldfparser/).\n\n---\n\n## Features\n\n+ Semantic validation of LDF files\n\n+ Retrieve header information (version, baudrate)\n\n+ Retrieve Signal and Frame information\n\n+ Retrieve Signal encoding types and use them to convert values\n\n+ Retrieve Node attributes\n\n+ Retrieve schedule table information\n\n+ Command Line Interface\n\n+ Capturing comments\n\n+ Encode and decode standard diagnostic frames\n\n+ Saving LDF object as an `.ldf` file (experimental)\n\n### Known issues / missing features\n\n+ Certain parsing related errors are unintuitive\n\n+ Checksum calculation for frames\n\n+ Token information is not preserved\n\n---\n\n## Development\n\nInstall the library locally by running `pip install -e .[dev]`\n\n[Pytest](https://pytest.org/) is used for testing, to execute all tests run `pytest -m 'not snapshot'`\n\n[Flake8](https://flake8.pycqa.org/en/latest/) is used for linting, run `flake8` to print out all linting errors.\n\n---\n\n## Contributors\n\n[@c4deszes](https://github.com/c4deszes) (Author)\n\n---\n\n## Credits\n\nInspired by [uCAN-LIN LinUSBConverter](https://github.com/uCAN-LIN/LinUSBConverter), specifically the LDF parsing mechanism via [Lark](https://github.com/lark-parser/lark). Previously the library included most of the lark file, parsing code and examples, since 0.5.0 they've been completely rewritten to better accomodate the different LIN standards.\n\n---\n\n## License\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT)\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "LDF Language support for Python",
    "version": "0.25.0",
    "project_urls": {
        "Documentation": "https://c4deszes.github.io/ldfparser/",
        "Homepage": "https://github.com/c4deszes/ldfparser",
        "Source Code": "https://github.com/c4deszes/ldfparser"
    },
    "split_keywords": [
        "lin",
        " ldf"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "964dfde9fce1e08b19cdc184a678bd09ae2aa5f381939ebf1cc64ab2bfcfb24c",
                "md5": "27c20f1fccc83e64a658d2e5c6b4525d",
                "sha256": "f557083bad5bb7c916c082cbfa3ef725386a25d023c07bee7044e583681fdba9"
            },
            "downloads": -1,
            "filename": "ldfparser-0.25.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "27c20f1fccc83e64a658d2e5c6b4525d",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,<4",
            "size": 31978,
            "upload_time": "2024-04-28T09:25:11",
            "upload_time_iso_8601": "2024-04-28T09:25:11.502737Z",
            "url": "https://files.pythonhosted.org/packages/96/4d/fde9fce1e08b19cdc184a678bd09ae2aa5f381939ebf1cc64ab2bfcfb24c/ldfparser-0.25.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "933aed6d13cb1c5e4c6f03084c3ad1236167cdf10dd5546239e594bc3147b9c3",
                "md5": "db98d7141247aca5df060635d260a38c",
                "sha256": "268f8435c4b695ac4d2356a0f70e8ebbaa4e3fa3e4ffcbb6ed1ec971a65410f5"
            },
            "downloads": -1,
            "filename": "ldfparser-0.25.0.tar.gz",
            "has_sig": false,
            "md5_digest": "db98d7141247aca5df060635d260a38c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,<4",
            "size": 28845,
            "upload_time": "2024-04-28T09:25:13",
            "upload_time_iso_8601": "2024-04-28T09:25:13.347827Z",
            "url": "https://files.pythonhosted.org/packages/93/3a/ed6d13cb1c5e4c6f03084c3ad1236167cdf10dd5546239e594bc3147b9c3/ldfparser-0.25.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-28 09:25:13",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "c4deszes",
    "github_project": "ldfparser",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ldfparser"
}
        
Elapsed time: 0.22771s