Oakrey.DBC
7.0.0
dotnet add package Oakrey.DBC --version 7.0.0
NuGet\Install-Package Oakrey.DBC -Version 7.0.0
<PackageReference Include="Oakrey.DBC" Version="7.0.0" />
<PackageVersion Include="Oakrey.DBC" Version="7.0.0" />
<PackageReference Include="Oakrey.DBC" />
paket add Oakrey.DBC --version 7.0.0
#r "nuget: Oakrey.DBC, 7.0.0"
#:package Oakrey.DBC@7.0.0
#addin nuget:?package=Oakrey.DBC&version=7.0.0
#tool nuget:?package=Oakrey.DBC&version=7.0.0
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.dbcfile 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— typedEV_definition with access rules,ENVVAR_DATA_, value descriptions, comments, and attributes.Attribute� typed (integer, float, string, enum) with min/max, default values, andAttributeOwnerscope (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.TrimCANIdstrips the extended-frame bit from raw DBC IDs.CanIdUtility.RestoreCANIdrestores the bit for round-trip export fidelity.
DBC Export
DbcMatrix.SaveDBC(string path)� serialise the in-memory model back to a valid.dbcfile (Windows-1252 encoding, matching the DBC file standard).- When the matrix is loaded with an explicit or BOM-detected encoding,
SaveDBCreuses that encoding instead of the Windows-1252 default.
Error Handling
DbcParserExceptioncarries the offendingDbcLinefor precise error reporting.DbcMatrix.Diagnosticsreports 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__XXXis 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
- .NET 11 or higher
- Oakrey.BitArray 3.0.0
- Oakrey.Collections 2.0.0
- Oakrey.Readers 3.0.0
Installation
.NET CLI
dotnet add package Oakrey.DBC
Package Manager Console
Install-Package Oakrey.DBC
NuGet Package Manager
- Open your project in Visual Studio.
- Navigate to Tools > NuGet Package Manager > Manage NuGet Packages for Solution.
- Search for
Oakrey.DBCand 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.TrimCANIdremoves it for normal use;RestoreCANIdre-applies it before export.Message.RestoredIDandSignal.RestoredParentIddo this automatically. - Attribute scope �
Attribute.OwnerTypeis anAttributeOwnerenum (Message,Signal,Node,Global).AddAttributeenforces the correct owner type and throwsDbcParserExceptionon mismatch. - Environment variable attributes —
AttributeOwner.EnvironmentVariablerepresents theEV_attribute scope. - Signal multiplex �
Signal.Multiplexstores 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_, andSG_MUL_VAL_are represented in the object model and preserved during export. - Extended multiplex ranges —
Message.SignalMultiplexValuesretains the controlling signal and one or more inclusive value ranges; payload decoding remains outside this library. - File encoding �
SaveDBCwrites 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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net11.0 is compatible. |
-
net11.0
- Oakrey.BitArray (>= 5.0.0)
- Oakrey.Collections (>= 3.0.0)
- Oakrey.Readers (>= 5.0.0)
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 | |
| 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 |