Skip to content

Commit a6980ac

Browse files
Replace the implementation (#51)
As the library is functionally complete and is usable, I would like to continue further development against the main branch. The current version number is set to v0.1. There have been no pushes to `main2` since #48. - closes #40 - closes #32 - closes #29 - closes #28 - closes #26 - closes #24 - closes #22 - closes #21 - closes #16 - closes #14 - closes #13 - closes #10 - closes #7 - closes #5
1 parent 32ff7e9 commit a6980ac

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+9892
-17914
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Checks: >-
2121
-cert-dcl03-c,
2222
-hicpp-static-assert,
2323
-misc-static-assert,
24+
-modernize-macro-to-enum,
2425
CheckOptions:
2526
- key: readability-function-cognitive-complexity.Threshold
2627
value: '99'

.github/workflows/main.yml

Lines changed: 130 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,15 @@
11
name: Main Workflow
2-
on: [push, pull_request]
2+
on: [ push, pull_request ]
33
env:
4-
LLVM_VERSION: 13
4+
LLVM_VERSION: 15
55
jobs:
66
debug:
7+
if: github.event_name == 'push'
78
runs-on: ubuntu-latest
8-
container: ghcr.io/opencyphal/toolshed:ts20.4.1
9+
container: ghcr.io/opencyphal/toolshed:ts22.4.3
910
strategy:
1011
matrix:
11-
toolchain: ['clang', 'gcc']
12+
toolchain: [ 'clang', 'gcc' ]
1213
include:
1314
- toolchain: gcc
1415
c-compiler: gcc
@@ -18,57 +19,165 @@ jobs:
1819
cxx-compiler: clang++
1920
steps:
2021
- uses: actions/checkout@v3
22+
with:
23+
submodules: true
24+
# language=bash
2125
- run: >
2226
cmake
2327
-B ${{ github.workspace }}/build
2428
-DCMAKE_BUILD_TYPE=Debug
2529
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
2630
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
27-
tests
28-
- name: make
29-
run: |
31+
.
32+
# language=bash
33+
- run: |
3034
cd ${{ github.workspace }}/build
31-
make VERBOSE=1
32-
make test
33-
- uses: actions/upload-artifact@v2
35+
make VERBOSE=1 -j$(nproc)
36+
make test ARGS="--verbose"
37+
- uses: actions/upload-artifact@v3
3438
if: always()
3539
with:
36-
name: ${{github.job}}
40+
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
41+
# Shall it break one day, feel free to remove the matrix from here.
42+
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
3743
path: ${{github.workspace}}/**/*
3844
retention-days: 2
3945

4046
optimizations:
47+
if: github.event_name == 'push'
4148
runs-on: ubuntu-latest
42-
container: ghcr.io/opencyphal/toolshed:ts20.4.1
49+
container: ghcr.io/opencyphal/toolshed:ts22.4.3
4350
strategy:
4451
matrix:
45-
toolchain: ['clang', 'gcc']
46-
build_type: [Release, MinSizeRel]
52+
toolchain: [ 'clang', 'gcc' ]
53+
build_type: [ Release, MinSizeRel ]
4754
include:
4855
- toolchain: gcc
4956
c-compiler: gcc
5057
cxx-compiler: g++
58+
cxx-flags: -fno-strict-aliasing # GCC in MinSizeRel C++20 mode misoptimizes the Cavl test.
5159
- toolchain: clang
5260
c-compiler: clang
5361
cxx-compiler: clang++
5462
steps:
5563
- uses: actions/checkout@v3
64+
with:
65+
submodules: true
66+
# language=bash
5667
- run: >
5768
cmake
5869
-B ${{ github.workspace }}/build
5970
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6071
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
6172
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
73+
-DCMAKE_CXX_FLAGS="${{ matrix.cxx-flags }}"
6274
-DNO_STATIC_ANALYSIS=1
63-
tests
64-
- name: make
65-
run: |
75+
.
76+
# language=bash
77+
- run: |
6678
cd ${{ github.workspace }}/build
67-
make VERBOSE=1
68-
make test
69-
- uses: actions/upload-artifact@v2
79+
make VERBOSE=1 -j$(nproc)
80+
make test ARGS="--verbose"
81+
- uses: actions/upload-artifact@v3
7082
if: always()
7183
with:
72-
name: ${{github.job}}
84+
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
85+
# Shall it break one day, feel free to remove the matrix from here.
86+
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
7387
path: ${{github.workspace}}/**/*
7488
retention-days: 2
89+
90+
avr:
91+
if: github.event_name == 'push'
92+
runs-on: ubuntu-latest
93+
env:
94+
mcu: at90can64
95+
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits
96+
strategy:
97+
matrix:
98+
std: [ 'c99', 'c11', 'gnu99', 'gnu11' ]
99+
steps:
100+
- uses: actions/checkout@v3
101+
# language=bash
102+
- run: |
103+
sudo apt update -y && sudo apt upgrade -y
104+
sudo apt install gcc-avr avr-libc
105+
avr-gcc --version
106+
- run: avr-gcc libudpard/*.c -c -std=${{matrix.std}} -mmcu=${{env.mcu}} ${{env.flags}}
107+
108+
arm:
109+
if: github.event_name == 'push'
110+
runs-on: ubuntu-latest
111+
env:
112+
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits -Wcast-align -Wfatal-errors
113+
strategy:
114+
matrix:
115+
std: [ 'c99', 'c11', 'gnu99', 'gnu11' ]
116+
steps:
117+
- uses: actions/checkout@v3
118+
# language=bash
119+
- run: |
120+
sudo apt update -y && sudo apt upgrade -y
121+
sudo apt-get install -y gcc-arm-none-eabi
122+
- run: arm-none-eabi-gcc libudpard/*.c -c -std=${{matrix.std}} ${{ env.flags }}
123+
124+
sonar:
125+
runs-on: ubuntu-latest
126+
container: ghcr.io/opencyphal/toolshed:ts22.4.3
127+
if: >
128+
(
129+
(github.event_name == 'pull_request' || contains(github.ref, '/main') || contains(github.ref, '/release')) &&
130+
!contains(github.event.head_commit.message, '#yolo')
131+
) || (
132+
contains(github.event.head_commit.message, '#sonar')
133+
)
134+
env:
135+
SONAR_SCANNER_VERSION: 4.8.0.2856
136+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
137+
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
138+
steps:
139+
- uses: actions/checkout@v3
140+
with:
141+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
142+
submodules: true
143+
- uses: actions/setup-java@v3
144+
with:
145+
java-version: 17
146+
distribution: 'zulu'
147+
# language=bash
148+
- run: |
149+
clang --version
150+
- name: Install Sonar tools
151+
env:
152+
SONAR_SCANNER_DOWNLOAD_URL: https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-${{ env.SONAR_SCANNER_VERSION }}-linux.zip
153+
BUILD_WRAPPER_DOWNLOAD_URL: https://sonarcloud.io/static/cpp/build-wrapper-linux-x86.zip
154+
# language=bash
155+
run: |
156+
mkdir -p $HOME/.sonar
157+
curl -sSLo $HOME/.sonar/sonar-scanner.zip ${{ env.SONAR_SCANNER_DOWNLOAD_URL }}
158+
unzip -o $HOME/.sonar/sonar-scanner.zip -d $HOME/.sonar/
159+
echo "$HOME/.sonar/sonar-scanner-${{ env.SONAR_SCANNER_VERSION }}-linux/bin" >> $GITHUB_PATH
160+
curl -sSLo $HOME/.sonar/build-wrapper-linux-x86.zip ${{ env.BUILD_WRAPPER_DOWNLOAD_URL }}
161+
unzip -o $HOME/.sonar/build-wrapper-linux-x86.zip -d $HOME/.sonar/
162+
echo "$HOME/.sonar/build-wrapper-linux-x86" >> $GITHUB_PATH
163+
# Sonar is not run on builds originating from forks due to secrets not being available (avoids errors).
164+
# language=bash
165+
- run: |
166+
[ -z "$SONAR_TOKEN" ] || tools/run_sonar.sh
167+
- uses: actions/upload-artifact@v3
168+
if: always()
169+
with:
170+
name: ${{github.job}}
171+
path: ${{github.workspace}}/
172+
retention-days: 3
173+
174+
style_check:
175+
if: github.event_name == 'push'
176+
runs-on: ubuntu-latest
177+
steps:
178+
- uses: actions/checkout@v3
179+
- uses: DoozyX/[email protected]
180+
with:
181+
source: './libudpard ./tests'
182+
extensions: 'c,h,cpp,hpp'
183+
clangFormatVersion: ${{ env.LLVM_VERSION }}

.gitignore

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,52 +1,38 @@
1-
# Object files
21
*.o
32
*.ko
43
*.obj
54
*.elf
6-
7-
# Precompiled Headers
85
*.gch
96
*.pch
10-
11-
# Libraries
127
*.lib
138
*.a
149
*.la
1510
*.lo
16-
17-
# Shared objects (inc. Windows DLLs)
1811
*.dll
1912
*.so
2013
*.so.*
2114
*.dylib
22-
23-
# Executables
2415
*.exe
2516
*.out
2617
*.app
2718
*.i*86
2819
*.x86_64
2920
*.hex
30-
31-
# Debug files
3221
*.dSYM/
33-
34-
# CMake build directory
35-
build/
22+
*build/
3623
cmake-build-*/
3724
build-avr/
38-
39-
# IDE and tools
4025
.metadata
4126
.settings
4227
.project
4328
.cproject
4429
.pydevproject
4530
.gdbinit
31+
.scannerwork/
4632
.vscode/
4733
**/.idea/*
4834
!**/.idea/dictionaries
4935
!**/.idea/dictionaries/*
50-
51-
# Pycache
5236
__pycache__/
37+
*.pyo
38+
*.pyc

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "submodules/unity"]
2+
path = submodules/unity
3+
url = https://github.com/ThrowTheSwitch/Unity

.idea/dictionaries/pavel.xml

Lines changed: 47 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CMakeLists.txt

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This software is distributed under the terms of the MIT License.
2+
# Copyright (C) OpenCyphal Development Team <opencyphal.org>
3+
# Copyright Amazon.com Inc. or its affiliates.
4+
# SPDX-License-Identifier: MIT
5+
# Author: Pavel Kirienko <[email protected]>
6+
#
7+
# This file is only needed for library development and testing. It is not needed to use the library in your project;
8+
# instead, users should integrate the library by copying its source files.
9+
10+
cmake_minimum_required(VERSION 3.20)
11+
12+
project(udpard)
13+
enable_testing()
14+
15+
# Shared Clang-Format target for all subprojects.
16+
find_program(clang_format NAMES clang-format)
17+
if (NOT clang_format)
18+
message(STATUS "Could not locate clang-format")
19+
else ()
20+
file(GLOB_RECURSE format_files
21+
${CMAKE_CURRENT_SOURCE_DIR}/demo/*.[ch]
22+
${CMAKE_CURRENT_SOURCE_DIR}/libudpard/*.[ch]
23+
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.[ch]
24+
${CMAKE_CURRENT_SOURCE_DIR}/tests/*.[ch]pp)
25+
message(STATUS "Using clang-format: ${clang_format}; files: ${format_files}")
26+
add_custom_target(format COMMAND ${clang_format} -i -fallback-style=none -style=file --verbose ${format_files})
27+
endif ()
28+
29+
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/tests)

README.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,19 @@ This package is a staging package to make changes before committing a pull reque
44

55
# Compact Cyphal/UDP v1 in C
66

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

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

18+
We pronounce LibUDPard as *lib-you-dee-pee-ard*.
19+
1320
## WORK IN PROGRESS, NOT READY FOR FORMAL USE
1421

1522
**Read the docs in [`libudpard/udpard.h`](/libudpard/udpard.h).**

0 commit comments

Comments
 (0)