Oakrey.Vector.Lin 4.0.4

dotnet add package Oakrey.Vector.Lin --version 4.0.4
                    
NuGet\Install-Package Oakrey.Vector.Lin -Version 4.0.4
                    
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.Vector.Lin" Version="4.0.4" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Oakrey.Vector.Lin" Version="4.0.4" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Vector.Lin" />
                    
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.Vector.Lin --version 4.0.4
                    
#r "nuget: Oakrey.Vector.Lin, 4.0.4"
                    
#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.Vector.Lin@4.0.4
                    
#: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.Vector.Lin&version=4.0.4
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Vector.Lin&version=4.0.4
                    
Install as a Cake Tool

Oakrey.Vector.Lin

LIN master and slave client library for Vector hardware (XL Driver Library). Built on Oakrey.Vector.Base and Oakrey.Vector.Wrapper, it provides VectorLinClient and VectorLinChannel with IObservable message streams (Rx.NET), a slave answer table, a software LIN scheduler, master request sending, and per-channel LinConfig.

Main features

  • Static factory creation - VectorLinClient.Create(serialNumber, appName) discovers all LIN channels on the target device and initializes each one automatically (opens the port and applies the default LinConfig).
  • Slave answer table - AddSlaveAnswer registers a VectorFrame as a slave response for a given LIN ID. RemoveSlaveAnswer and ClearAllAnswers manage the table at runtime; removing an answer reopens and reconfigures the port transparently.
  • LIN scheduler - AddSchedulerRequest queues frames for cyclic master transmission. StartSchedule / StopSchedule run the scheduler on a background Task with per-frame Delay (milliseconds) between header requests. ClearSchedule empties the queue and stops the scheduler.
  • Master requests - SendMasterRequest issues a single LIN header request on demand, independent of the scheduler.
  • Per-channel configuration - ConfigureChannel(channelNumber, LinConfig) applies a new LinConfig (baud rate, master/slave mode, etc.) at runtime. Changing the mode resets the DLC table and frame list.
  • Rx.NET observable streams - IVectorLinClient.ReceivedData exposes an IObservable<ReceivedLinMessage> that merges frames from all channels. Subscribe using standard Rx operators.
  • Enable / disable lifecycle - EnableChannel / DisableChannel control hardware activation without closing or reinitializing the port.
  • VectorFrame data type - carries LIN frame ID, data bytes, DLC, enhanced-checksum flag, and inter-frame delay for scheduler use. A copy constructor (GetCopy) is provided to avoid shared-state bugs when the scheduler iterates queued frames.

Architecture

classDiagram
    direction TB

    class IVectorLinClient {
        <<interface>>
        +IObservable~ReceivedLinMessage~ ReceivedData
        +uint SerialNumber
        +AddSlaveAnswer(byte channelNumber, VectorFrame frame)
        +AddSchedulerRequest(byte channelNumber, VectorFrame frame)
        +ClearAllAnswers(byte channelNumber)
        +ClearSchedule(byte channelNumber)
        +ConfigureChannel(byte channelNumber, LinConfig config)
        +RemoveSlaveAnswer(byte channelNumber, byte id)
        +SendMasterRequest(byte channelNumber, VectorFrame frame)
        +StartSchedule(byte channelNumber)
        +StopSchedule(byte channelNumber)
        +EnableChannel(byte channelNumber)
        +DisableChannel(byte channelNumber)
    }

    class IVectorLinChannel {
        <<interface>>
        +IObservable~ReceivedLinMessage~ ReceivedData
        +byte ChannelNumber
        +AddSlaveAnswer(VectorFrame frame)
        +AddSchedulerRequest(VectorFrame frame)
        +ClearAllAnswers()
        +ClearSchedule()
        +Configure(LinConfig config)
        +RemoveSlaveAnswer(byte id)
        +SendMasterRequest(VectorFrame frame)
        +StartSchedule()
        +StopSchedule()
    }

    class VectorLinClient {
        +Create(uint serialNumber, string appName) IVectorLinClient$
    }

    class VectorLinChannel {
        -byte[] dlcs
        -List~VectorFrame~ frames
        -LinConfig currentLinConfig
    }

    class VectorFrame {
        +byte Id
        +byte[] Data
        +byte Dlc
        +bool EnhancedChecksum
        +ushort Delay
        +GetCopy(VectorFrame) VectorFrame$
    }

    IVectorLinClient <|.. VectorLinClient
    IVectorLinChannel <|.. VectorLinChannel
    VectorLinClient o-- VectorLinChannel
    VectorLinChannel ..> VectorFrame

VectorLinClient extends VectorClientBase from Oakrey.Vector.Base. VectorLinChannel extends VectorChannelBase from Oakrey.Vector.Base.

Requirements

  • .NET 10 or higher
  • Vector XL Driver Library installed on the host machine
  • Oakrey.Vector.Base and Oakrey.Vector.Wrapper (pulled automatically as transitive dependencies)

Build instructions

dotnet build VectorLin/VectorLin.csproj

To produce a NuGet package:

dotnet pack VectorLin/VectorLin.csproj -c Release

Installation

.NET CLI

dotnet add package Oakrey.Vector.Lin

Package Manager Console

Install-Package Oakrey.Vector.Lin

Configuration

LinConfig (from Oakrey.Vector.Wrapper) controls the channel operating mode and baud rate. LinConfig.GetDefault() is applied automatically at channel construction; call ConfigureChannel to override it at any point after creation.

LinConfig config = LinConfig.GetDefault(); // adjust baud rate, master/slave mode, etc.
client.ConfigureChannel(channelNumber: 1, config);

Changing LinConfig.Mode resets the DLC table and clears all queued frames for that channel.

Example usage

Receive LIN frames

using IVectorLinClient client = VectorLinClient.Create(serialNumber: 12345, appName: "MyApp");

using IDisposable subscription = client.ReceivedData
    .Subscribe(msg => Console.WriteLine($"LIN id=0x{msg.Id:X2} data={BitConverter.ToString(msg.Data)}"));

client.EnableChannel(channelNumber: 1);
Console.ReadLine();
client.DisableChannel(channelNumber: 1);

Send a master request

using IVectorLinClient client = VectorLinClient.Create(serialNumber: 12345, appName: "MyApp");
client.EnableChannel(channelNumber: 1);

VectorFrame request = new VectorFrame(id: 0x10, dlc: 8, enhancedChecksum: false, delay: 0);
client.SendMasterRequest(channelNumber: 1, request);

Register slave answers

using IVectorLinClient client = VectorLinClient.Create(serialNumber: 12345, appName: "MyApp");
client.EnableChannel(channelNumber: 1);

VectorFrame answer = new VectorFrame(id: 0x20, data: [0xAA, 0xBB, 0xCC, 0xDD], enhancedChecksum: true, delay: 0);
client.AddSlaveAnswer(channelNumber: 1, answer);

// Remove one answer at runtime
client.RemoveSlaveAnswer(channelNumber: 1, id: 0x20);

// Clear all answers
client.ClearAllAnswers(channelNumber: 1);

Run the LIN scheduler

using IVectorLinClient client = VectorLinClient.Create(serialNumber: 12345, appName: "MyApp");
client.EnableChannel(channelNumber: 1);

// Queue frames; Delay is the pause in ms after each header request
client.AddSchedulerRequest(channelNumber: 1, new VectorFrame(id: 0x01, dlc: 2, enhancedChecksum: false, delay: 10));
client.AddSchedulerRequest(channelNumber: 1, new VectorFrame(id: 0x02, dlc: 4, enhancedChecksum: false, delay: 20));

client.StartSchedule(channelNumber: 1);
Console.ReadLine();
client.StopSchedule(channelNumber: 1);

Development notes

  • VectorLinClient has a private constructor; always use VectorLinClient.Create(...) which returns IVectorLinClient for easy mocking and dependency injection.
  • The channel port is opened and configured automatically during VectorLinClient construction. There is no separate Init step unlike VectorCanChannel.
  • The scheduler runs on a background Task and iterates a snapshot (GetCopy) of the frame list taken at StartSchedule time. Changes to the frame list after StartSchedule are not reflected until the scheduler is restarted.
  • ClearAllAnswers reopens and reconfigures the port to flush slave registrations from the driver; expect a brief interruption on the bus.
  • The RX queue size is 256 events per channel.

License

MIT - Copyright (c) Oakrey 2016-present. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
4.0.4 100 5/22/2026
4.0.3 103 5/14/2026
4.0.2 149 2/2/2026
4.0.1 127 1/6/2026
4.0.0 227 11/25/2025
3.0.0 294 11/14/2025
2.0.0 246 7/8/2025
1.1.0 252 6/18/2025
1.0.1 232 6/4/2025
1.0.0 290 4/17/2025