Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
C

cpp-can-parser

> 编程语言
Open source

C++ library for parsing CAN databases (currently only with the DBC format)

100 stars0 likes0 views
WebsiteGitHub

About

C++ library for parsing CAN databases (currently only with the DBC format)

C++ CAN Parser

This project provides a C++ library that reads and parses CAN databases which can then be analyzed for other purposes.

Currently the library only understand a subset of the DBC file format.

How robust and efficient is this library ?

C++ CAN Parser is an open-source project based on my work. The library is currently used in a robust industrial-grade pipeline. The few test files that I gathered in the tests/dbc-files/ directory are inspired by in-use CAN databases of several automotive industrial companies. So you can safely include this library into your own pipeline or CAN-based software.

C++ CAN Parser can be useful for building:

  • CAN sniffers
  • Static file generation (such as the Auto-Generated Code on the SJ-One Board)
  • TCP-to-CAN and CAN-to-TCP middlewares
  • ...

can-parse is a tool that analyzes a CAN database and proposes different operations. You can use it to inspect all or part of the database. can-parse printframe CAN_ID notably give detailed and structured information about the layout of a frame. Check out the dedicated section for more info.

Table of Contents

  • C++ CAN Parser
  • Table of Contents
  • Compile and include the library
    • The public headers
    • Compilation
  • Parsing a CAN database
  • How to use the database
    • CANSignal
    • CANFrame
    • CANDatabase
  • Database analysis
  • can-parse
  • Supported standards

Compile and include the library

Compilation

cpp-can-parser is not a header-only library. I recommand CMake to include the library into your project:

cmake
# After including cpp-can-parser into your project's CMakeLists.txt...
target_link_libraries(MyAwesomeProject cpp-can-parser)

By default, cpp-can-parser is linked as a shared object. If you want to use a static library, you can add set(CPP_CAN_PARSER_USE_STATIC TRUE) or set it at "command-line time": cmake -DCPP_CAN_PARSER_USE_STATIC=TRUE ...

If you are not using CMake to manage your whole project:

cpp-can-parser is not provided with an already existing Makefile. You will still need CMake to manage the compilation of the library and then include it with traditional means:

bash
> cd cpp-can-parser
> mkdir build && cd build
> cmake .. && cmake --build . --target cpp-can-parser
makefile
LD_FLAGS=-Lpath/to/the/library -lcpp-can-parser

Parsing a CAN database

The main feature of the library is the possibility of parsing a file representing the CAN database. There are several popular file formats and the list of the currently ones is available at the end of this README.

CANDatabase::fromFile("path/to/the/data.dbc") is the function to call in order to parse the database from a file. See the following example for a more "advanced" use:

cpp
#include 
#include 

int main(int argc, char** argv) {
  try {
    CppCAN::CANDatabase db = CppCAN::CANDatabase::fromFile(argv[1]);

    // ...
  }
  catch(const CppCAN::CANDatabaseException& e) {
    std::cerr 
#include 

CppCAN::CANDatabase db = ...;

// Boolean-based version ...
for(const auto& frame : db) {
  if(!CppCAN::analysis::is_frame_layout_ok(frame))
    std::cerr  cd cpp-can-parser
> mkdir build && cd build
> cmake .. && cmake --build . --target can-parse 

There you got yourself a very nice installation of can-parse :) !

Supported standards

  • DBC (the relevant subset of the file format)

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

C++can-networkingdbclibraryparser

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 18, 2026
Category编程语言
PricingOpen source

> Related tools

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言