CanTools.Net 1.1.0

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

CanTools.Net

CI

A C#/.NET port of the excellent cantools Python library by Erik Moqvist and contributors.

Why this library

DbcParserLib is the established .NET choice for DBC files, and for plain DBC parsing it works well. CanTools.Net exists for the cases it doesn't cover: extended multiplexing (SG_MUL_VAL_), signal groups, DBC writing, J1939 helpers, and — uniquely on .NET — the KCD and SYM formats, candump/ PCAN log parsing, and a full CANopen layer (EDS/DCF, PDO decoding, CiA 301 frame codecs, log interpretation). Behavior is verified against the upstream cantools test suite and cross-checked against the Python implementation.

What works today:

  • DBC: read and write, including attributes, value tables, comments, signal groups, long-name resolution, J1939/CAN FD detection and relation attributes.
  • KCD and SYM 6.0: read. DatabaseLoader.LoadFile picks the format from the file extension, or probes the content when the extension is unknown.
  • Encode/decode CAN messages with scaling, choices, floats, and simple and extended multiplexing — verified against the cantools test suite.
  • J1939 frame id and PGN helpers.
  • Log reading: candump (plain, -tz, -l, -tA) and PCAN trace 1.0–2.1.
  • CANopen: read EDS/DCF object dictionaries (CiA 306, $NODEID expressions, compact arrays — verified against python-canopen), project PDO mappings onto ordinary decodable messages, parse and build the CiA 301 frames (NMT, heartbeat, EMCY, SYNC, TIME, SDO), and fold a candump of a CANopen network into typed events with SDO reassembly — segmented and block transfers included. This goes beyond upstream cantools; see CANOPEN.md.
  • Live SDO client: read and write a remote node's object dictionary over any ICanChannel — expedited, segmented and block transfer — verified against SDO test vectors learned from lely-core. The core ships no bus binding, so it stays dependency-free; see CANOPEN.md and samples/CanTools.CanOpenSample.
using CanTools.Formats.Dbc;

var db = DbcReader.LoadFile("vehicle.dbc");
var data = db.EncodeMessage("ExampleMessage", new Dictionary<string, SignalValue>
{
    ["Temperature"] = 250.55,
    ["Enable"] = "Enabled",
});
var decoded = db.DecodeMessage("ExampleMessage", data);

More examples — loading databases, decoding log files, J1939, CANopen — in docs/examples.md. For a runnable end-to-end tour, see samples/CanTools.Sample (dotnet run --project samples/CanTools.Sample).

Command line

The CanTools.Net.Cli package ports the cantools command line (the decode, dump, list and convert subcommands):

dotnet tool install --global CanTools.Net.Cli

candump can0 | cantools-net decode vehicle.dbc
cantools-net dump vehicle.dbc
cantools-net list vehicle.dbc
cantools-net convert vehicle.kcd vehicle.dbc

If you would rather not install the .NET SDK, each GitHub release also attaches a self-contained cantools-net executable for Windows, Linux and macOS (x64 and Apple Silicon). Download the one for your platform, and run it directly — no runtime required (on Linux/macOS, chmod +x it first).

This is an independent port and is not affiliated with the cantools maintainers. CANopen is a registered trademark of CAN in Automation (CiA); this project is not affiliated with or endorsed by CiA. Behavior is verified against the upstream test suite and cross-checked against the Python implementation; see PORTING.md for exactly what has been ported and which deviations exist, and PLAN.md for the roadmap. Not yet ported: ARXML and CDD parsing, KCD/SYM writing, container messages, and the monitor, plot and generate_c_source subcommands.

Versioning

From 1.0.0 the public API follows Semantic Versioning: breaking changes ship only in a new major version. See CHANGELOG.md for what changed in each release.

License

MIT. Portions derived from cantools, Copyright (c) 2015-2019 Erik Moqvist, also MIT — see THIRD-PARTY-NOTICES.txt.

Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  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
1.1.0 139 7/19/2026
0.2.0 105 7/16/2026
0.1.0 114 7/16/2026