Oakrey.LDF 5.0.0

dotnet add package Oakrey.LDF --version 5.0.0
                    
NuGet\Install-Package Oakrey.LDF -Version 5.0.0
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Oakrey.LDF" Version="5.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.LDF" Version="5.0.0" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.LDF" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Oakrey.LDF --version 5.0.0
                    
#r "nuget: Oakrey.LDF, 5.0.0"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Oakrey.LDF@5.0.0
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Oakrey.LDF&version=5.0.0
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.LDF&version=5.0.0
                    
Install as a Cake Tool

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 ILdfExportable and serialises itself to a StringBuilder.
  • LdfMatrix.Export() composes a complete, spec-compliant LDF text file including signal representation bindings.

Error handling

  • LdfParserException exposes the original LdfLine (text and 1-based line number) for precise diagnostics.
  • SignalEncodingType.Min and Max enforce the range [0, 65535] and throw ArgumentOutOfRangeException on 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.0
  • Oakrey.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))}");
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}]");
    }
}
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.AllFrames returns both standard and diagnostic frames as IEnumerable<IFrame>.
  • LdfMatrix.AllNodes returns the master and all slaves as IReadOnlyList<INode>.
  • LdfParserException is constructable only by the parser and carries the original LdfLine with its 1-based line number for error reporting.
  • SignalEncodingType.Min and Max validate against [0, 65535] on set and throw ArgumentOutOfRangeException for 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

License

This project is licensed under the MIT License.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

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.

Version Downloads Last Updated
5.0.0 59 11/13/2026
4.0.1 189 9/18/2026
4.0.0 210 8/7/2026
3.2.4 157 8/3/2026
3.2.3 194 5/22/2026
3.2.1 166 5/15/2026
3.2.0 171 3/17/2026
3.1.0 159 3/17/2026
3.0.0 150 3/13/2026
2.0.0 180 2/2/2026
1.0.0 355 4/22/2025