DiagKit.Dbc
1.2.0-preview.1
dotnet add package DiagKit.Dbc --version 1.2.0-preview.1
NuGet\Install-Package DiagKit.Dbc -Version 1.2.0-preview.1
<PackageReference Include="DiagKit.Dbc" Version="1.2.0-preview.1" />
<PackageVersion Include="DiagKit.Dbc" Version="1.2.0-preview.1" />
<PackageReference Include="DiagKit.Dbc" />
paket add DiagKit.Dbc --version 1.2.0-preview.1
#r "nuget: DiagKit.Dbc, 1.2.0-preview.1"
#:package DiagKit.Dbc@1.2.0-preview.1
#addin nuget:?package=DiagKit.Dbc&version=1.2.0-preview.1&prerelease
#tool nuget:?package=DiagKit.Dbc&version=1.2.0-preview.1&prerelease
DiagKit.Dbc
DiagKit.Dbc is a .NET 10 DBC runtime library for diagnostic and CAN tooling. It provides DBC loading, an immutable metadata model, CAN/CAN FD signal encoding and decoding, runtime channel state, signal sample projection, and hardware-agnostic periodic transmit scheduling.
Current Capabilities
- Load DBC files with
StrictorLenientdiagnostics. - Use grouped
DbcDiagnosticFormatter,Errors/Warnings,SignalPath, and simple facades for first-use and migration scenarios. - Load immutable documents directly with
DbcLoader.LoadDocumentOrThrow(...)when runtime state is not needed. - Enumerate
DbcSignalViewSnapshotvalues for UI binding throughDbcSimpleRuntime/DbcSimpleChannel. - Model nodes, messages, signals, environment variables, relation-attribute metadata, attributes, value tables, multiplexing, CAN identifiers, CAN FD flags, and source lines.
- Restore Vector
SystemNodeLongSymbol,SystemMessageLongSymbol,SystemSignalLongSymbol, andSystemEnvVarLongSymbolas canonical names while keeping short-name aliases resolvable. - Export normalized, reloadable DBC text with
DbcWriter, write diagnostics, Vector long-symbol output, and reload semantic equivalence coverage. - Create or semantically edit documents with
DbcDocumentBuilderbefore export. - Encode and decode Intel/Motorola signals, signed values, floating-point signals, raw values, and physical values.
- Use explicit write policies for range handling instead of silent correction.
- Process received frames into current snapshots and streaming
SignalSampleoutput for real-time or historical data consumers. - Build immediate frames and poll due periodic frames without owning hardware, threads, timers, or application queues.
- Map common DBC semantics such as cycle time, send type, timeout, signal start value, and
VFrameFormat. - Keep common third-party DBC output usable in lenient mode, including Vector-explainable transport-sized message metadata, duplicate value-table warnings, and ambiguous duplicate-signal metadata.
- Run deterministic fuzz/property tests, benchmark matrix scenarios, opt-in soak runs, and real DBC corpus verification.
Scope
The package is intentionally hardware-agnostic. It does not depend on CanHub, Vector, ZLG, WPF, Excel/CSV workflows, or any hardware SDK. Host applications adapt hardware frames to DbcFrameView and consume transmit frames through IDbcFrameSink.
For Excel-based bulk editing of common DBC parameters, reference the optional DiagKit.Dbc.Workbook extension package or use the diagkit-dbc workbook template/export/import/validate commands from DiagKit.Dbc.Tool. Import reads a .xlsx DBC semantic table file by itself; it is not CAN trace data, signal samples, EOL test scripts, or source-preserving DBC editing.
J1939 is considered in the public boundaries, but the full J1939 protocol stack is not implemented in this package. Lenient loading may preserve J1939/transport payload metadata beyond 64 bytes; DbcChannelRuntime and CAN/CAN FD frame APIs only process messages where SupportsSingleFrameRuntime is true. Future protocol-specific behavior belongs in a separate extension layer.
For a fuller integration guide, see API usage guide.
Entry Points
| Scenario | Start with | Notes |
|---|---|---|
| First use, UI, scripts, tests | DbcSimpleRuntime |
Loads a DBC, keeps diagnostics, and exposes "Message.Signal" convenience APIs. |
| Production runtime state machine | DbcRuntimeSession / DbcChannelRuntime |
Use pre-resolved handles, snapshots, sinks, and periodic polling. |
| Low-level tools and metadata | DbcLoader.LoadDocumentOrThrow, DbcDocument, DbcCodec |
Inspect DBC metadata or run stateless encode/decode without a runtime session. |
Normalized DBC Export
DbcWriter writes stable DBC text from immutable DbcDocument metadata for newly built documents, semantic edits, and CI normalized export. The contract is reload semantic equivalence, not byte-for-byte round-trip editing: original whitespace, statement order, unknown statements, and comment placement are not preserved.
The default writer profile is ReloadEquivalent, which may emit metadata preserved by this library but not currently known-good in CANdb++, including general BA_ ... EV_ ... environment-variable attributes and BA_REL_ relation assignments. Use DbcWriterCompatibilityProfile.CanDbPlusKnownGood for CANdb++-oriented export; strict mode fails on known-unsupported statements, while lenient mode omits them and reports warnings.
var document = DbcLoader.LoadTextDocumentOrThrow(dbcText);
var result = DbcWriter.WriteText(document);
var text = result.GetTextOrThrow();
DbcDocumentBuilder can create or edit documents before export:
var builder = DbcDocumentBuilder.Create();
builder.AddNode("ECU");
builder.AddMessage(new DbcRawMessageId(256), "Status", 8, "ECU")
.AddSignal("Speed", 0, 16)
.WithScaling(0.1, 0);
5-Minute Path
Load a DBC and inspect messages/signals:
var dbc = DbcSimpleRuntime.LoadFile("vehicle.dbc");
Console.WriteLine(DbcDiagnosticFormatter.FormatGrouped(dbc.LoadResult.Diagnostics));
foreach (var message in dbc.Document.Messages)
{
Console.WriteLine($"{message.Name}: {message.Signals.Count} signals");
}
Decode one received CAN frame into physical values:
var values = dbc.ProcessFrame(identifier, payload, timestamp: timestamp);
var speed = values.GetPhysicalValue("VehicleSpeed");
Set one signal and build an immediate transmit frame:
dbc.SetPhysicalValue("VehicleStatus.VehicleSpeed", 42.5);
var frame = dbc.BuildFrame("VehicleStatus", timestamp);
Poll DBC-driven periodic messages:
var session = DbcRuntimeSession.Create(dbc.Document);
var channel = session.CreateChannel("CAN1");
var start = Stopwatch.GetTimestamp();
var now = DbcTimestamp.FromElapsed(Stopwatch.GetElapsedTime(start));
var report = channel.RegisterCyclicPublishingMessagesFromDbc();
channel.PollDueFrames(now, txSink);
For hardware adapters, map receive frames to DbcFrameView and synchronously copy or forward IDbcFrameSink.OnFrame output to the hardware send API. DbcSimpleRuntime / DbcSimpleChannel are for UI, scripts, tests, and migration; hot paths should use pre-resolved handles, DbcFrameView, IDbcFrameSink, and ISignalSampleSink.
Verification
dotnet test ..\..\DiagKit.Dbc.slnx
dotnet run --project ..\..\tests\DiagKit.Dbc.Benchmarks\DiagKit.Dbc.Benchmarks.csproj -- --matrix
dotnet run --project ..\..\tests\DiagKit.Dbc.Benchmarks\DiagKit.Dbc.Benchmarks.csproj -- --soak --seconds 30
dotnet run --project ..\..\tests\DiagKit.Dbc.Benchmarks\DiagKit.Dbc.Benchmarks.csproj -- --corpus path\to\dbc-folder
Package Status
The package uses the MIT license. NuGet versions are generated by MinVer from Git tags with v as the tag prefix. The first preview tag is v1.0.0-preview; later previews use tags such as v1.0.0-preview.1. Releases follow the DiagKit family convention: CI first, then tag-driven NuGet publishing and GitHub Release creation.
| 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. |
-
net10.0
- No dependencies.
NuGet packages (1)
Showing the top 1 NuGet packages that depend on DiagKit.Dbc:
| Package | Downloads |
|---|---|
|
DiagKit.Dbc.Workbook
DBC Excel semantic table export, template, and import for editing DiagKit.Dbc messages, signals, value descriptions, nodes, environment variables, and attribute metadata. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 1.2.0-preview.1 | 85 | 5/31/2026 |
| 1.2.0-preview | 61 | 5/29/2026 |
| 1.1.0-preview.2 | 65 | 5/22/2026 |
| 1.1.0-preview.1 | 57 | 5/21/2026 |
| 1.0.0-preview | 60 | 5/20/2026 |
Preview export update: normalized DBC writer, semantic document builder, reload-equivalence diagnostics, Vector long-symbol export, CANdb++ known-good compatibility profile, relation value formatting fixes, and documentation for non-round-trip export boundaries.