Oakrey.Peak.Lin.Wrapper 2.0.2

dotnet add package Oakrey.Peak.Lin.Wrapper --version 2.0.2
                    
NuGet\Install-Package Oakrey.Peak.Lin.Wrapper -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.Wrapper" 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.Wrapper" Version="2.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Oakrey.Peak.Lin.Wrapper" />
                    
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.Wrapper --version 2.0.2
                    
#r "nuget: Oakrey.Peak.Lin.Wrapper, 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.Wrapper@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.Wrapper&version=2.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Oakrey.Peak.Lin.Wrapper&version=2.0.2
                    
Install as a Cake Tool

Oakrey.Peak.Lin.Wrapper

A .NET 10 library providing a managed, high-level interface over the Peak PLIN API. It covers LIN master and slave communication, frame scheduling, hardware and client management, message filtering, keep-alive, logging, checksum calculation, and hardware discovery for Peak LIN hardware on Windows.

Main Features

  • Initialize hardware in master or slave mode (InitializeHardware, HardwareOperationMode)
  • Connect and disconnect clients to hardware handles (Connect, Disconnect)
  • Register client as application (RegisterClient, UnregisterClient)
  • Send LIN messages (Write, WriteMulti)
  • Receive single or batched LIN messages (Read, ReadAll, ReadMulti)
  • Keep-alive frame management (StartKeepAlive, SuspendKeepAlive, ResumeKeepAlive)
  • Frame scheduling: set, get, delete, start, stop, resume schedules, set breakpoints (SetSchedule, GetSchedule, StartSchedule, StopSchedule, DeleteSchedule, up to 7 schedules / 256 slots)
  • Frame entry and response remap configuration (GetFrameEntry, GetResponseRemap, RegisterFrameId)
  • Hardware discovery and channel enumeration (GetAvailableHardware, GetAvailableHardwareHandles)
  • Hardware status, baud rate, bus state, and target time queries (GetStatus, GetBaudRate, GetTargetTime)
  • Client-level logging: enable/disable, configure log type and path (EnableLogging, DisableLogging, GetLogConfiguration)
  • Message filter configuration per client/hardware pair (GetFilter)
  • Checksum calculation and PID computation (CalculateCheckSum, GetPID)
  • Version and API information (GetApiVersion, GetVersionInfo)
  • Typed exception on error (PeakLinException) with ErrorCode enumeration

Architecture / Project Structure

PeakLinWrapper/
  PeakLinWrapper.cs              - Core: RegisterClient, CalculateCheckSum, PID, logging, status frames
  PeakLinWrapper.Client.cs       - Hardware init, connect/disconnect, frame entry, remap, status, filter
  PeakLinWrapper.Messages.cs     - Read, ReadAll, ReadMulti, Write, WriteMulti, keep-alive
  PeakLinWrapper.Hardware.cs     - Hardware discovery, channel info, baud rate, bus state, boss client
  PeakLinWrapper.Scheduler.cs    - Schedule management (set/get/start/stop/delete/resume/breakpoint)
  Helpers.cs                     - Shared parameter helpers (GetParameter, GetIntParameter, SetParameter)
  DataTypes/                     - MessageToSent, ReceivedMessage, FrameEntry, FrameInfo, ScheduleSlot,
                                   ScheduleState, HardwareStatus, HardwareOperationMode, BusState,
                                   ChannelInformation, ErrorCode, PeakVersion, LogSettings, ...
  NativeMethods/                 - P/Invoke wrappers (PeakLinNativeMethods.*), PeakLINConstants
  PeakLinException.cs            - Exception type wrapping ErrorCode

The public API is a single static partial class PeakLinWrapper split across partial files by concern. All methods throw PeakLinException on non-NoError status codes.

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

    App --> 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 PeakLinWrapper
dotnet build

Installation

Via .NET CLI:

dotnet add package Oakrey.Peak.Lin.Wrapper

Via Package Manager Console:

Install-Package Oakrey.Peak.Lin.Wrapper

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

Example Usage

Initialize hardware and connect a client

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

byte clientHandle = PeakLinWrapper.RegisterClient("MyApp", 0);
ushort hardwareHandle = PeakLinWrapper.GetAvailableHardwareHandles()[0];

PeakLinWrapper.Connect(clientHandle, hardwareHandle);
PeakLinWrapper.InitializeHardware(clientHandle, hardwareHandle, HardwareOperationMode.Master, 19200);

Send and receive messages

var msg = new MessageToSent { FrameId = 0x10, Length = 4, Data = new byte[] { 0x01, 0x02, 0x03, 0x04 } };
PeakLinWrapper.Write(clientHandle, hardwareHandle, msg);

List<ReceivedMessage> received = PeakLinWrapper.ReadAll(clientHandle);

Schedule management

var slots = new List<ScheduleSlot>
{
    new ScheduleSlot { FrameId = 0x10, Delay = 10 },
    new ScheduleSlot { FrameId = 0x11, Delay = 10 },
};
PeakLinWrapper.SetSchedule(clientHandle, hardwareHandle, scheduleIndex: 0, slots);
PeakLinWrapper.StartSchedule(clientHandle, hardwareHandle, scheduleIndex: 0);

Keep-alive

PeakLinWrapper.StartKeepAlive(clientHandle, hardwareHandle, frameId: 0x3C, period: 100);
PeakLinWrapper.SuspendKeepAlive(clientHandle, hardwareHandle);
PeakLinWrapper.ResumeKeepAlive(clientHandle, hardwareHandle);

Logging

PeakLinWrapper.EnableLogging(clientHandle);
PeakLinWrapper.SetLogConfiguration(clientHandle, LogSettings.LogAllMessages);

Cleanup

PeakLinWrapper.Disconnect(clientHandle, hardwareHandle);
PeakLinWrapper.UnregisterClient(clientHandle);

Development Notes

  • The library uses unsafe code blocks for native struct interop.
  • Nullable reference types are enabled throughout.
  • All public methods throw PeakLinException on error. Use ErrorCode to inspect the specific failure.
  • Hardware baud rate is validated in code to the range 1000-20000 baud.
  • Client handles are byte; hardware handles are ushort, matching the PLIN API convention.
  • Up to 7 schedules and 256 slots per schedule are supported.

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 list of supported Peak LIN hardware models (USB, PCIe, etc.).
  • Whether RegisterClient requires a window handle (HWND) for event notifications and how that maps on headless/service scenarios.
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.
  • net10.0

    • No dependencies.

NuGet packages (1)

Showing the top 1 NuGet packages that depend on Oakrey.Peak.Lin.Wrapper:

Package Downloads
Oakrey.Peak.Lin.Driver

A .NET 10 high-level LIN driver built on Oakrey.Peak.Lin.Wrapper. Exposes IPeakLinClient and ISlaveClient with Rx observable streams for received messages and bus state changes. Supports master and slave operation modes, timer-based polling, frame publisher/subscriber configuration, and hardware discovery for Peak LIN hardware on Windows.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
2.0.2 90 5/14/2026
2.0.1 151 2/2/2026
2.0.0 305 11/14/2025
1.0.0 335 4/17/2025