Code Monkey home page Code Monkey logo

libcanard's Introduction

Libcanard

Minimal implementation of the DroneCAN protocol stack in C for resource constrained applications.

Get help on the DroneCAN Forum.

Usage

If you're not using Git, you can just copy the entire library into your project tree. If you're using Git, it is recommended to add Libcanard to your project as a Git submodule, like this:

git submodule add https://github.com/DroneCAN/libcanard

The entire library is contained in three files:

  • canard.c - the only translation unit; add it to your build or compile it into a separate static library;
  • canard.h - the API header; include it in your application;
  • canard_internals.h - internal definitions of the library; keep this file in the same directory with canard.c.

Add canard.c to your application build, add libcanard directory to the include paths, and you're ready to roll.

Also you may want to use one of the available drivers for various CAN backends that are distributed with Libcanard - check out the drivers/ directory to find out more.

If you wish to override some of the default options, e.g., assert macros' definition, define the macro CANARD_ENABLE_CUSTOM_BUILD_CONFIG as a non-zero value (e.g. for GCC or Clang: -DCANARD_ENABLE_CUSTOM_BUILD_CONFIG=1) and provide your implementation in a file named canard_build_config.h.

Example for Make:

# Adding the library.
INCLUDE += libcanard
CSRC += libcanard/canard.c

# Adding drivers, unless you want to use your own.
# In this example we're using Linux SocketCAN drivers.
INCLUDE += libcanard/drivers/socketcan
CSRC += libcanard/drivers/socketcan/socketcan.c

Example for CMake, first installing dependencies.

sudo apt-get update && sudo apt-get install gcc-multilib g++-multilib
cmake -S . -B build -DBUILD_TESTING=ON
cmake --build build
ctest .

There is no dedicated documentation for the library API, because it is simple enough to be self-documenting. Please check out the explanations provided in the comments in the header file to learn the basics. Most importantly, check out the examples directory for fully worked examples

For generation of de-serialisation and serialisation source code, please refer https://github.com/dronecan/dronecan_dsdlc .

C++ Interface

The C++ interface is in the canard/ directory. See examples/ESCNode_C++ for a fully worked example of the C++ API.

Library Development

This section is intended only for library developers and contributors.

The library design document can be found in DESIGN.md

Building and Running Tests

mkdir build && cd build
cmake ../libcanard/tests    # Adjust path if necessary
make
./run_tests

libcanard's People

Contributors

pavel-kirienko avatar masierra avatar bugobliterator avatar tridge avatar papatience avatar rennerm avatar antoinealb avatar storola avatar ryanf55 avatar espitall avatar aasmune avatar adolfogc avatar mahibak avatar magshaw avatar acassis avatar davidlenfesty avatar a1ien avatar kjetilkjeka avatar wesen avatar petervdperk-nxp avatar rabad-matternet avatar valle125 avatar bradapd avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.