Skip to main content

LDF Language support for Python

Project description

LDF Parser

Workflow PyPI version codecov.io License

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.


Disclaimer

The tool has been written according the LIN standards 1.3, 2.0, 2.1 and 2.2A, 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.

Since the LDF usually contains sensitive information try to provide either an anonymized version with signals and frames obfuscated or just the relevant segments in an example LDF.


Example

import ldfparser

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

# Get baudrate from LDF
print(ldf.baudrate)

# Encode signal values into frame
message = frame.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.parse(received))
# >> {"Signal_1": 123, "Signal_2": 0}

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

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

Currently not supported

  • Scheduling table

  • Diagnostics


Installation

Install via pip install ldfparser


Credits

Inspired by uCAN-LIN LinUSBConverter, specifically the LDF parsing mechanism via 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

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

ldfparser-0.5.0.tar.gz (11.9 kB view details)

Uploaded Source

Built Distributions

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

ldfparser-0.5.0-py3.6.egg (33.7 kB view details)

Uploaded Egg

ldfparser-0.5.0-py3-none-any.whl (15.3 kB view details)

Uploaded Python 3

File details

Details for the file ldfparser-0.5.0.tar.gz.

File metadata

  • Download URL: ldfparser-0.5.0.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.12

File hashes

Hashes for ldfparser-0.5.0.tar.gz
Algorithm Hash digest
SHA256 eccd0af6db483d0a1baae7c88537984877699164336f0cdae5b4d5a6816a76b0
MD5 e48f8f4b5d48ade5da6543f0c76491bd
BLAKE2b-256 bd367a4465a03b62fc8a67efe798096c17fa9e6e6af3114bf751507b5088e9b8

See more details on using hashes here.

File details

Details for the file ldfparser-0.5.0-py3.6.egg.

File metadata

  • Download URL: ldfparser-0.5.0-py3.6.egg
  • Upload date:
  • Size: 33.7 kB
  • Tags: Egg
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.12

File hashes

Hashes for ldfparser-0.5.0-py3.6.egg
Algorithm Hash digest
SHA256 a27d2a3b6287d89354da78148f1a3a1b4b607becb31652c67644bc73c00c29ec
MD5 9e5b19bf3437cfcd7d817512e97b613f
BLAKE2b-256 eeb5e86def112a0e1798a991580df684dc29365a96f1f72df3cd77ca3a3fd2fc

See more details on using hashes here.

File details

Details for the file ldfparser-0.5.0-py3-none-any.whl.

File metadata

  • Download URL: ldfparser-0.5.0-py3-none-any.whl
  • Upload date:
  • Size: 15.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/40.6.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.6.12

File hashes

Hashes for ldfparser-0.5.0-py3-none-any.whl
Algorithm Hash digest
SHA256 105ecd4aae43e0ee9bd3f8285858cbf60d4149a8537701ab03a781bef1f24a6e
MD5 6ddbbd3ae953f329c8d7bb538949ee72
BLAKE2b-256 a57d3a6d55d26bfb1bab5452fbc790cc66d71c1ad3edff7f835ab747f8ebd382

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