Skip to main content

LDF Language support for Python

Project description

LDF Parser

Workflow 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.


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

Currently not supported

  • Signals longer than 16 bits

  • Ascii and BCD signal values

  • Node attributes

  • Scheduling table

  • Diagnostics


Installation

Install via pip install ldfparser


Credits

Inspired by uCAN-LIN LinUSBConverter, specifically the LDF parsing mechanism via Lark


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.3.1.tar.gz (8.0 kB view hashes)

Uploaded Source

Built Distributions

ldfparser-0.3.1-py3.6.egg (18.6 kB view hashes)

Uploaded Source

ldfparser-0.3.1-py3-none-any.whl (10.5 kB view hashes)

Uploaded Python 3

Supported by

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