LDF Language support for Python
Project description
LDF Parser
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
-
Command Line Interface
-
Capturing comments
Currently not supported
-
Scheduling table
-
Diagnostics
Installation
Install via pip install ldfparser
Contributors
@c4deszes (Author)
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for ldfparser-0.7.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | f2bcc73e182d05cf623f6b0fb953bf43450cb9ee782635c4f93a586863c3a797 |
|
MD5 | 9a1d74bf818b63285894120de1ed819d |
|
BLAKE2b-256 | 16bd1c94c34ac95ece8b15158d1f3ba996214adfb9e358846038effbbbd337ab |