Oakrey.DBC 7.0.0

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

Oakrey.DBC

Overview

Oakrey.DBC is a .NET 11 library for parsing, building, and exporting DBC (CAN database) files. It provides a complete object model for CAN bus databases covering messages, signals (with multiplexing, big/little endian, scale/offset, and value tables), nodes, attributes, and relationships. Files are parsed asynchronously and can be exported back to a valid DBC file with full round-trip fidelity.

Main Features

Async DBC Parsing

  • DbcMatrix.CreateAsync(FileInfo, CancellationToken) � parse a .dbc file asynchronously into a fully populated object model.
  • DbcMatrix.CreateAsync(FileInfo, Encoding, CancellationToken) supports an explicit source encoding and retains it for export.
  • Handles all standard DBC sections: version, bit-timing, nodes, messages, signals, comments, attribute definitions, attribute values, value descriptions, and environmental properties.

Full CAN Object Model

  • Message � ID (standard and extended CAN), length, sending node, transmitters, signals, attributes, and comments.
  • Signal � start bit, size, endian, scale, offset, min/max, unit, multiplex indicator, receiving nodes, enum values, attributes, and comments.
  • Node � name, attributes, and comments.
  • EnvironmentVariable — typed EV_ definition with access rules, ENVVAR_DATA_, value descriptions, comments, and attributes.
  • Attribute � typed (integer, float, string, enum) with min/max, default values, and AttributeOwner scope (message, signal, node, or global).
  • ValueTable � named enum value tables referenced by signals.
  • Relationship � environment variable relationships between nodes.
  • CategoryDefinition � category metadata entries.

Extended CAN ID Handling

  • CanIdUtility.TrimCANId strips the extended-frame bit from raw DBC IDs.
  • CanIdUtility.RestoreCANId restores the bit for round-trip export fidelity.

DBC Export

  • DbcMatrix.SaveDBC(string path) � serialise the in-memory model back to a valid .dbc file (Windows-1252 encoding, matching the DBC file standard).
  • When the matrix is loaded with an explicit or BOM-detected encoding, SaveDBC reuses that encoding instead of the Windows-1252 default.

Error Handling

  • DbcParserException carries the offending DbcLine for precise error reporting.
  • DbcMatrix.Diagnostics reports parser warnings and model validation errors.
  • Validation runs automatically after parsing and can be repeated after model edits with DbcMatrix.Validate().
  • The validator checks unique message IDs and model names, node references, frame and signal ranges, bit overlaps, non-zero factors, ordered min/max values, and simple/extended multiplexing rules. Vector__XXX is accepted as the standard placeholder node.

Architecture

classDiagram
    direction TB
    class DbcMatrix {
        +Name: string
        +Version: string
        +Messages: ListOfMessages
        +Nodes: ListOfNodes
        +Attributes: ListOfAttributes
        +ValueTables: List~ValueTable~
        +Relationships: ListOfRelationships
        +CreateAsync(file, ct)$ Task~DbcMatrix~
        +SaveDBC(path)
    }
    class Message {
        +ID: long
        +RestoredID: long
        +Name: string
        +Length: int
        +SendingNode: ListOfNodes
        +Signals: ListOfSignals
        +Attributes: ListOfAttributes
    }
    class Signal {
        +Name: string
        +StartAt: int
        +Size: int
        +Endian: string
        +Scale: double
        +Offset: double
        +Unit: string
        +Multiplex: string
        +Values: List~EnumValue~
        +Attributes: ListOfAttributes
    }
    class Node {
        +Name: string
        +Attributes: ListOfAttributes
    }
    class Attribute {
        +Name: string
        +Type: AttributeType
        +OwnerType: AttributeOwner
    }
    class ValueTable {
        +Name: string
        +Values: List~EnumValue~
    }

    DbcMatrix "1" --> "*" Message
    DbcMatrix "1" --> "*" Node
    DbcMatrix "1" --> "*" Attribute
    DbcMatrix "1" --> "*" ValueTable
    Message "1" --> "*" Signal
    Message "1" --> "*" Attribute
    Signal "1" --> "*" Attribute
    Node "1" --> "*" Attribute

Requirements

Installation

.NET CLI

dotnet add package Oakrey.DBC

Package Manager Console

Install-Package Oakrey.DBC

NuGet Package Manager

  1. Open your project in Visual Studio.
  2. Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
  3. Search for Oakrey.DBC and click Install.

Usage

Parse a DBC file

FileInfo dbcFile = new FileInfo("vehicle_network.dbc");
DbcMatrix matrix = await DbcMatrix.CreateAsync(dbcFile, CancellationToken.None);

Console.WriteLine($"Version: {matrix.Version}");
Console.WriteLine($"Messages: {matrix.Messages.Count}");
Console.WriteLine($"Nodes: {matrix.Nodes.Count}");

Inspect messages and signals

foreach (Message message in matrix.Messages)
{
    Console.WriteLine($"  [{message.ID:X}] {message.Name} ({message.Length} bytes)");

    foreach (Signal signal in message.Signals)
    {
        Console.WriteLine($"    {signal.Name}: start={signal.StartAt}, size={signal.Size}, scale={signal.Scale}, offset={signal.Offset}, unit={signal.Unit}");
    }
}

Export back to DBC

matrix.SaveDBC("vehicle_network_modified.dbc");

Work with attributes

foreach (Attribute attribute in matrix.Messages.SelectMany(m => m.Attributes))
{
    Console.WriteLine($"{attribute.Name} ({attribute.Type}) = {attribute.DefaultValueString}");
}

Development Notes

  • Extended CAN IDs � DBC files encode extended 29-bit CAN IDs with the MSB set (0x80000000). CanIdUtility.TrimCANId removes it for normal use; RestoreCANId re-applies it before export. Message.RestoredID and Signal.RestoredParentId do this automatically.
  • Attribute scope � Attribute.OwnerType is an AttributeOwner enum (Message, Signal, Node, Global). AddAttribute enforces the correct owner type and throws DbcParserException on mismatch.
  • Environment variable attributes — AttributeOwner.EnvironmentVariable represents the EV_ attribute scope.
  • Signal multiplex � Signal.Multiplex stores the raw DBC mux indicator (e.g., M, m3). Full mux decoding is not yet implemented; the field is preserved for round-trip correctness.
  • Advanced signal metadata — VAL_TABLE_, SIG_VALTYPE_, SIG_GROUP_, and SG_MUL_VAL_ are represented in the object model and preserved during export.
  • Extended multiplex ranges — Message.SignalMultiplexValues retains the controlling signal and one or more inclusive value ranges; payload decoding remains outside this library.
  • File encoding � SaveDBC writes Windows-1252 (Encoding.GetEncoding(1252)), which is the encoding used by most OEM DBC toolchains.

Project Information

Field Value
Author Oakrey
License MIT
NuGet Oakrey.DBC
Repository Azure DevOps

License

This project is licensed under the MIT License. See the LICENSE file for details.

Product Compatible and additional computed target framework versions.
.NET net11.0 is compatible. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Oakrey.DBC:

Package Downloads
Oakrey.DBC.Values

Oakrey.DBC.Values is a .NET 11 library that adds live signal value handling on top of Oakrey.DBC. SignalValue wraps a DBC Signal template with NumericBitArray-backed raw and scaled double access, implements INotifyPropertyChanged for data-binding support, and tracks decimal precision from the signal scale. TaskMessage composes a full CAN message payload from its signal set, supports mux-ID dispatch in SetValues, and maintains a rolling receive history via FixedSizedQueue. Designed for automotive, industrial, and IoT CAN data processing.

Oakrey.Applications.FileParsing.DBC

Specialized file parsing library for DBC (CAN database) files. Built on FileParsing framework with automatic parsing into DbcMatrix objects, reactive updates, and extended file management. Features CAN message/signal access, template support, and seamless integration with Oakrey.DBC parser.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
7.0.0 61 11/13/2026
6.1.1 199 9/18/2026
6.1.0 268 8/6/2026
6.0.0 145 8/6/2026
5.1.0 156 8/4/2026
5.0.0 152 8/3/2026
4.0.1 207 6/5/2026
4.0.0 173 6/3/2026 4.0.0 is deprecated because it has critical bugs.
3.0.2 173 5/22/2026
3.0.1 157 5/15/2026
3.0.0 179 3/13/2026
2.1.2 171 2/25/2026
2.1.1 158 2/25/2026
2.1.0 158 2/25/2026
2.0.0 175 2/2/2026
1.0.0 368 4/22/2025