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" />
<PackageReference Include="Oakrey.Peak.Lin.Driver" />
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
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#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
#tool nuget:?package=Oakrey.Peak.Lin.Driver&version=2.0.2
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
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 calculationISlaveClient/SlaveClient- LIN slave role: configure frame publisher/subscriber entries, enable/disable individual framesISchedulerClient/SchedulerClient- LIN scheduler mode: add/remove/start/stop frame request schedules
- Shared base behavior via
LinClientBaseandIPeakLinClient: 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 messagesIObservable<BusState> BusStateChanged- bus state transitionsIObservable<PeakLinMessage> SentData(master) - outgoing messagesIObservable<PeakLinMessage> Response(slave) - slave responses
PeakLinMessagevalue 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.dllmust 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.Idis masked to 6 bits; maximum valid value is 63 (0x3F).SchedulerClientthrowsPeakLinExceptionifAddRequestorRemoveRequestis called while the schedule is running.- All clients implement
IDisposable; always dispose or callUninitializeto 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.dllredistribution 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
SchedulerClientinstances can share one hardware handle concurrently.
| Product | Versions 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
- Oakrey.Peak.Lin.Wrapper (>= 2.0.2)
- Oakrey.Reflection (>= 2.0.1)
- System.Reactive (>= 6.1.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.