Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UAVCAN v1.0 done #142

Merged
merged 100 commits into from
Mar 8, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
502e512
Restructuring WIP
pavel-kirienko Jan 19, 2020
22400fa
WIP; tests are temporarily broken
pavel-kirienko Feb 2, 2020
165ef2d
API review WIP
pavel-kirienko Feb 4, 2020
5cf5b1b
Test integration
pavel-kirienko Feb 4, 2020
3c7188c
CI test fix
pavel-kirienko Feb 4, 2020
ab480af
Linter fixes
pavel-kirienko Feb 4, 2020
501955d
Moving on
pavel-kirienko Feb 4, 2020
4cfa339
Compile-time platform assumption checks
pavel-kirienko Feb 5, 2020
bcca484
Transmission WIP
pavel-kirienko Feb 5, 2020
0989c31
Should be ready for testing now
pavel-kirienko Feb 5, 2020
aa64c18
Remove float subnorm test to fix GCC build
pavel-kirienko Feb 5, 2020
716b5b2
Moving on
pavel-kirienko Feb 5, 2020
93ad49f
Moving on with the API. Improved error handling and typing.
pavel-kirienko Feb 9, 2020
ff822fd
Formatting & clarifications
pavel-kirienko Feb 9, 2020
8410701
Finalized makeTailByte() & makeCANID()
pavel-kirienko Feb 9, 2020
70e5322
findTxQueueSupremum()
pavel-kirienko Feb 9, 2020
5274db5
Started work on the TX test suite
pavel-kirienko Feb 9, 2020
f4d9a44
Fixed a documentation error
pavel-kirienko Feb 9, 2020
c7ed983
Ci build fix
pavel-kirienko Feb 9, 2020
f75eff2
Formatting
pavel-kirienko Feb 9, 2020
534f317
TX test WIP
pavel-kirienko Feb 10, 2020
91d8589
TX test, partial
pavel-kirienko Feb 11, 2020
45f8b40
TX queue popping
pavel-kirienko Feb 11, 2020
a6679b6
Fix SonarQube warnings
pavel-kirienko Feb 11, 2020
aedd4f8
Fix minor SonarQube warnings
pavel-kirienko Feb 11, 2020
a4aac16
More TX testing
pavel-kirienko Feb 11, 2020
70e8411
Random-fill allocated memory
pavel-kirienko Feb 11, 2020
65aab43
More TX testing
pavel-kirienko Feb 11, 2020
5a3d960
Finished the TX test and added some docs
pavel-kirienko Feb 11, 2020
25f210a
Fix tests & static analysis
pavel-kirienko Feb 14, 2020
8b7551f
DSDL primitive serialization routines moved into a separate pair of f…
pavel-kirienko Feb 14, 2020
fd30448
Update the heap memory model description
pavel-kirienko Feb 14, 2020
ec884d2
Moving on with the RX pipeline
pavel-kirienko Feb 15, 2020
eaf9537
Pending refactoring of rx_filter()
pavel-kirienko Feb 15, 2020
fd4a225
RX revamping WIP
pavel-kirienko Feb 15, 2020
9e109f8
RX pipeline refactoring continues; the new heap memory model requires…
pavel-kirienko Feb 15, 2020
a987ced
Minor clarifications in the comments & static analysis fixes
pavel-kirienko Feb 15, 2020
f83025c
Zero-copy reception
pavel-kirienko Feb 16, 2020
951902b
Update the docs
pavel-kirienko Feb 16, 2020
24ab7ec
RX pipeline seems to be finished, but requires review & refactoring
pavel-kirienko Feb 17, 2020
468965f
RX pipeline refactoring
pavel-kirienko Feb 17, 2020
a61b505
Missing declaration
pavel-kirienko Feb 17, 2020
23a47eb
Internal simplification
pavel-kirienko Feb 17, 2020
0bc8cf4
Global renamings, no structural changes
pavel-kirienko Feb 17, 2020
249594d
More structured organization of the test suite; no logical changes
pavel-kirienko Feb 17, 2020
4ed9f77
Fix coverage
pavel-kirienko Feb 17, 2020
ec68f80
AVR GCC compilation test
pavel-kirienko Feb 17, 2020
573da6e
Improve coverage
pavel-kirienko Feb 17, 2020
8087564
RX frame parsing test
pavel-kirienko Feb 17, 2020
568ac1f
Test rxSessionWritePayload
pavel-kirienko Feb 17, 2020
a6d38c6
Formatting
pavel-kirienko Feb 17, 2020
0e5e959
Better (ugh) coverage tracking (hack, fix later)
pavel-kirienko Feb 19, 2020
46529d6
RX test WIP; the CI build is temporarily broken sry
pavel-kirienko Feb 19, 2020
36edc2d
rxSessionUpdate() test done
pavel-kirienko Feb 20, 2020
41d2f80
Fix sonarqube and move configs into .travis.yml
pavel-kirienko Feb 20, 2020
5e9f742
I love YAML but sometimes it's like wtf
pavel-kirienko Feb 20, 2020
97484cc
rxAccept() testing WIP
pavel-kirienko Feb 21, 2020
58a4dfd
RX pipeline test done
pavel-kirienko Feb 21, 2020
64e60ce
Rework
pavel-kirienko Feb 23, 2020
efaa25b
Randomized roundtrip test
pavel-kirienko Feb 23, 2020
894f3a1
Fix AVR compile test
pavel-kirienko Feb 23, 2020
c579ae2
Refactor the TX memory management API
pavel-kirienko Feb 23, 2020
82844f0
SonarQube
pavel-kirienko Feb 23, 2020
e9019d0
Fix the AVR build again
pavel-kirienko Feb 23, 2020
5e1bca9
Suppress check near an intended MISRA violation
pavel-kirienko Feb 23, 2020
9ca9be2
Started work on the DSDL helpers
pavel-kirienko Feb 23, 2020
389cf17
bit copy implementation & minimal testing (to be extended)
pavel-kirienko Feb 27, 2020
5c8bdef
canardDSDLPrimitiveSerialize()
pavel-kirienko Feb 28, 2020
54637ea
Better DSDL serialization API
pavel-kirienko Feb 28, 2020
6aa8de0
Working on the deserialization logic and its tests
pavel-kirienko Feb 28, 2020
357d4d1
Finished the tests for the deserializer routines
pavel-kirienko Feb 29, 2020
123ff12
Fix warnings
pavel-kirienko Feb 29, 2020
b9497e7
Make the floating point support optional depending on the properties …
pavel-kirienko Feb 29, 2020
130862c
Fix warnings from SonarQube
pavel-kirienko Feb 29, 2020
57c328b
Nits from SonarQube
pavel-kirienko Feb 29, 2020
162a5a0
Suppress a false-positive from Clang-Tidy
pavel-kirienko Feb 29, 2020
0d66591
Fix the hack in the CI coverage tracking
pavel-kirienko Feb 29, 2020
e1caf06
Fixing combined coverage reporting
pavel-kirienko Feb 29, 2020
966d10e
Bump coverage
pavel-kirienko Mar 1, 2020
afc0b2e
More coverage
pavel-kirienko Mar 1, 2020
347d0f8
Brought the coverage to 100% excepting the assertion checks
pavel-kirienko Mar 1, 2020
6b4e9a5
A hack to get the coverage metrics correct in SonarQube
pavel-kirienko Mar 1, 2020
34f8484
Formatting
pavel-kirienko Mar 1, 2020
9efc9dd
Fix coverage?
pavel-kirienko Mar 1, 2020
c9e464e
Okay, C code coverage is malfunctioning on SonarQube, let's try somet…
pavel-kirienko Mar 1, 2020
4199f62
Trying with NDEBUG again
pavel-kirienko Mar 1, 2020
1361489
Okay, the coverage tracking seems to be working now
pavel-kirienko Mar 1, 2020
988bba2
Minor clean up; docs next
pavel-kirienko Mar 1, 2020
183013b
Add missing badges
pavel-kirienko Mar 1, 2020
1ac67c4
Docs WIP
pavel-kirienko Mar 2, 2020
7b5fcc3
Docs WIP
pavel-kirienko Mar 2, 2020
42664f4
Finished the header file documentation; README next
pavel-kirienko Mar 2, 2020
d0da584
README rework
pavel-kirienko Mar 2, 2020
691f2ca
It's done
pavel-kirienko Mar 3, 2020
9a2052f
Move the IDE-related files into the project root
pavel-kirienko Mar 3, 2020
b5f1b77
A few very trivial changes: typos, wording, doc style
pavel-kirienko Mar 3, 2020
13d0f90
Disable the codecov integration to eliminate noise. The coverage is t…
pavel-kirienko Mar 3, 2020
09b4370
Update the README to match https://github.com/UAVCAN/specification/is…
pavel-kirienko Mar 7, 2020
f80aa3c
Update the docs following the feedback from Scott. Comment-only changes.
pavel-kirienko Mar 7, 2020
b16a86b
Update canard.h
pavel-kirienko Mar 8, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -37,19 +37,19 @@ cmake-build-*/
build-avr/

# IDE and tools
.idea
.metadata
.settings
.project
.cproject
.pydevproject
.gdbinit
.vscode/
**/.idea/*
!**/.idea/dictionaries
!**/.idea/dictionaries/*

# Generated files
dsdlc_generated/

# Pycache
__pycache__/

# Ignore IDE folders
.vscode/
79 changes: 79 additions & 0 deletions .idea/dictionaries/pavel.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

94 changes: 72 additions & 22 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
dist: xenial
env:
- CTEST_OUTPUT_ON_FAILURE=1

matrix:
include:
Expand All @@ -17,44 +19,92 @@ matrix:
- g++-9-multilib
- gcc-9-multilib
- linux-libc-dev:i386
env:
- CC=gcc-9
- CXX=g++-9
script:
- CC=gcc-9 && CXX=g++-9 && cmake tests
- build-wrapper-linux-x86-64 --out-dir sonar-dump make all # The build wrapper comes from Sonar Cloud.
- ./run_tests --rng-seed time
- sonar-scanner
# ANALYSIS
# Using the build wrapper from Sonar and collecting the code coverage.
# Define NDEBUG=1 to avoid assertion checks being reported as uncovered statements.
- cmake tests -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=1 -DCMAKE_C_FLAGS='-DNDEBUG=1'
- build-wrapper-linux-x86-64 --out-dir sonar-dump make all
- make test
- gcov-9 --preserve-paths --long-file-names $(find CMakeFiles/test_private_cov.dir -name '*.gcno')
- gcov-9 --preserve-paths --long-file-names $(find CMakeFiles/test_private_le_cov.dir -name '*.gcno')
- gcov-9 --preserve-paths --long-file-names $(find CMakeFiles/test_public_cov.dir -name '*.gcno')
- 'sonar-scanner -Dsonar.projectKey=libcanard
-Dsonar.organization=uavcan
-Dsonar.sources=libcanard
-Dsonar.cfamily.gcov.reportsPath=.
-Dsonar.cfamily.build-wrapper-output=sonar-dump
-Dsonar.cfamily.cache.enabled=false'
- make clean

# DEBUG
- cmake tests -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=1
- make all VERBOSE=1 && make test
- make clean

# RELEASE
- cmake tests -DCMAKE_BUILD_TYPE=Release -DNO_STATIC_ANALYSIS=1
- make all VERBOSE=1 && make test
- make clean

# -------------------- Clang 9 --------------------
- language: cpp
addons:
apt:
sources:
- ubuntu-toolchain-r-test
packages:
- libstdc++-7-dev:i386
packages: # Install a newer GCC because https://stackoverflow.com/a/51512150/1007777.
- g++-9
- g++-9-multilib
- gcc-9-multilib
- linux-libc-dev:i386
- libc6-dev-i386
- libstdc++-7-dev:i386
script:
# Set up the toolchain.
- wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 9
- clang++-9 -E -x c++ - -v < /dev/null # Print the Clang configuration for troubleshooting purposes
- cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests
- make
- ./run_tests --rng-seed time
- sudo apt install clang-tidy-9 clang-format-9
- clang++-9 -E -x c++ - -v < /dev/null # Print the Clang configuration for troubleshooting purposes.

# -------------------- Static analysis --------------------
- language: cpp
script:
- sudo rm -rf /usr/local/clang*
- wget https://apt.llvm.org/llvm.sh && chmod +x llvm.sh && sudo ./llvm.sh 9
- sudo apt install clang-format-9 clang-tidy-9
- sudo ln -sf $(which clang-format-9) /usr/bin/clang-format
- sudo ln -sf $(which clang-tidy-9) /usr/bin/clang-tidy
# DEBUG
- cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=Debug
- make VERBOSE=1 && make test
- make clean

# RELEASE
- cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=Release
- make VERBOSE=1 && make test
- make clean

# TODO: invoke clang-tidy.
# RELWITHDEBINFO
- cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=RelWithDebInfo
- make VERBOSE=1 && make test
- make clean

# Code style enforcement.
- ./format.sh
# MINSIZEREL
- cmake -DCMAKE_C_COMPILER=clang-9 -DCMAKE_CXX_COMPILER=clang++-9 tests -DCMAKE_BUILD_TYPE=MinSizeRel
- make VERBOSE=1 && make test
- make clean

# Format check
- make format VERBOSE=1
- 'modified="$(git status --porcelain --untracked-files=no)"'
- 'if [ -n "$modified" ]; then echo "Run format.sh to reformat the code."; exit 1; fi'
- 'if [ -n "$modified" ]; then echo "Run make format to reformat the code properly."; exit 1; fi'

# -------------------- AVR GCC --------------------
- language: c
addons:
apt:
packages:
- gcc-avr
- avr-libc
script:
# This is a trivial test where we only check whether it compiles at all with all warnings enabled.
# TODO: Write unit tests and run them on an emulator.
- avr-gcc libcanard/*.c -c -std=c11 -mmcu=at90can64 -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits

git:
depth: false # Disable shallow clone because it is incompatible with SonarCloud
103 changes: 103 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,103 @@
# Libcanard contribution guide

## Design principles

The library is intended for use in real-time high-integrity applications.
It is paramount that its temporal properties and resource utilization are plain to model and predict statically.
The code shall follow applicable high-reliability coding guidelines as explained later in this document.
The implementation shall be fully compliant with the UAVCAN/CAN specification.

The implementation and the API should be kept simple.
The core library `canard.c` (that is, excluding the optional DSDL presentation layer extension) shall never become
larger than 1000 logical lines of code.
This restriction ensures that the library is kept simple and easy to validate and verify.
There will be no high-level abstractions -- if that is desired, other implementations of UAVCAN should be used.

The library is intended for deeply embedded systems where the resources may be scarce.
The ROM footprint is of a particular concern because the library should be usable with embedded bootloaders.

## Directory layout

The production sources and some minimal configuration files (such as `.clang-tidy`) are located under `/libcanard/`.
Do not put anything else in there.

The tests are located under `/tests/`.
This directory also contains the top `CMakeLists.txt` needed to build and run the tests on the local machine.

There is no separate storage for the documentation because it is written directly in the header files.
This works for Libcanard because it is sufficiently compact and simple.

## Standards

The library shall be implemented in ISO C11 following MISRA C:2012.
The MISRA compliance is enforced by Clang-Tidy and SonarQube.
Deviations are documented directly in the source code as follows:

```c
// Intentional violation of MISRA: <some valid reason>
<... deviant construct ...>
```

The full list of deviations with the accompanying explanation can be found by grepping the sources.

Do not suppress compliance warnings using the means provided by static analysis tools because such deviations
are impossible to track at the source code level.
An exception applies for the case of false-positive (invalid) warnings -- those should not be mentioned in the codebase.

[Zubax C++ Coding Conventions](https://kb.zubax.com/x/84Ah) shall be followed.
Formatting is enforced by Clang-Format; it is used also to fail the CI/CD build if violations are detected.

Unfortunately, some rules are hard or impractical to enforce automatically,
so code reviewers shall be aware of MISRA and general high-reliability coding practices
to prevent non-compliant code from being accepted into upstream.

## Tools

The following tools are required to conduct library development locally:

- GCC v9 or newer.
pavel-kirienko marked this conversation as resolved.
Show resolved Hide resolved
- Clang and Clang-Tools v9 or newer.
- CMake v3.12 or newer.
- An AMD64 machine.

### Clang-Tidy

Clang-Tidy is used to enforce compliance with MISRA and Zubax Coding Conventions.
There are separate configuration files per directory:

- `/libcanard/` (the production code) is equipped with the most stringent configuration.

- `/tests/` is equipped with a separate configuration which omits certain rules that are considered
expensive to maintain.
This is because the test suite is intentionally kept to a somewhat lower quality bar to reduce development costs.

Clang-Tidy is invoked automatically on each translation unit before it is compiled;
the build will fail if the tool is not available locally.
To disable this behavior, pass `NO_STATIC_ANALYSIS=1` to CMake at the generation time.

### Clang-Format

Clang-Format is used to enforce compliance with MISRA and Zubax Coding Conventions.
There is a single configuration file at the root of the repository.

To reformat the sources, generate the project and build the target `format`; e.g., for Make: `make format`.

### SonarQube

SonarQube is a cloud solution so its use is delegated to the CI/CD pipeline.
If you need access, please get in touch with the UAVCAN Development Team members.

### IDE

The recommended development environment is JetBrains CLion. The root project file is `tests/CMakeLists.txt`.
thirtytwobits marked this conversation as resolved.
Show resolved Hide resolved
The repository contains the spelling dictionaries for CLion located under `.idea/`, make sure to use them.

## Testing

Generate the CMake project, build all, and then build the target `test` (e.g., `make test`).
The tests are built for x86 and x86_64; the latter is why an AMD64 machine is required for local development.

At the moment, the library is not being tested against other platforms.
We would welcome contributions implementing CI/CD testing against popular embedded architectures, particularly
the ARM Cortex M series and AVR in an emulator.
As a high-integrity library, the Libcanard test suite should provide full test coverage for all commonly used platforms.
Loading