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

Replace the implementation #51

Merged
merged 7 commits into from
Aug 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions libudpard/.clang-tidy → .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
151 changes: 130 additions & 21 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,165 @@ jobs:
cxx-compiler: clang++
steps:
- uses: actions/checkout@v3
with:
submodules: true
# 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
with:
submodules: true
# 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
submodules: true
- uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
# language=bash
- run: |
clang --version
- 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
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[submodule "submodules/unity"]
path = submodules/unity
url = https://github.com/ThrowTheSwitch/Unity
47 changes: 47 additions & 0 deletions .idea/dictionaries/pavel.xml

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

29 changes: 29 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# This software is distributed under the terms of the MIT License.
# Copyright (C) OpenCyphal Development Team <opencyphal.org>
# Copyright Amazon.com Inc. or its affiliates.
# SPDX-License-Identifier: MIT
# Author: Pavel Kirienko <[email protected]>
#
# This file is only needed for library development and testing. It is not needed to use the library in your project;
# instead, users should integrate the library by copying its source files.

cmake_minimum_required(VERSION 3.20)

project(udpard)
enable_testing()

# Shared Clang-Format target for all subprojects.
find_program(clang_format NAMES clang-format)
if (NOT clang_format)
message(STATUS "Could not locate clang-format")
else ()
file(GLOB_RECURSE format_files
${CMAKE_CURRENT_SOURCE_DIR}/demo/*.[ch]
${CMAKE_CURRENT_SOURCE_DIR}/libudpard/*.[ch]
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.[ch]
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.[ch]pp)
message(STATUS "Using clang-format: ${clang_format}; files: ${format_files}")
add_custom_target(format COMMAND ${clang_format} -i -fallback-style=none -style=file --verbose ${format_files})
endif ()

add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)
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
Loading