Skip to content
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
File renamed without changes.
4 changes: 2 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ jobs:
-DCMAKE_BUILD_TYPE=Debug
-DCMAKE_C_COMPILER=${{ matrix.c-compiler }}
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
tests
.
# language=bash
- run: |
cd ${{ github.workspace }}/build
Expand Down Expand Up @@ -72,7 +72,7 @@ jobs:
-DCMAKE_CXX_COMPILER=${{ matrix.cxx-compiler }}
-DCMAKE_CXX_FLAGS="${{ matrix.cxx-flags }}"
-DNO_STATIC_ANALYSIS=1
tests
.
# language=bash
- run: |
cd ${{ github.workspace }}/build
Expand Down
File renamed without changes.
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 <pavel@opencyphal.org>
#
# 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)
96 changes: 0 additions & 96 deletions libudpard/.clang-format

This file was deleted.

18 changes: 13 additions & 5 deletions libudpard/udpard.h
Original file line number Diff line number Diff line change
Expand Up @@ -390,11 +390,11 @@ struct UdpardMemoryResource
/// datagrams ready for transmission are not enqueued into the local prioritized queue but instead are sent directly
/// to the network interface driver using a dedicated callback. The callback would accept not just a single
/// chunk of data but a list of three chunks to avoid copying the source transfer payload: the datagram header,
/// the payload, and (only for the last frame) the CRC. The driver would then use some form of vectorized IO to
/// transmit the data; the advantage of this approach is that up to two data copy operations are eliminated from the
/// stack and the memory allocator is not used at all. The disadvantage is that if the driver callback is blocking,
/// the application thread will be blocked as well; plus the driver will be responsible for the correct prioritization
/// of the outgoing datagrams according to the DSCP value.
/// the payload, and (only for the last frame) the CRC. The driver would then use some form of vectorized IO or
/// MSG_MORE/UDP_CORK to transmit the data; the advantage of this approach is that up to two data copy operations are
/// eliminated from the stack and the memory allocator is not used at all. The disadvantage is that if the driver
/// callback is blocking, the application thread will be blocked as well; plus the driver will be responsible
/// for the correct prioritization of the outgoing datagrams according to the DSCP value.
struct UdpardTx
{
/// Pointer to the node-ID of the local node, which is used to populate the source node-ID field of outgoing
Expand Down Expand Up @@ -523,6 +523,14 @@ int_fast8_t udpardTxInit(struct UdpardTx* const self,
/// The library itself, however, does not use or check this value in any way, so it can be zero if not needed
/// (this is not recommended for real-time systems).
///
/// Note that due to the priority ordering, transient transfer loss may occur if the user increases the priority
/// level on a given port. This is because the frames of the new transfer will be enqueued before the frames of
/// the previous transfer, so the frames of the previous transfer will be transmitted only after the frames of
/// the new transfer are transmitted, causing the receiver to discard them as duplicates due to their lower transfer-ID.
/// To avoid this, it is necessary to wait for all frames originating from the port to be delivered before increasing
/// the priority level on the port. The "user_transfer_reference" may help here as it allows the user to establish
/// traceability from enqueued transfer frames (datagrams) back to the port they originate from.
///
/// The function returns the number of UDP datagrams enqueued, which is always a positive number, in case of success.
/// In case of failure, the function returns a negated error code.
///
Expand Down
1 change: 1 addition & 0 deletions tests/.clang-tidy
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
# The tests are held to somewhat lower quality standards than production code.
# The tests are also written in somewhat non-idiomatic C++ because they are tightly related to the C codebase.
InheritParentConfig: true
Checks: >-
boost-*,
bugprone-*,
Expand Down
21 changes: 5 additions & 16 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# This software is distributed under the terms of the MIT License.
# Copyright (c) OpenCyphal.
# Copyright (C) OpenCyphal Development Team <opencyphal.org>
# Copyright Amazon.com Inc. or its affiliates.
# SPDX-License-Identifier: MIT
# Author: Pavel Kirienko <pavel@opencyphal.org>

cmake_minimum_required(VERSION 3.12)
Expand All @@ -14,8 +16,8 @@ enable_testing()
set(CTEST_OUTPUT_ON_FAILURE ON)
set(NO_STATIC_ANALYSIS OFF CACHE BOOL "disable udpard static analysis")

set(library_dir "${CMAKE_SOURCE_DIR}/../libudpard")
set(unity_root "${CMAKE_CURRENT_SOURCE_DIR}/../submodules/unity")
set(library_dir "${CMAKE_SOURCE_DIR}/libudpard")
set(unity_root "${CMAKE_SOURCE_DIR}/submodules/unity")

# Use -DNO_STATIC_ANALYSIS=1 to suppress static analysis.
# If not suppressed, the tools used here shall be available, otherwise the build will fail.
Expand All @@ -28,19 +30,6 @@ if (NOT NO_STATIC_ANALYSIS)
message(STATUS "Using clang-tidy: ${clang_tidy}")
endif ()

# clang-format
find_program(clang_format NAMES clang-format)
if (NOT clang_format)
message(STATUS "Could not locate clang-format")
else ()
file(GLOB_RECURSE format_files
${library_dir}/*.[ch]
${CMAKE_SOURCE_DIR}/src/*.[ch]
${CMAKE_SOURCE_DIR}/src/*.[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 ()

function(gen_test name files compile_definitions compile_flags link_flags c_standard)
# Unity
add_library("${name}_unity" STATIC "${unity_root}/src/unity.c")
Expand Down
Loading