Skip to content

Commit

Permalink
Merge of Issue #346 "CAN sessions" (#360)
Browse files Browse the repository at this point in the history
Co-authored-by: Sergei Shirokov <sergei@Sergeis-Mac-mini.local>
Co-authored-by: Sergei Shirokov <sshirokov@malwarebytes.com>
Co-authored-by: Pavel Kirienko <pavel.kirienko@gmail.com>
  • Loading branch information
4 people committed May 15, 2024
1 parent ee5f1e2 commit 5e652de
Show file tree
Hide file tree
Showing 56 changed files with 5,695 additions and 600 deletions.
54 changes: 27 additions & 27 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,61 +1,61 @@
---
Language: Cpp
BasedOnStyle: LLVM
Language: Cpp
BasedOnStyle: LLVM
AccessModifierOffset: -4
AlignAfterOpenBracket: Align
AlignConsecutiveAssignments: true
AlignConsecutiveDeclarations: true
AlignEscapedNewlines: Left
AlignOperands: true
AlignOperands: true
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: false
AllowShortBlocksOnASingleLine: false
AllowShortBlocksOnASingleLine: Never
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: Empty
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: None
AlwaysBreakAfterReturnType: None
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
AlwaysBreakTemplateDeclarations: Yes
BinPackArguments: false
BinPackParameters: false
BreakBeforeBinaryOperators: None
BreakBeforeBraces: Custom
BraceWrapping:
SplitEmptyRecord: false
AfterEnum: true
AfterStruct: true
AfterClass: true
AfterControlStatement: true
AfterFunction: true
AfterUnion: true
AfterNamespace: true
AfterExternBlock: true
BeforeElse: true
SplitEmptyRecord: false
AfterEnum: true
AfterStruct: true
AfterClass: true
AfterControlStatement: true
AfterFunction: true
AfterUnion: true
AfterNamespace: true
AfterExternBlock: true
BeforeElse: true

BreakBeforeTernaryOperators: true
BreakConstructorInitializers: BeforeComma
BreakStringLiterals: true
ColumnLimit: 120
CommentPragmas: '^ (coverity|pragma:)'
ColumnLimit: 120
CommentPragmas: '^ (coverity|NOSONAR|pragma:)'
CompactNamespaces: false
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
DisableFormat: false
FixNamespaceComments: true
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IncludeBlocks: Preserve
IndentCaseLabels: false
IndentPPDirectives: AfterHash
IndentWidth: 4
IndentWidth: 4
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: false
MacroBlockBegin: ''
MacroBlockEnd: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: None
PenaltyBreakAssignment: 2
Expand All @@ -66,21 +66,21 @@ PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 10000 # Raised intentionally because it hurts readability
PointerAlignment: Left
ReflowComments: true
SortIncludes: false
ReflowComments: true
SortIncludes: Never
SortUsingDeclarations: false
SpaceAfterCStyleCast: true
SpaceAfterTemplateKeyword: true
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInAngles: false
SpacesInCStyleCastParentheses: false
SpacesInContainerLiterals: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 8
UseTab: Never
Standard: c++14
TabWidth: 8
UseTab: Never
...
37 changes: 37 additions & 0 deletions .clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Checks: >-
boost-*,
bugprone-*,
cert-*,
clang-analyzer-*,
cppcoreguidelines-*,
google-*,
hicpp-*,
llvm-*,
misc-*,
modernize-*,
performance-*,
portability-*,
readability-*,
-clang-analyzer-core.uninitialized.Assign,
-cppcoreguidelines-avoid-const-or-ref-data-members,
-cppcoreguidelines-use-default-member-init,
-google-readability-avoid-underscore-in-googletest-name,
-google-readability-todo,
-llvm-header-guard,
-modernize-concat-nested-namespaces,
-modernize-type-traits,
-modernize-use-constraints,
-modernize-use-default-member-init,
-modernize-use-nodiscard,
-readability-avoid-const-params-in-decls,
-readability-identifier-length,
-*-use-trailing-return-type,
-*-named-parameter,
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: '90'
- key: readability-magic-numbers.IgnoredIntegerValues
value: '1;2;3;4;5;8;10;16;20;32;60;64;100;128;256;500;512;1000'
WarningsAsErrors: '*'
HeaderFilterRegex: 'include/libcyphal/.*\.hpp'
FormatStyle: file
2 changes: 1 addition & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "linux development environment for libcyphal",
"image": "ghcr.io/opencyphal/toolshed:ts22.4.3",
"image": "ghcr.io/opencyphal/toolshed:ts22.4.7",
"customizations": {
"vscode": {
"extensions": [
Expand Down
79 changes: 79 additions & 0 deletions .github/workflows/sonar.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
name: "libcyphal_sonar"

on:
push: # Further filtering is done in the jobs.
pull_request:
branches:
- main
- 'issue/*'

jobs:
sonarcloud:
if: >
contains(github.event.head_commit.message, '#sonar') ||
contains(github.ref, '/main') ||
contains(github.ref, '/issue/') ||
(github.event_name == 'pull_request')
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts22.4.7
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: get nunavut
run: >
pip install nunavut
- name: Install sonar-scanner and build-wrapper
uses: SonarSource/sonarcloud-github-c-cpp@v2
- name: Run tests
env:
GTEST_COLOR: yes
run: >
./build-tools/bin/verify.py
--verbose
--online
--no-exceptions
--cpp-standard 14
--build-flavor Coverage
--toolchain gcc
test
- name: Generate XML coverage report
run: |
cd build
cmake --build . --target test/unittest/coverage.xml
cmake --build . --target docs/examples/coverage.xml
- name: upload-artifacts
uses: actions/upload-artifact@v4
with:
name: Coverage-14-gcc
path: |
build/compile_commands.json
build/*/**/coverage.xml
build/*/**/*-sonarqube.xml
build/*/**/gcovr_html/*.*
if-no-files-found: error
- name: Run sonar-scanner
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
run: >
sonar-scanner
-X
--define sonar.organization=opencyphal-garage
--define sonar.projectKey=OpenCyphal-Garage_libcyphal
--define sonar.projectName=libcyphal
--define sonar.projectVersion=1.0
--define sonar.sources=include,test/unittest/sonar.cpp
--define sonar.tests=test/unittest,docs/examples
--define sonar.test.inclusions=test_*.cpp,example_*.cpp
--define sonar.sourceEncoding=UTF-8
--define sonar.host.url=https://sonarcloud.io
--define sonar.cfamily.ignoreHeaderComments=false
--define sonar.coverage.exclusions="test/unittest/**/*,docs/examples/**/*,**/sonar.cpp"
--define sonar.cpd.exclusions="test/unittest/**/*,docs/examples/**/*,**/sonar.cpp"
--define sonar.cfamily.compile-commands="build/compile_commands.json"
--define sonar.cfamily.reportingCppStandardOverride=c++14
--define sonar.coverageReportPaths="build/test/unittest/coverage.xml,build/docs/examples/coverage.xml"
--define sonar.issue.ignore.multicriteria=r1
--define sonar.issue.ignore.multicriteria.r1.ruleKey=cpp:S3230
--define sonar.issue.ignore.multicriteria.r1.resourceKey=**
12 changes: 5 additions & 7 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: "libcyphal_test"
name: "libcyphal_tests"

on:
push: # Further filtering is done in the jobs.
Expand All @@ -16,7 +16,7 @@ jobs:
contains(github.ref, '/issue/') ||
(github.event_name == 'pull_request')
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts22.4.3
container: ghcr.io/opencyphal/toolshed:ts22.4.7
steps:
- uses: actions/checkout@v4
- name: Cache ext modules
Expand Down Expand Up @@ -47,7 +47,7 @@ jobs:
contains(github.ref, '/issue/') ||
(github.event_name == 'pull_request')
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts22.4.3
container: ghcr.io/opencyphal/toolshed:ts22.4.7
needs: [warmup]
strategy:
matrix:
Expand Down Expand Up @@ -77,7 +77,7 @@ jobs:
run: >
./build-tools/bin/verify.py
--verbose
--asserts
${{ matrix.build_flavor != 'Coverage' && '--asserts' || '--no-exceptions' }}
--cpp-standard ${{ matrix.std }}
--build-flavor ${{ matrix.build_flavor }}
--toolchain ${{ matrix.toolchain }}
Expand All @@ -91,8 +91,6 @@ jobs:
name: ${{ matrix.build_flavor }}-${{ matrix.std }}-${{ matrix.toolchain }}
path: |
build/compile_commands.json
build/*/**/coverage.xml
build/*/**/*-sonarqube.xml
build/*/**/gcovr_html/*.*
if-no-files-found: error

Expand All @@ -103,7 +101,7 @@ jobs:
contains(github.ref, '/issue/') ||
(github.event_name == 'pull_request')
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts22.4.3
container: ghcr.io/opencyphal/toolshed:ts22.4.7
needs: [warmup]
steps:
- uses: actions/checkout@v4
Expand Down
13 changes: 12 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,17 @@ project(libcyphal
HOMEPAGE_URL https://github.com/OpenCyphal-Garage/libcyphal
)

# Use -DNO_STATIC_ANALYSIS=1 to suppress static analysis.
# If not suppressed, the tools used here shall be available, otherwise the build will fail.
if (NOT NO_STATIC_ANALYSIS)
# clang-tidy (separate config files per directory)
find_program(clang_tidy NAMES clang-tidy)
if (NOT clang_tidy)
message(FATAL_ERROR "Could not locate clang-tidy")
endif ()
message(STATUS "Using clang-tidy: ${clang_tidy}")
endif ()

add_subdirectory(test/unittest)
add_subdirectory(docs)

Expand Down Expand Up @@ -62,7 +73,7 @@ if (${CMAKE_CXX_PLATFORM_ID} STREQUAL "Linux")
endif()

# Don't normalize deviance: if CMAKE_TOOLCHAIN_FILE is not set then provide
# an initalized default to display in the status thus avoiding a warning about
# an initialized default to display in the status thus avoiding a warning about
# using an uninitialized variable.
if (NOT CMAKE_TOOLCHAIN_FILE)
set(LOCAL_CMAKE_TOOLCHAIN_FILE "(not set)")
Expand Down
6 changes: 3 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -147,10 +147,10 @@ and manually run it.

### TLDR
```
docker pull ghcr.io/opencyphal/toolshed:ts22.4.3
docker pull ghcr.io/opencyphal/toolshed:ts22.4.7
git clone {this repo}
cd {this repo}
docker run --rm -it -v ${PWD}:/repo ghcr.io/opencyphal/toolshed:ts22.4.3
docker run --rm -it -v ${PWD}:/repo ghcr.io/opencyphal/toolshed:ts22.4.7
mkdir build
cd build
cmake ..
Expand Down Expand Up @@ -200,7 +200,7 @@ To ensure that the formatting matches the expectations of the CI suite,
invoke Clang-Format of the correct version from the container (be sure to use the correct image tag):

```
docker run --rm -v ${PWD}:/repo ghcr.io/opencyphal/toolshed:ts22.4.3 ./build-tools/bin/verify.py build-danger-danger-repo-clang-format-in-place
docker run --rm -v ${PWD}:/repo ghcr.io/opencyphal/toolshed:ts22.4.7 ./build-tools/bin/verify.py build-danger-danger-repo-clang-format-in-place
```

### `issue/*` and hashtag-based CI triggering
Expand Down
7 changes: 3 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
![Cyphal](docs/images/html/opencyphal_logo.svg) Cyphal stack in C++
===================

[![Build Status](https://badge.buildkite.com/af844974c06af6406e3b2192d98298b02b30f6ebebb5f8b16c.svg)](https://buildkite.com/uavcan/libcyphal-v1)
[![Build Status](https://github.com/OpenCyphal-Garage/libcyphal/actions/workflows/tests.yml/badge.svg)](https://github.com/OpenCyphal-Garage/libcyphal)
[![Forum](https://img.shields.io/discourse/https/forum.opencyphal.org/users.svg)](https://forum.opencyphal.org)
[![Sonarqube Badge](https://sonarcloud.io/api/project_badges/measure?project=UAVCAN_libuavcan&metric=alert_status)](https://sonarcloud.io/dashboard?id=UAVCAN_libuavcan)
[![Sonarqube Coverage](https://sonarcloud.io/api/project_badges/measure?project=UAVCAN_libuavcan&metric=coverage)](https://sonarcloud.io/dashboard?id=UAVCAN_libuavcan)
[![Sonarqube Badge](https://sonarcloud.io/api/project_badges/measure?project=OpenCyphal-Garage_libcyphal&metric=alert_status)](https://sonarcloud.io/project/overview?id=OpenCyphal-Garage_libcyphal)
[![Sonarqube Coverage](https://sonarcloud.io/api/project_badges/measure?project=OpenCyphal-Garage_libcyphal&metric=coverage)](https://sonarcloud.io/project/overview?id=OpenCyphal-Garage_libcyphal)
[![Documentation](https://img.shields.io/badge/docs-passing-green.svg)](https://opencyphal.org/libcyphal/)

> **WARNING** libcyphal v1 is not yet complete. This is a work-in-progress.
Portable reference implementation of the [Cyphal protocol stack](https://opencyphal.org) in C++ for embedded systems, Linux, and POSIX-compliant RTOSs.

Cyphal is a lightweight protocol designed for reliable communication in aerospace and robotic applications over robust vehicular networks.

2 changes: 2 additions & 0 deletions build-tools/bin/verify.py
Original file line number Diff line number Diff line change
Expand Up @@ -669,6 +669,8 @@ def _cmake_configure(args: argparse.Namespace, cmake_args: typing.List[str]) ->

# --[BUILD FLAVOR]-------------------------------------
cmake_configure_args.append("-DCMAKE_BUILD_TYPE={}".format(args.build_flavor))
if args.build_flavor == "Coverage":
cmake_configure_args.append("-DNO_STATIC_ANALYSIS:BOOL=ON")

# --[COMPILER FLAGS]-----------------------------------
flag_set_dir = _test_suite_dir(args) / pathlib.Path("cmake") / pathlib.Path("compiler_flag_sets")
Expand Down
1 change: 1 addition & 0 deletions cmake/compiler_flag_sets/default.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ if (CMAKE_BUILD_TYPE STREQUAL "Release")
message(DEBUG "Release build. Setting optimization flags.")
list(APPEND C_FLAG_SET
"-O1"
"-fno-delete-null-pointer-checks" # https://github.com/OpenCyphal-Garage/libcyphal/pull/347#discussion_r1572254288
)
else()

Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findcetl.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

include(FetchContent)
set(cetl_GIT_REPOSITORY "https://github.com/OpenCyphal/cetl.git")
set(cetl_GIT_TAG "884f3b38e7857daa790ed6ba7031f7037fb81a2e")
set(cetl_GIT_TAG "63a118441a80078ebfeabf509c342bc0480a50b2")

FetchContent_Declare(
cetl
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findlibcanard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
include(FetchContent)

set(libcanard_GIT_REPOSITORY "https://github.com/OpenCyphal/libcanard.git")
set(libcanard_GIT_TAG "69ed329db4ae31d9c85dbe052434f60e552cecbe")
set(libcanard_GIT_TAG "3.2.0")

FetchContent_Declare(
libcanard
Expand Down
2 changes: 1 addition & 1 deletion cmake/modules/Findlibudpard.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ include(FindPackageHandleStandardArgs)
include(ProjectLibrary)

set(libudpard_GIT_REPOSITORY "https://github.com/OpenCyphal-garage/libudpard.git")
set(libudpard_GIT_TAG "89f87abf000cbe358b8e4974a52793c6dea12bd4")
set(libudpard_GIT_TAG "6c7c12ef1db0338684c536167dc4ba6dc7fa8b5a")

FetchContent_Declare(
libudpard
Expand Down

0 comments on commit 5e652de

Please sign in to comment.