Package: ldfparser
LDF ParserThis 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.DisclaimersThe 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 thechangelogand on theGithub releases page.The tool has been written according the LIN standards1.3,2.0,2.1and2.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.The LIN standard is now known asISO 17987which
clears up some of the confusing parts in the 2.2A specification. Since this new standard is not
freely availablethis 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.InstallationYou can install this library from PyPI using pip.pipinstallldfparserExamplesimportldfparserimportbinascii# Load LDFldf=ldfparser.parse_ldf(path="network.ldf")frame=ldf.get_unconditional_frame('Frame_1')# Get baudrate from LDFprint(ldf.get_baudrate())# Encode signal values into framemessage=frame.encode_raw({"Signal_1":123,"Signal_2":0})print(binascii.hexlify(message))>>>0x7B00# Decode message into dictionary of signal names and valuesreceived=bytearray([0x7B,0x00])print(frame.decode(received))>>>{"Signal_1":123,"Signal_2":0}# Encode signal values through convertersmessage=frame.encode({"MotorRPM":100,"FanState":"ON"})print(binascii.hexlify(message))>>>0xFE01More examples can be found in theexamples directory.DocumentationDocumentation is published toGithub Pages.FeaturesSemantic validation of LDF filesRetrieve header information (version, baudrate)Retrieve Signal and Frame informationRetrieve Signal encoding types and use them to convert valuesRetrieve Node attributesRetrieve schedule table informationCommand Line InterfaceCapturing commentsEncode and decode standard diagnostic framesSaving LDF object as an.ldffile (experimental)Known issues / missing featuresCertain parsing related errors are unintuitiveChecksum calculation for framesToken information is not preservedDevelopmentInstall the library locally by runningpip install -e .[dev]Pytestis used for testing, to execute all tests runpytest -m 'not snapshot'Flake8is used for linting, runflake8to print out all linting errors.Contributors@c4deszes(Author)CreditsInspired byuCAN-LIN LinUSBConverter, specifically the LDF parsing mechanism viaLark. 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