C++ library for parsing CAN databases (currently only with the DBC format)
C++ library for parsing CAN databases (currently only with the DBC format)
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-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.
cpp-can-parser is not a header-only library. I recommand CMake to include the library into your project:
# 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:
> cd cpp-can-parser
> mkdir build && cd build
> cmake .. && cmake --build . --target cpp-can-parserLD_FLAGS=-Lpath/to/the/library -lcpp-can-parserThe 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:
#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 :) !
No open issues yet, or sync has not completed.