Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
fff1551
Add JetBrains CLion directory with teh dictionary (CLion is superior …
pavel-kirienko Jun 26, 2023
6cb16c8
Temporarily drop the codebase and the tests, ensure everything builds…
pavel-kirienko Jun 26, 2023
0f7d43b
Update the CI workflow; Sonar is not yet reintroduced
pavel-kirienko Jun 26, 2023
e47f078
Autoformat
pavel-kirienko Jun 26, 2023
dfe2883
API rework WIP
pavel-kirienko Jun 27, 2023
c21d261
Refine the API; the general structure is there but the docs are missing
pavel-kirienko Jun 27, 2023
32ac521
Make the tests green
pavel-kirienko Jun 28, 2023
831f95c
Drop docker
pavel-kirienko Jun 28, 2023
f129f64
Fix language standards
pavel-kirienko Jun 28, 2023
8001fd7
Use parallel build in the CI
pavel-kirienko Jun 28, 2023
20212e2
Improve diagnostic snapshot uploading
pavel-kirienko Jun 28, 2023
ebdc647
Bye bye Catch2, hello Google Test
pavel-kirienko Jun 28, 2023
6de85cc
Eliminate unnecessary static casts and add a misoptimization workaround
pavel-kirienko Jun 28, 2023
d9480dd
Another misoptimization?
pavel-kirienko Jun 28, 2023
5a4a11c
Disable strict aliasing for GCC
pavel-kirienko Jun 28, 2023
5ed5f9b
Add run_sonar.sh; it is not yet invoked from the CI workflow
pavel-kirienko Jun 28, 2023
4483d1a
Configure #sonar workflow
pavel-kirienko Jun 28, 2023
8e66302
#sonar
pavel-kirienko Jun 28, 2023
2884eab
Add a summy test to help with coverage setup #sonar
pavel-kirienko Jun 28, 2023
5f201a3
#sonar
pavel-kirienko Jun 28, 2023
845c155
Add preface docs
pavel-kirienko Jun 29, 2023
5eed978
Describe the tx pipeline
pavel-kirienko Jun 29, 2023
fc28d6c
Subsription pipeline
pavel-kirienko Jun 29, 2023
0e8c88f
Finish the API docs
pavel-kirienko Jun 29, 2023
b509b85
31 char max
pavel-kirienko Jun 29, 2023
570f5d0
Proofread
pavel-kirienko Jun 29, 2023
d1c829e
Address the feedback
pavel-kirienko Jun 30, 2023
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
158 changes: 139 additions & 19 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
name: Main Workflow
on: [push, pull_request]
on: [ push, pull_request ]
env:
LLVM_VERSION: 13
LLVM_VERSION: 15
jobs:
debug:
if: github.event_name == 'push'
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts20.4.1
container: ghcr.io/opencyphal/toolshed:ts22.4.3
strategy:
matrix:
toolchain: ['clang', 'gcc']
toolchain: [ 'clang', 'gcc' ]
include:
- toolchain: gcc
c-compiler: gcc
Expand All @@ -18,57 +19,176 @@ jobs:
cxx-compiler: clang++
steps:
- uses: actions/checkout@v3
# language=bash
- run: |
# TODO https://github.com/OpenCyphal/docker_toolchains/issues/36
dpkg --add-architecture i386
apt-get update
apt-get install -y libgtest-dev libgtest-dev:i386
# language=bash
- run: >
cmake
-B ${{ github.workspace }}/build
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
tests
- name: make
run: |
# language=bash
- run: |
cd ${{ github.workspace }}/build
make VERBOSE=1
make test
- uses: actions/upload-artifact@v2
make VERBOSE=1 -j$(nproc)
make test ARGS="--verbose"
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{github.job}}
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
# Shall it break one day, feel free to remove the matrix from here.
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
path: ${{github.workspace}}/**/*
retention-days: 2

optimizations:
if: github.event_name == 'push'
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts20.4.1
container: ghcr.io/opencyphal/toolshed:ts22.4.3
strategy:
matrix:
toolchain: ['clang', 'gcc']
build_type: [Release, MinSizeRel]
toolchain: [ 'clang', 'gcc' ]
build_type: [ Release, MinSizeRel ]
include:
- toolchain: gcc
c-compiler: gcc
cxx-compiler: g++
cxx-flags: -fno-strict-aliasing # GCC in MinSizeRel C++20 mode misoptimizes the Cavl test.
- toolchain: clang
c-compiler: clang
cxx-compiler: clang++
steps:
- uses: actions/checkout@v3
# language=bash
- run: |
# TODO https://github.com/OpenCyphal/docker_toolchains/issues/36
dpkg --add-architecture i386
apt-get update
apt-get install -y libgtest-dev libgtest-dev:i386
# language=bash
- run: >
cmake
-B ${{ github.workspace }}/build
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
-DCMAKE_CXX_FLAGS="${{ matrix.cxx-flags }}"
-DNO_STATIC_ANALYSIS=1
tests
- name: make
run: |
# language=bash
- run: |
cd ${{ github.workspace }}/build
make VERBOSE=1
make test
- uses: actions/upload-artifact@v2
make VERBOSE=1 -j$(nproc)
make test ARGS="--verbose"
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{github.job}}
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
# Shall it break one day, feel free to remove the matrix from here.
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
path: ${{github.workspace}}/**/*
retention-days: 2

avr:
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
mcu: at90can64
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits
strategy:
matrix:
std: [ 'c99', 'c11', 'gnu99', 'gnu11' ]
steps:
- uses: actions/checkout@v3
# language=bash
- run: |
sudo apt update -y && sudo apt upgrade -y
sudo apt install gcc-avr avr-libc
avr-gcc --version
- run: avr-gcc libudpard/*.c -c -std=${{matrix.std}} -mmcu=${{env.mcu}} ${{env.flags}}

arm:
if: github.event_name == 'push'
runs-on: ubuntu-latest
env:
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits -Wcast-align -Wfatal-errors
strategy:
matrix:
std: [ 'c99', 'c11', 'gnu99', 'gnu11' ]
steps:
- uses: actions/checkout@v3
# language=bash
- run: |
sudo apt update -y && sudo apt upgrade -y
sudo apt-get install -y gcc-arm-none-eabi
- run: arm-none-eabi-gcc libudpard/*.c -c -std=${{matrix.std}} ${{ env.flags }}

sonar:
runs-on: ubuntu-latest
container: ghcr.io/opencyphal/toolshed:ts22.4.3
if: >
(
(github.event_name == 'pull_request' || contains(github.ref, '/main') || contains(github.ref, '/release')) &&
!contains(github.event.head_commit.message, '#yolo')
) || (
contains(github.event.head_commit.message, '#sonar')
)
env:
SONAR_SCANNER_VERSION: 4.8.0.2856
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/setup-java@v3
with:
java-version: 11
distribution: 'zulu'
# language=bash
- run: |
clang --version
# TODO https://github.com/OpenCyphal/docker_toolchains/issues/36
dpkg --add-architecture i386
apt-get update
apt-get install -y libgtest-dev libgtest-dev:i386
- name: Install Sonar tools
env:
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
BUILD_WRAPPER_DOWNLOAD_URL: https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
# language=bash
run: |
mkdir -p $HOME/.sonar
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
# Sonar is not run on builds originating from forks due to secrets not being available (avoids errors).
# language=bash
- run: |
[ -z "$SONAR_TOKEN" ] || tools/run_sonar.sh
- uses: actions/upload-artifact@v3
if: always()
with:
name: ${{github.job}}
path: ${{github.workspace}}/
retention-days: 3

style_check:
if: github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: DoozyX/[email protected]
with:
source: './libudpard ./tests'
extensions: 'c,h,cpp,hpp'
clangFormatVersion: ${{ env.LLVM_VERSION }}
22 changes: 4 additions & 18 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,52 +1,38 @@
# Object files
*.o
*.ko
*.obj
*.elf

# Precompiled Headers
*.gch
*.pch

# Libraries
*.lib
*.a
*.la
*.lo

# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib

# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex

# Debug files
*.dSYM/

# CMake build directory
build/
*build/
cmake-build-*/
build-avr/

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

# Pycache
__pycache__/
*.pyo
*.pyc
9 changes: 8 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ This package is a staging package to make changes before committing a pull reque

# Compact Cyphal/UDP v1 in C

Libudpard is a compact implementation of the Cyphal/UDP protocol stack in C99/C11 for high-integrity real-time
[![Main Workflow](https://github.com/OpenCyphal-Garage/libudpard/actions/workflows/main.yml/badge.svg)](https://github.com/OpenCyphal-Garage/libudpard/actions/workflows/main.yml)
[![Reliability Rating](https://sonarcloud.io/api/project_badges/measure?project=libudpard&metric=reliability_rating)](https://sonarcloud.io/summary?id=libudpard)
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=libudpard&metric=coverage)](https://sonarcloud.io/summary?id=libudpard)
[![Forum](https://img.shields.io/discourse/users.svg?server=https%3A%2F%2Fforum.opencyphal.org&color=1700b3)](https://forum.opencyphal.org)

LibUDPard is a compact implementation of the Cyphal/UDP protocol stack in C99/C11 for high-integrity real-time
embedded systems.

[Cyphal](https://opencyphal.org) is an open lightweight data bus standard designed for reliable intravehicular
communication in aerospace and robotic applications via CAN bus, UDP, and other robust transports.

We pronounce LibUDPard as *lib-you-dee-pee-ard*.

## WORK IN PROGRESS, NOT READY FOR FORMAL USE

**Read the docs in [`libudpard/udpard.h`](/libudpard/udpard.h).**
Expand Down
1 change: 1 addition & 0 deletions libudpard/.clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ Checks: >-
-cert-dcl03-c,
-hicpp-static-assert,
-misc-static-assert,
-modernize-macro-to-enum,
CheckOptions:
- key: readability-function-cognitive-complexity.Threshold
value: '99'
Expand Down
12 changes: 6 additions & 6 deletions libudpard/cavl.h → libudpard/_udpard_cavl.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ extern "C" {

// ---------------------------------------- PUBLIC API SECTION ----------------------------------------

/// Modified for use with Libudpard: expose the Cavl structure via public API as UdpardTreeNode.
/// Modified for use with LibUDPard: expose the Cavl structure via public API as UdpardTreeNode.
typedef UdpardTreeNode Cavl;

/// Returns POSITIVE if the search target is GREATER than the provided node, negative if smaller, zero on match (found).
Expand Down Expand Up @@ -118,7 +118,7 @@ static inline Cavl* cavlPrivateAdjustBalance(Cavl* const x, const bool increment
{
CAVL_ASSERT((x != NULL) && ((x->bf >= -1) && (x->bf <= +1)));
Cavl* out = x;
const int8_t new_bf = (int8_t)(x->bf + (increment ? +1 : -1));
const int8_t new_bf = (int8_t) (x->bf + (increment ? +1 : -1));
if ((new_bf < -1) || (new_bf > 1))
{
const bool r = new_bf < 0; // bf<0 if left-heavy --> right rotation is needed.
Expand All @@ -131,8 +131,8 @@ static inline Cavl* cavlPrivateAdjustBalance(Cavl* const x, const bool increment
cavlPrivateRotate(x, r);
if (0 == z->bf)
{
x->bf = (int8_t)(-sign);
z->bf = (int8_t)(+sign);
x->bf = (int8_t) (-sign);
z->bf = (int8_t) (+sign);
}
else
{
Expand All @@ -149,15 +149,15 @@ static inline Cavl* cavlPrivateAdjustBalance(Cavl* const x, const bool increment
cavlPrivateRotate(x, r);
if ((y->bf * sign) < 0)
{
x->bf = (int8_t)(+sign);
x->bf = (int8_t) (+sign);
y->bf = 0;
z->bf = 0;
}
else if ((y->bf * sign) > 0)
{
x->bf = 0;
y->bf = 0;
z->bf = (int8_t)(-sign);
z->bf = (int8_t) (-sign);
}
else
{
Expand Down
Loading