Skip to content

Commit 9296213

Browse files
v3.0 WIP: experimental implementation of Cyphal v1.1 transport layer (#71)
This is not ready for production use. Find stable v1.0 and v2.0 in GitHub releases.
1 parent b6fbd4c commit 9296213

40 files changed

Lines changed: 12739 additions & 9917 deletions

.clang-format

Lines changed: 14 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,17 @@
1-
---
2-
Language: Cpp
3-
# BasedOnStyle: LLVM
4-
AccessModifierOffset: -4
5-
AlignAfterOpenBracket: Align
1+
Language: Cpp
2+
BasedOnStyle: Mozilla
3+
IndentWidth: 4
4+
ColumnLimit: 120
5+
Standard: c++20
6+
IndentExternBlock: NoIndent
7+
AlwaysBreakAfterDefinitionReturnType: None
8+
BreakAfterReturnType: None
9+
AllowShortFunctionsOnASingleLine: All
610
AlignConsecutiveAssignments: true
11+
AlignConsecutiveBitFields: true
712
AlignConsecutiveDeclarations: true
8-
AlignEscapedNewlines: Left
9-
AlignOperands: true
13+
AlignConsecutiveMacros: true
14+
AlignConsecutiveShortCaseStatements: { Enabled: true }
15+
AlignEscapedNewlines: LeftWithLastLine
1016
AlignTrailingComments: true
11-
AllowAllParametersOfDeclarationOnNextLine: false
12-
AllowShortBlocksOnASingleLine: false
13-
AllowShortCaseLabelsOnASingleLine: false
14-
AllowShortFunctionsOnASingleLine: Inline
15-
AllowShortIfStatementsOnASingleLine: Never
16-
AllowShortLoopsOnASingleLine: false
17-
AlwaysBreakAfterDefinitionReturnType: None
18-
AlwaysBreakAfterReturnType: None
19-
AlwaysBreakBeforeMultilineStrings: false
20-
AlwaysBreakTemplateDeclarations: Yes
21-
BinPackArguments: false
22-
BinPackParameters: false
23-
BraceWrapping:
24-
AfterCaseLabel: true
25-
AfterClass: true
26-
AfterControlStatement: true
27-
AfterEnum: true
28-
AfterFunction: true
29-
AfterNamespace: true
30-
AfterStruct: true
31-
AfterUnion: true
32-
BeforeCatch: true
33-
BeforeElse: true
34-
IndentBraces: false
35-
SplitEmptyFunction: false
36-
SplitEmptyRecord: false
37-
SplitEmptyNamespace: false
38-
AfterExternBlock: false # Keeps the contents un-indented.
39-
BreakBeforeBinaryOperators: None
40-
BreakBeforeBraces: Custom
41-
BreakBeforeTernaryOperators: true
42-
BreakConstructorInitializers: AfterColon
43-
# BreakInheritanceList: AfterColon
44-
BreakStringLiterals: true
45-
ColumnLimit: 120
46-
CommentPragmas: '^ (coverity|pragma:)'
47-
CompactNamespaces: false
48-
ConstructorInitializerAllOnOneLineOrOnePerLine: true
49-
ConstructorInitializerIndentWidth: 4
50-
ContinuationIndentWidth: 4
51-
Cpp11BracedListStyle: true
52-
DerivePointerAlignment: false
53-
DisableFormat: false
54-
ExperimentalAutoDetectBinPacking: false
55-
FixNamespaceComments: true
56-
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
57-
IncludeBlocks: Preserve
58-
IndentCaseLabels: false
59-
IndentPPDirectives: AfterHash
60-
IndentWidth: 4
61-
IndentWrappedFunctionNames: false
62-
KeepEmptyLinesAtTheStartOfBlocks: false
63-
MacroBlockBegin: ''
64-
MacroBlockEnd: ''
65-
MaxEmptyLinesToKeep: 1
66-
NamespaceIndentation: None
67-
PenaltyBreakAssignment: 2
68-
PenaltyBreakBeforeFirstCallParameter: 10000 # Raised intentionally; prefer breaking all
69-
PenaltyBreakComment: 300
70-
PenaltyBreakFirstLessLess: 120
71-
PenaltyBreakString: 1000
72-
PenaltyExcessCharacter: 1000000
73-
PenaltyReturnTypeOnItsOwnLine: 10000 # Raised intentionally because it hurts readability
74-
PointerAlignment: Left
75-
ReflowComments: true
76-
SortIncludes: false
77-
SortUsingDeclarations: false
78-
SpaceAfterCStyleCast: true
79-
SpaceAfterTemplateKeyword: true
80-
SpaceBeforeAssignmentOperators: true
81-
SpaceBeforeCpp11BracedList: false
82-
SpaceBeforeInheritanceColon: true
83-
SpaceBeforeParens: ControlStatements
84-
SpaceBeforeCtorInitializerColon: true
85-
SpaceBeforeRangeBasedForLoopColon: true
86-
SpaceInEmptyParentheses: false
87-
SpacesBeforeTrailingComments: 2
88-
SpacesInAngles: false
89-
SpacesInCStyleCastParentheses: false
90-
SpacesInContainerLiterals: false
91-
SpacesInParentheses: false
92-
SpacesInSquareBrackets: false
93-
Standard: Cpp11
94-
TabWidth: 8
95-
UseTab: Never
96-
...
17+
SortIncludes: false

.clang-tidy

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,11 +22,18 @@ Checks: >-
2222
-boost-use-ranges,
2323
-hicpp-static-assert,
2424
-misc-static-assert,
25-
-modernize-macro-to-enum,
26-
-cppcoreguidelines-macro-to-enum,
27-
-bugprone-casting-through-void,
25+
-*-macro-to-enum,
26+
-*-macro-usage,
27+
-*-enum-size,
28+
-*-use-using,
29+
-*-casting-through-void,
2830
-misc-include-cleaner,
2931
-cppcoreguidelines-avoid-do-while,
32+
-*-magic-numbers,
33+
-*-use-enum-class,
34+
-*-use-trailing-return-type,
35+
-*-deprecated-headers,
36+
-*-avoid-c-arrays,
3037
CheckOptions:
3138
- key: readability-function-cognitive-complexity.Threshold
3239
value: '99'

.gdbinit

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
skip make_frame_base
2+
skip make_frame
3+
skip cavl2_min

.github/workflows/main.yml

Lines changed: 64 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
container: ghcr.io/opencyphal/toolshed:ts24.4.3
1010
strategy:
1111
matrix:
12-
toolchain: [ 'clang', 'gcc' ]
12+
toolchain: [ "clang", "gcc" ]
1313
include:
1414
- toolchain: gcc
1515
c-compiler: gcc
@@ -24,23 +24,28 @@ jobs:
2424
# language=bash
2525
- run: >
2626
cmake
27-
-B ${{ github.workspace }}/build
27+
-B $GITHUB_WORKSPACE/build
2828
-DCMAKE_BUILD_TYPE=Debug
2929
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
3030
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
3131
.
3232
# language=bash
3333
- run: |
34-
cd ${{ github.workspace }}/build
34+
cd $GITHUB_WORKSPACE/build
3535
make VERBOSE=1 -j$(nproc)
3636
make test ARGS="--verbose"
37+
- name: Archive workspace
38+
if: always()
39+
run: |
40+
cd $GITHUB_WORKSPACE
41+
tar --use-compress-program="gzip -9" -cf $RUNNER_TEMP/workspace.tar.gz .
3742
- uses: actions/upload-artifact@v4
3843
if: always()
3944
with:
4045
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
4146
# Shall it break one day, feel free to remove the matrix from here.
4247
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
43-
path: ${{github.workspace}}/**/*
48+
path: ${{runner.temp}}/workspace.tar.gz
4449
retention-days: 2
4550

4651
optimizations:
@@ -49,13 +54,13 @@ jobs:
4954
container: ghcr.io/opencyphal/toolshed:ts24.4.3
5055
strategy:
5156
matrix:
52-
toolchain: [ 'clang', 'gcc' ]
57+
toolchain: [ "clang", "gcc" ]
5358
build_type: [ Release, MinSizeRel ]
5459
include:
5560
- toolchain: gcc
5661
c-compiler: gcc
5762
cxx-compiler: g++
58-
cxx-flags: -fno-strict-aliasing # GCC in MinSizeRel C++20 mode misoptimizes the Cavl test.
63+
cxx-flags: ""
5964
- toolchain: clang
6065
c-compiler: clang
6166
cxx-compiler: clang++
@@ -66,7 +71,7 @@ jobs:
6671
# language=bash
6772
- run: >
6873
cmake
69-
-B ${{ github.workspace }}/build
74+
-B $GITHUB_WORKSPACE/build
7075
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
7176
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
7277
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
@@ -75,35 +80,68 @@ jobs:
7580
.
7681
# language=bash
7782
- run: |
78-
cd ${{ github.workspace }}/build
83+
cd $GITHUB_WORKSPACE/build
7984
make VERBOSE=1 -j$(nproc)
8085
make test ARGS="--verbose"
86+
- name: Archive workspace
87+
if: always()
88+
run: |
89+
cd $GITHUB_WORKSPACE
90+
tar --use-compress-program="gzip -9" -cf $RUNNER_TEMP/workspace.tar.gz .
8191
- uses: actions/upload-artifact@v4
8292
if: always()
8393
with:
8494
# The matrix is shown for convenience but this is fragile because the values may not be string-convertible.
8595
# Shall it break one day, feel free to remove the matrix from here.
8696
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}-${{join(matrix.*, ',')}}
87-
path: ${{github.workspace}}/**/*
97+
path: ${{runner.temp}}/workspace.tar.gz
8898
retention-days: 2
8999

90-
avr:
100+
coverage:
91101
if: github.event_name == 'push'
92102
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' ]
103+
container: ghcr.io/opencyphal/toolshed:ts24.4.3
99104
steps:
100105
- uses: actions/checkout@v4
106+
with:
107+
submodules: true
108+
# language=bash
109+
- run: >
110+
cmake -B $GITHUB_WORKSPACE/build -DCMAKE_BUILD_TYPE=Debug -DNO_STATIC_ANALYSIS=ON -DENABLE_COVERAGE=ON .
101111
# language=bash
102112
- 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}}
113+
cd $GITHUB_WORKSPACE/build
114+
make -j$(nproc) && make test && make coverage
115+
- name: Archive workspace
116+
if: always()
117+
run: |
118+
cd $GITHUB_WORKSPACE
119+
tar --use-compress-program="gzip -9" -cf $RUNNER_TEMP/workspace.tar.gz .
120+
- uses: actions/upload-artifact@v4
121+
if: always()
122+
with:
123+
name: ${{github.job}}-#${{strategy.job-index}}-${{job.status}}
124+
path: ${{runner.temp}}/workspace.tar.gz
125+
retention-days: 30
126+
127+
# TODO: re-enable this
128+
# avr:
129+
# if: github.event_name == 'push'
130+
# runs-on: ubuntu-latest
131+
# env:
132+
# mcu: at90can64
133+
# flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits
134+
# strategy:
135+
# matrix:
136+
# std: [ 'c99', 'c11', 'gnu99', 'gnu11' ]
137+
# steps:
138+
# - uses: actions/checkout@v4
139+
# # language=bash
140+
# - run: |
141+
# sudo apt update -y && sudo apt upgrade -y
142+
# sudo apt install gcc-avr avr-libc
143+
# avr-gcc --version
144+
# - run: avr-gcc -Ilib/cavl/ libudpard/*.c -c -std=${{matrix.std}} -mmcu=${{env.mcu}} ${{env.flags}}
107145

108146
arm:
109147
if: github.event_name == 'push'
@@ -112,14 +150,14 @@ jobs:
112150
flags: -Wall -Wextra -Werror -pedantic -Wconversion -Wtype-limits -Wcast-align -Wfatal-errors
113151
strategy:
114152
matrix:
115-
std: [ 'c99', 'c11', 'gnu99', 'gnu11' ]
153+
std: [ "c99", "c11", "gnu99", "gnu11" ]
116154
steps:
117155
- uses: actions/checkout@v4
118156
# language=bash
119157
- run: |
120158
sudo apt update -y && sudo apt upgrade -y
121159
sudo apt-get install -y gcc-arm-none-eabi
122-
- run: arm-none-eabi-gcc libudpard/*.c -c -std=${{matrix.std}} ${{ env.flags }}
160+
- run: arm-none-eabi-gcc -Ilib/cavl/ libudpard/*.c -c -std=${{matrix.std}} ${{ env.flags }}
123161

124162
sonar:
125163
runs-on: ubuntu-latest
@@ -138,12 +176,12 @@ jobs:
138176
steps:
139177
- uses: actions/checkout@v4
140178
with:
141-
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
179+
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
142180
submodules: true
143181
- uses: actions/setup-java@v4
144182
with:
145183
java-version: 17
146-
distribution: 'zulu'
184+
distribution: "zulu"
147185
# language=bash
148186
- run: |
149187
clang --version
@@ -178,6 +216,6 @@ jobs:
178216
- uses: actions/checkout@v4
179217
- uses: DoozyX/clang-format-lint-action@v0.20
180218
with:
181-
source: './libudpard ./tests'
182-
extensions: 'c,h,cpp,hpp'
219+
source: "./libudpard ./tests"
220+
extensions: "c,h,cpp,hpp"
183221
clangFormatVersion: ${{ env.LLVM_VERSION }}

.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,17 @@
2020
*.hex
2121
*.dSYM/
2222
*build/
23+
build*/
2324
cmake-build-*/
24-
build-avr/
25+
.cache/
2526
.metadata
2627
.settings
2728
.project
2829
.cproject
2930
.pydevproject
30-
.gdbinit
3131
.scannerwork/
3232
.vscode/
33+
.sisyphus/
3334
**/.idea/*
3435
!**/.idea/dictionaries
3536
!**/.idea/dictionaries/*

.idea/dictionaries/project.xml

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

0 commit comments

Comments
 (0)