Oakrey.Peak.Lin.Driver 2.0.2

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

Oakrey.Peak.Lin.Driver

A .NET 10 high-level LIN driver built on top of Oakrey.Peak.Lin.Wrapper. Exposes three concrete client types - MasterClient, SlaveClient, and SchedulerClient - each backed by Rx observable streams for received data and bus state changes. Targets Peak LIN hardware on Windows.

Main Features

  • Three ready-to-use client implementations behind clean interfaces:
    • IMasterClient / MasterClient - LIN master role: send publisher/subscriber messages with automatic PID and checksum calculation
    • ISlaveClient / SlaveClient - LIN slave role: configure frame publisher/subscriber entries, enable/disable individual frames
    • ISchedulerClient / SchedulerClient - LIN scheduler mode: add/remove/start/stop frame request schedules
  • Shared base behavior via LinClientBase and IPeakLinClient: initialize, uninitialize, start/stop timer-based polling, get status, get baud rate, set filter, identify hardware
  • Rx observable streams on all clients:
    • IObservable<PeakLinMessage> ReceivedData - incoming messages
    • IObservable<BusState> BusStateChanged - bus state transitions
    • IObservable<PeakLinMessage> SentData (master) - outgoing messages
    • IObservable<PeakLinMessage> Response (slave) - slave responses
  • PeakLinMessage value type carrying Id, Data, TimeStamp, SerialNumber, ChannelNumber
  • Static hardware discovery: GetAvailableHardware(), GetAllChannelsInfo()
  • Baud rate range enforced at initialization (1000-20000)
  • PID calculation and enhanced/classic checksum support

Architecture / Project Structure

PeakLin/
  IPeakLinClient.cs       - Base interface: Initialize, StartRead, StopRead, Uninitialize, ReceivedData, BusStateChanged
  LinClientBase.cs        - Abstract base class implementing IPeakLinClient, timer-based polling loop
  IMasterClient.cs        - Master interface: SendData, WritePublisherMessage, WriteSubscriberMessage
  MasterClient.cs         - Master implementation with SentData observable
  ISlaveClient.cs         - Slave interface: SetFramePublisher, SetFrameSubscriber, DisableFrame, DisableAllFrames
  SlaveClient.cs          - Slave implementation with Response observable, frame entry management
  ISchedulerClient.cs     - Scheduler interface: AddRequest, RemoveRequest, ClearAllRequests, StartSchedule, StopSchedule
  SchedulerClient.cs      - Scheduler implementation (HardwareOperationMode.Scheduler), single schedule slot list
  PeakLinMessage.cs       - Message record: Id (max 63), Data, TimeStamp, SerialNumber, ChannelNumber
  BusState.cs             - Bus state enumeration

Dependencies:

graph TD
    App["Your Application"]
    Driver["Oakrey.Peak.Lin.Driver\n(MasterClient / SlaveClient / SchedulerClient)"]
    Wrapper["Oakrey.Peak.Lin.Wrapper\n(static PeakLinWrapper API)"]
    Native["PeakLinNativeMethods (P/Invoke)"]
    PLIN["plinapi.dll (Peak PLIN Driver)"]
    HW["Peak LIN Hardware"]

    App --> Driver
    Driver --> Wrapper
    Wrapper --> Native
    Native --> PLIN
    PLIN --> HW

Requirements

  • .NET 10.0 or higher
  • Windows OS
  • Peak PLIN driver installed (plinapi.dll must be present)
  • Physical Peak LIN device

Build Instructions

git clone https://dev.azure.com/oakrey/OpenPackages/_git/Drivers
cd PeakLin
dotnet build

Installation

Via .NET CLI:

dotnet add package Oakrey.Peak.Lin.Driver

Via Package Manager Console:

Install-Package Oakrey.Peak.Lin.Driver

Via NuGet Package Manager in Visual Studio: search for Oakrey.Peak.Lin.Driver.

Example Usage

Discover available hardware

using Oakrey.Peak.Lin;
using Oakrey.Peak.Lin.Wrapper.DataTypes;

ChannelInformation[] channels = LinClientBase.GetAllChannelsInfo();
ChannelInformation channel = channels[0];

Master client - send messages and observe received data

IMasterClient master = MasterClient.Create(channel, "MyMaster", readPeriodMillis: 10);

master.ReceivedData.Subscribe(msg =>
    Console.WriteLine($"RX: id=0x{msg.Id:X2} data=[{string.Join(",", msg.Data)}]"));

master.BusStateChanged.Subscribe(state =>
    Console.WriteLine($"Bus state: {state}"));

master.Initialize(19200);
master.StartRead();

// Send a subscriber request (master requests data from a slave)
master.SendData(id: 0x10, data: new byte[8], enhancedChecksum: true);

master.StopRead();
master.Uninitialize();

Slave client - configure frame entries and observe responses

ISlaveClient slave = SlaveClient.Create(channel, "MySlave", readPeriodMillis: 10);

slave.ReceivedData.Subscribe(msg =>
    Console.WriteLine($"Slave RX: id=0x{msg.Id:X2}"));

slave.Initialize(19200);
slave.StartRead();

// Publish data for frame 0x10
slave.SetFramePublisher(id: 0x10, data: new byte[] { 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 }, enhancedChecksum: true);

// Subscribe to receive data on frame 0x11
slave.SetFrameSubscriber(id: 0x11, data: new byte[8], enhancedChecksum: true);

slave.StopRead();
slave.Uninitialize();

Scheduler client - schedule periodic frame requests

ISchedulerClient scheduler = SchedulerClient.Create(channel, "MyScheduler", readPeriodMillis: 10);

scheduler.ReceivedData.Subscribe(msg =>
    Console.WriteLine($"Scheduled RX: id=0x{msg.Id:X2}"));

scheduler.Initialize(19200);
scheduler.StartRead();

scheduler.AddRequest(id: 0x10, delay: 10);
scheduler.AddRequest(id: 0x11, delay: 20);
scheduler.StartSchedule();

// ...

scheduler.StopSchedule();
scheduler.StopRead();
scheduler.Uninitialize();

Development Notes

  • PID bytes are computed automatically from the raw frame ID in MasterClient.
  • Checksum type (enhanced or classic) must match the slave device configuration.
  • PeakLinMessage.Id is masked to 6 bits; maximum valid value is 63 (0x3F).
  • SchedulerClient throws PeakLinException if AddRequest or RemoveRequest is called while the schedule is running.
  • All clients implement IDisposable; always dispose or call Uninitialize to release the hardware handle.
  • Timer-based polling period is set at construction time and cannot be changed afterwards.

License

MIT License Copyright (c) Oakrey 2016-2025


Open Questions

  • Whether plinapi.dll redistribution is allowed or must be installed separately as part of the Peak driver package.
  • Exact supported hardware models (USB, PCIe, etc.) and whether virtual channels are supported.
  • Whether multiple SchedulerClient instances can share one hardware handle concurrently.
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
2.0.2 35 5/22/2026
2.0.1 157 2/2/2026
2.0.0 310 11/14/2025
1.1.0 273 6/18/2025
1.0.0 296 4/17/2025