Oakrey.LDF
5.0.0
dotnet add package Oakrey.LDF --version 5.0.0
NuGet\Install-Package Oakrey.LDF -Version 5.0.0
<PackageReference Include="Oakrey.LDF" Version="5.0.0" />
<PackageVersion Include="Oakrey.LDF" Version="5.0.0" />
<PackageReference Include="Oakrey.LDF" />
paket add Oakrey.LDF --version 5.0.0
#r "nuget: Oakrey.LDF, 5.0.0"
#:package Oakrey.LDF@5.0.0
#addin nuget:?package=Oakrey.LDF&version=5.0.0
#tool nuget:?package=Oakrey.LDF&version=5.0.0
Oakrey.LDF
Overview
Oakrey.LDF is a .NET 11 class library for parsing, modelling, and exporting LIN Description Files (LDF)
according to the LIN 2.x specification. Unsupported top-level LIN clauses are rejected explicitly instead of
being silently ignored.
It produces a strongly-typed LdfMatrix object graph covering nodes, signals, frames, schedule tables,
signal encoding types, and diagnostic elements.
The same model can be serialised back to a valid LDF text file via the built-in composer.
Main Features
Async parsing
LdfMatrix.CreateAsync(FileInfo, CancellationToken)reads and parses an LDF file asynchronously.- Parsing is cancellable at any line boundary.
- Parse errors are reported via
LdfParserException, which carries the offending line number and text. - C/C++ comments are accepted anywhere, and multiple LDF statements may share one physical line.
- Decimal and hexadecimal integers, byte-array initial values, fractional schedule delays, and multiple physical encoding ranges are supported using culture-independent conversion.
- Input is limited to 32 MiB to avoid unbounded memory consumption from untrusted files.
Full LDF object model
| Type | Description |
|---|---|
MasterNode |
Name, time base (ms), and jitter (ms). |
Node |
Slave node with NAD, product ID, protocol version, timing parameters, response error signal, and configurable frames. |
Signal |
Bit size, initial value, publisher node, subscriber nodes, and optional SignalEncodingType binding. |
DiagnosticSignal |
Counterpart of Signal used in diagnostic frames. |
Frame |
Identifier (0-59), publisher node, response length (1-8 bytes), and positioned signals. |
DiagnosticFrame |
Same structure as Frame for diagnostic traffic. |
ConfigurableFrame |
Frame variant associated with a configurable node address. |
ScheduleTable |
Ordered list of frame requests each with a millisecond delay. |
SignalEncodingType |
Named encoding with Min/Max range and a list of ILogicalValue entries. |
LDF export / compose
- Every model type implements
ILdfExportableand serialises itself to aStringBuilder. LdfMatrix.Export()composes a complete, spec-compliant LDF text file including signal representation bindings.
Error handling
LdfParserExceptionexposes the originalLdfLine(text and 1-based line number) for precise diagnostics.SignalEncodingType.MinandMaxenforce the range[0, 65535]and throwArgumentOutOfRangeExceptionon invalid assignment.
Semantic diagnostics
Syntactically valid files are loaded even when they contain suspicious or inconsistent model data. Findings are
available through LdfMatrix.Diagnostics; calling Validate() recalculates them after programmatic model changes.
Every diagnostic contains a stable code, severity, message, and model location.
LdfMatrix matrix = await LdfMatrix.CreateAsync(file, cancellationToken);
foreach (LdfDiagnostic diagnostic in matrix.Diagnostics)
{
Console.WriteLine($"{diagnostic.Severity} {diagnostic.Code} at {diagnostic.Location}: {diagnostic.Message}");
}
Diagnostics cover unused signals and encodings, unscheduled or empty frames, incomplete configurable_frames,
unmapped response-error signals, insufficient schedule delays, encoding values outside signal width, and
overlapping physical encoding ranges. Syntax and structural violations that prevent a reliable object model still
raise LdfParserException.
In the LDF.Demo application, enter the ldf menu and use full --path <file.ldf> for a complete structured
model dump or diagnostics --path <file.ldf> for error-severity diagnostics only. The same verbs can be passed
directly when starting the application, for example dotnet run --project LDF.Demo -- diagnostics -p file.ldf.
Architecture
classDiagram
class LdfMatrix {
+MasterNode Master
+IReadOnlyList~Node~ Slaves
+IReadOnlyList~INode~ AllNodes
+IEnumerable~IFrame~ AllFrames
+IReadOnlyList~Signal~ Signals
+IReadOnlyList~DiagnosticSignal~ DiagnosticSignals
+IReadOnlyList~Frame~ Frames
+IReadOnlyList~DiagnosticFrame~ DiagnosticFrames
+IReadOnlyList~ScheduleTable~ ScheduleTables
+IReadOnlyList~SignalEncodingType~ SignalEncodings
+double SpeedKbps
+Version ProtocolVersion
+Version LanguageVersion
+CreateAsync(FileInfo, CancellationToken) LdfMatrix
+Export() string
}
class ILdfExportable {
<<interface>>
+Export(StringBuilder)
}
class Signal {
+int Size
+int InitValue
+INode Publisher
+IReadOnlyList~INode~ Subscribers
+SignalEncodingType? Encoding
}
class Frame {
+int Identifier
+int ResponseLength
+INode Publisher
+IReadOnlyList~PositionedSignal~ PositionedSignals
}
class ScheduleTable {
+string Name
+IReadOnlyList~ISchedule~ Schedules
}
class SignalEncodingType {
+string Name
+int Min
+int Max
+IReadOnlyList~ILogicalValue~ LogicalValues
}
class MasterNode {
+string Name
+double TimeBase
+double Jitter
}
class Node {
+string Name
+int ConfiguredNAD
+Version ProtocolVersion
+ISignal? ResponseError
+IReadOnlyList~IConfigurableFrame~ ConfigurableFrames
}
LdfMatrix --> MasterNode
LdfMatrix --> Node
LdfMatrix --> Signal
LdfMatrix --> Frame
LdfMatrix --> ScheduleTable
LdfMatrix --> SignalEncodingType
Signal ..|> ILdfExportable
Frame ..|> ILdfExportable
ScheduleTable ..|> ILdfExportable
SignalEncodingType ..|> ILdfExportable
MasterNode ..|> ILdfExportable
Node ..|> ILdfExportable
Requirements
- .NET 11 or higher
Oakrey.Collections>= 2.0.0Oakrey.Readers>= 3.0.0
Installation
.NET CLI
dotnet add package Oakrey.LDF
Package Manager Console
Install-Package Oakrey.LDF
NuGet Package Manager
Search for Oakrey.LDF under Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
Build
dotnet build
dotnet pack --configuration Release
Example Usage
Parse an LDF file
FileInfo file = new FileInfo("vehicle.ldf");
LdfMatrix matrix = await LdfMatrix.CreateAsync(file, CancellationToken.None);
Console.WriteLine($"LIN speed: {matrix.SpeedKbps} kbps");
Console.WriteLine($"Protocol version: {matrix.ProtocolVersion}");
Console.WriteLine($"Master: {matrix.Master.Name} timebase={matrix.Master.TimeBase} ms jitter={matrix.Master.Jitter} ms");
Console.WriteLine($"Slaves: {string.Join(", ", matrix.Slaves.Select(s => s.Name))}");
Navigate signals
foreach (Signal signal in matrix.Signals)
{
Console.WriteLine($"{signal.Name}: {signal.Size} bit, init={signal.InitValue}, publisher={signal.Publisher.Name}");
if (signal.Encoding is not null)
{
Console.WriteLine($" encoding: {signal.Encoding.Name} [{signal.Encoding.Min}..{signal.Encoding.Max}]");
}
}
Navigate frames
foreach (Frame frame in matrix.Frames)
{
Console.WriteLine($"Frame {frame.Name} (id={frame.Identifier}, {frame.ResponseLength} bytes, publisher={frame.Publisher.Name})");
foreach (PositionedSignal ps in frame.PositionedSignals)
{
Console.WriteLine($" {ps.Signal.Name} @ bit {ps.Position}");
}
}
Inspect schedule tables
foreach (ScheduleTable table in matrix.ScheduleTables)
{
Console.WriteLine($"Schedule: {table.Name}");
foreach (ISchedule entry in table.Schedules)
{
Console.WriteLine($" {entry.Request.Name} delay {entry.Delay} ms");
}
}
Inspect signal encoding types
foreach (SignalEncodingType encoding in matrix.SignalEncodings)
{
Console.WriteLine($"Encoding: {encoding.Name} [{encoding.Min}..{encoding.Max}]");
foreach (ILogicalValue lv in encoding.LogicalValues)
{
Console.WriteLine($" {lv}");
}
}
Export back to LDF text
string ldfContent = matrix.Export();
File.WriteAllText("output.ldf", ldfContent);
Development Notes
ILdfExportable.Export(StringBuilder)is the single extension point for serialisation. Implement it on custom types to participate in the compose pipeline.LdfMatrix.AllFramesreturns both standard and diagnostic frames asIEnumerable<IFrame>.LdfMatrix.AllNodesreturns the master and all slaves asIReadOnlyList<INode>.LdfParserExceptionis constructable only by the parser and carries the originalLdfLinewith its 1-based line number for error reporting.SignalEncodingType.MinandMaxvalidate against[0, 65535]on set and throwArgumentOutOfRangeExceptionfor out-of-range values.- Frame identifier valid range is 0-59; response length valid range is 1-8 bytes.
Violations are caught during parsing and reported as
LdfParserException.
Project Information
- Author: Oakrey
- License: MIT
- Repository: Azure DevOps
- Package page: oakrey.cz
License
This project is licensed under the MIT License.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Oakrey.Collections (>= 3.0.0)
- Oakrey.Readers (>= 5.0.0)
NuGet packages (2)
Showing the top 2 NuGet packages that depend on Oakrey.LDF:
| Package | Downloads |
|---|---|
|
Oakrey.Applications.FileParsing.LDF
Specialized file parsing library for LDF (LIN Description File) files. Built on FileParsing framework with automatic parsing into LdfMatrix objects, reactive updates, and extended file management. Features LIN frame/signal access, schedule tables, template support, and seamless integration with Oakrey.LDF parser. |
|
|
Oakrey.LDF.Values
Runtime value layer for LIN frames and signals built on top of Oakrey.LDF. Provides LdfSignalValue with INotifyPropertyChanged and physical value decoding via encoding offset and scale, and LdfTaskFrame for composing and parsing raw LIN message bytes across all positioned signals. |
GitHub repositories
This package is not used by any popular GitHub repositories.