克隆/下载
贡献代码
同步代码
取消
提示: 由于 Git 不支持空文件夾,创建文件夹后会生成空的 .keep 文件
Loading...
README
MIT

Libcanard

Forum Build Status Coverity Scan

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

Get help on the UAVCAN 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/UAVCAN/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

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 demo application under tests/demo.c. Also use code search to find real life usage examples.

At the moment the library does not provide means to automate (de)serialization of UAVCAN data structures, like other implementations (e.g. libuavcan for C++ or pyuavcan for Python) do. Therefore, data structures need to be parsed and assembled manually. The necessary examples are provided in the demo application.

Library Development

This section is intended only for library developers and contributors.

The library design document can be found in DESIGN.md

Contributors, please follow the Zubax C++ Coding Conventions.

Building and Running Tests

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

Submitting a Coverity Scan Build

First, get the Coverity build tool. Then build the tests with it:

export PATH=$PATH:<coverity-build-tool-directory>/bin/
mkdir build && cd build
cmake ../libcanard/tests -DCMAKE_BUILD_TYPE=Debug   # Adjust path if necessary
cov-build --dir cov-int make -j8
tar czvf libcanard.tgz cov-int

Then upload the resulting archive to Coverity.

The MIT License (MIT) Copyright (c) 2015 UAVCAN Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

简介

暂无描述 展开 收起
C++ 等 4 种语言
MIT
取消

发行版

暂无发行版

贡献者

全部

近期动态

不能加载更多了
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化