Oakrey.Capsule.Lin 2.0.2

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

Oakrey.Capsule.Lin

Project overview

Oakrey.Capsule.Lin is a .NET 10 class library that encodes LIN bus data into the Oakrey Capsule binary framing protocol (v2). It provides strongly-typed capsule types for LIN data frames, channel information, and channel settings, together with supporting enumerations and a message factory. The library targets automotive, industrial, and IoT data-logging scenarios where LIN bus traffic must be captured and transmitted in a compact binary format.

Main features

  • LinDataCapsule (capsule ID 0x0201) � carries one or more LinMessage records in a single capsule. Supports multi-message batching via the LinStatus.MultiModeMessage flag and compact delta-timestamp encoding for subsequent messages.
  • LinChannelInfoCapsule (capsule ID 0x0200) � reports the current state of a LIN channel: status (Disabled, Ok, BusError), capability flags, maximum baud rate, and optional alias.
  • LinChannelSettingCapsule (capsule ID 0x0202) � carries the desired configuration for a LIN channel: operating mode, data baud rate, pull-up setting, and optional alias.
  • LinMessageFactory � creates LinMessage instances from raw binary payloads; handles both single-timestamp and delta-timestamp formats.
  • Full serialize / deserialize round-trip via CapsuleBase infrastructure.
  • Static GetRequestPayload() helpers on each capsule for generating query frames.

Architecture

classDiagram
    class CapsuleBase {
        +Serialize() byte[]
        +Head : CapsuleHead
    }

    class LinDataCapsule {
        +Id : ushort = 0x0201
        +ChannelIndex : byte
        +Flag : LinStatus
        +Messages : IList~LinMessage~
    }

    class LinChannelInfoCapsule {
        +Id : ushort = 0x0200
        +ChannelIndex : byte
        +Status : LinChannelStatus
        +Setting : LinChannelFlag
        +MaxBaudRate : ushort
        +Alias : string
    }

    class LinChannelSettingCapsule {
        +Id : ushort = 0x0202
        +ChannelIndex : byte
        +Setting : LinChannelSetting
        +Mode : LinChannelMode
        +DataBaudRate : uint
        +Alias : string
    }

    class LinMessage {
        +Timestamp : long
        +Id : long
        +Data : byte[]
    }

    class LinMessageFactory {
        +FromPayload(payload, out totalSize) LinMessage
        +FromPayload(payload, out totalSize, timestamp) LinMessage
    }

    CapsuleBase <|-- LinDataCapsule
    CapsuleBase <|-- LinChannelInfoCapsule
    CapsuleBase <|-- LinChannelSettingCapsule
    LinDataCapsule "1" --> "*" LinMessage
    LinMessageFactory ..> LinMessage : creates

Enumerations

Type Kind Values
LinChannelMode enum Observer, Slave, Master, Scheduler
LinChannelStatus enum Disabled, Ok, BusError
LinChannelFlag flags HasPullUp, SupportObserverMode, SupportSlaveMode, SupportMasterMode, SupportSchedulerMode
LinChannelSetting flags PullUpEnabled
LinStatus flags PullUpEnabled, MultiModeMessage

Requirements

  • .NET 10 or higher
  • Oakrey.Collections 2.0.0 (transitive dependency)
  • Oakrey.Capsule 2.x (project reference / NuGet)

Build instructions

dotnet build Capsule.Lin/Capsule.Lin.csproj

To produce a NuGet package:

dotnet pack Capsule.Lin/Capsule.Lin.csproj -c Release

Installation

.NET CLI

dotnet add package Oakrey.Capsule.Lin

Package Manager Console

Install-Package Oakrey.Capsule.Lin

NuGet Package Manager

Search for Oakrey.Capsule.Lin in Tools > NuGet Package Manager > Manage NuGet Packages for Solution.

Example usage

Serialize a single LIN message

using Oakrey.Capsule.Lin;

byte[] data = [0x01, 0x02, 0x03, 0x04];
LinMessage message = new(DateTime.UtcNow.Ticks, frameId: 0x10, data);

LinDataCapsule capsule = new(message, LinStatus.PullUpEnabled, channelIndex: 0, hwId: 1);
byte[] frame = capsule.Serialize();

Serialize multiple LIN messages (batched)

IEnumerable<LinMessage> messages = GetMessages();

LinDataCapsule capsule = new(
    messages,
    LinStatus.PullUpEnabled | LinStatus.MultiModeMessage,
    channelIndex: 0,
    hwId: 1);

byte[] frame = capsule.Serialize();

Deserialize a received capsule

byte[] received = ReceiveFrame();
LinDataCapsule capsule = new(received);

foreach (LinMessage msg in capsule.Messages)
{
    Console.WriteLine(msg);
}

Request channel information

byte[] requestFrame = LinChannelInfoCapsule.GetRequestPayload();
// send requestFrame over transport

Deserialize a channel info reply

byte[] reply = ReceiveFrame();
LinChannelInfoCapsule info = new(reply);

Console.WriteLine($"Channel {info.ChannelIndex}: {info.Status}, max {info.MaxBaudRate} baud");

Configure a channel

LinChannelSettingCapsule setting = new(
    channelIndex: 0,
    setting: LinChannelSetting.PullUpEnabled,
    mode: LinChannelMode.Master,
    dataBaudRate: 19200,
    alias: "LIN_1");

byte[] frame = setting.Serialize();

Development notes

  • All capsule types inherit from CapsuleBase and follow the Capsule binary protocol v2 framing.
  • LinDataCapsule uses a compact delta-timestamp encoding when LinStatus.MultiModeMessage is set: the first message carries an absolute timestamp from the capsule header, and subsequent messages carry a uint tick difference relative to the first message. The maximum representable delta is uint.MaxValue ticks.
  • LinMessageFactory distinguishes between single-message payloads (10 + N bytes) and multi-message payloads (14 + N bytes per subsequent message) based on the call overload, not an inline marker.
  • GetRequestPayload() serializes an empty capsule instance, which is the standard way to request data from a device using the Capsule protocol.

License

MIT. Copyright Oakrey 2016-present.

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 36 5/22/2026
2.0.1 89 5/15/2026
2.0.0 121 2/2/2026
1.0.0 282 4/22/2025