Skip to content

v5.0 alpha#258

Open
pavel-kirienko wants to merge 175 commits intomasterfrom
experimental
Open

v5.0 alpha#258
pavel-kirienko wants to merge 175 commits intomasterfrom
experimental

Conversation

@pavel-kirienko
Copy link
Member

v5 is a major rework based on the experience gained from extensive production use of the previous revisions. The API has been redesigned from scratch and as such there is no migration guide available; please refer to the examples and read the new canard.h to see how to use the library -- the new API is much more ergonomic than the old one.

Ignore the commit history, it will be squashed into a single commit.

Main changes:

  • Support for new protocols alongside Cyphal v1.0:

    • Cyphal/CAN v1.1, which adds support for 16-bit subject-IDs (like in UAVCAN v0) via a new CAN ID layout format.
    • UAVCAN v0 aka DroneCAN, a legacy predecessor to Cyphal v1.0 that is still widely used.
  • Anonymous messages can no longer be transmitted, but they can still be received.

  • A new passive node-ID autoconfiguration based on a simple occupancy observer.
    This method is decentralized and is compatible with old nodes.
    A node-ID can still be assigned manually if needed.

  • Automatic CAN acceptance filter configuration based on the current subscription set.
    The configuration is refreshed whenever the subscription set is modified or the local node-ID is changed.

  • New TX pipeline using per-transfer queue granularity with efficient CAN frame deduplication across redundant
    interfaces, which resulted in a major reduction of heap memory footprint (typ. x2+ reduction).

  • New RX pipeline supporting priority level preemption without transfer loss and reduced memory consumption.
    The old revision was susceptible to transfer loss when the remote initiated a higher-priority multi-frame
    transfer while a lower-priority multi-frame transfer was in flight. The v5 revision maintains concurrent
    reassemblers per priority level, enabling arbitrary priority nesting.

Closes #184
Closes #223
Closes #247

pavel-kirienko and others added 16 commits March 24, 2026 15:23
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Fix lcov branch_coverage option for lcov 1.14 (use lcov_branch_coverage).
Add tests for: tx_spool_v0 OOM mid-chain cleanup, tx_ensure_queue_space
sacrifice-NULL path, validation short-circuits in publish/subscribe APIs,
rx_parse rejection branches (self-addressing, reserved bits, anonymous
multi-frame), rx_filter_configure OOM and coalescence overflow,
canard_new/set_node_id/poll/ingest_frame NULL-argument guards, and
refcount inc/dec with NULL data.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…utOfRange

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Add gcovr-based Cobertura XML export and Coveralls upload to the
coverage CI job, with continue-on-error so Coveralls API flakiness
does not break the build. Add coverage badge to README.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
- Remove test_canard_publish_validation (subsumed by test_canard_publish_16b_validation)
- Remove test_v0_service_validation_branches (duplicate of test_canard_v0_service_validation)
- Remove test_rx_parse_v1_0_msg_bit23_reject (duplicate of test_rx_parse_v1_0_reserved_bit23_reject)
- Remove redundant sub-cases from test_rx_parse_v1_0_anon_multiframe_reject and
  test_rx_parse_v0_anon_multiframe_reject (already covered by test_rx_parse_anonymous_multi_frame_reject)
- Extract free_frame_chain() helper replacing 7 inline cleanup loops
- Rename coverage tests for naming consistency (test_*_validation_branches -> test_canard_*_validation)
- Dissolve ad-hoc "Group D" section, relocating tests to their logical groups
- Net reduction of 130 lines with no coverage regression

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@pavel-kirienko pavel-kirienko requested a review from Copilot March 24, 2026 15:18
@pavel-kirienko pavel-kirienko self-assigned this Mar 24, 2026
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Introduces the v5.0 alpha test/build infrastructure overhaul (migrating from Catch2-based tests to Unity-based intrusive + API black-box tests), along with supporting build/CI/demo updates and some AVL helper API extensions.

Changes:

  • Replaces legacy Catch2 tests with new Unity-based intrusive C tests and C++20 API-level tests; adds coverage targets and updated test documentation.
  • Updates CI workflows, build system layout (top-level CMake), and adds a SocketCAN heartbeat monitor demo.
  • Extends cavl2 API (remove semantics + new bound/replace helpers) and refreshes lint/format configs.

Reviewed changes

Copilot reviewed 46 out of 52 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
tests/test_self.cpp Removed legacy Catch2 allocator self-test (replaced by Unity helper tests).
tests/test_public_roundtrip.cpp Removed legacy Catch2 roundtrip stress test (replaced by new API/intrusive tests).
tests/test_public_filters.cpp Removed legacy Catch2 filter tests (filter testing moved/rewritten).
tests/test_private_tx.cpp Removed legacy Catch2 TX private tests (replaced by intrusive/API tests).
tests/test_private_crc.cpp Removed legacy Catch2 CRC test (replaced by API/intrusive coverage).
tests/src/test_intrusive_rx_admission.c Added intrusive adversarial tests for RX admission logic.
tests/src/test_intrusive_misc.c Added intrusive tests for occupancy observer, purge behavior, and TX collision handling.
tests/src/test_helpers.c Added Unity tests for the instrumented allocator helper.
tests/src/test_api_tx_queue.cpp Added C++20 Unity-based API tests for TX queue behavior and edge cases.
tests/src/test_api_tx.cpp Added C++20 Unity-based API tests for TX publish/request/respond/poll and v0/v1 encodings.
tests/src/helpers.h Added/ported shared test helpers (instrumented allocator, PRNG seeding, panic helpers).
tests/main.cpp Removed Catch2 main entrypoint.
tests/helpers.hpp Removed Catch2-era C++ helper layer.
tests/exposed.hpp Removed Catch2-era internal exposure header.
tests/canard_config_private.h Removed prior CANARD_PRIVATE test config header (intrusive tests now include canard.c).
tests/README.md Added updated testing guidance for intrusive vs API-level tests and coverage expectations.
tests/CMakeLists.txt Major rework: Unity integration, test matrix generation, optional coverage targets, new source layout.
tests/.clang-tidy Updated lint config and inherited parent configuration.
libcanard/.clang-tidy Updated lint suppressions/enablement for the library.
lib/unity Added Unity as a git submodule reference.
lib/cavl2/cavl2.h Extended API (replace/bounds helpers), changed remove signature, added inserted/remove_if.
demos/heartbeat_monitor.c Added SocketCAN demo that monitors Cyphal+DroneCAN heartbeats concurrently.
demos/CMakeLists.txt Added build target for the new demo.
README.md Updated badges, rewrote quick start and revision notes for v5 WIP.
MIGRATION_v3.x_to_v4.0.md Removed the v3→v4 migration guide from this branch.
CONTRIBUTING.md Removed contribution guide from this branch.
CMakeLists.txt Added new top-level build that wires tests and demos + static analysis/format checks.
CLAUDE.md Added pointer file for agent instructions.
AGENTS.md Added repository guidance for AI agents (style/testing/coverage).
.gitmodules Added Unity submodule configuration.
.gitignore Updated ignore patterns (build* and cache/tooling directories).
.github/workflows/main.yml Updated CI: submodules, llvm tooling, coverage publishing, removed sonar/style jobs.
.github/workflows/esp_publish.yml Updated checkout action version.
.github/workflows/esp_dry_run.yml Updated checkout action version.
.clang-format Replaced prior style config with a Mozilla-based configuration and custom foreach macros.
Files not reviewed (2)
  • .idea/dictionaries/pavel.xml: Language not supported
  • .idea/dictionaries/project.xml: Language not supported
Comments suppressed due to low confidence (3)

tests/src/test_intrusive_misc.c:1

  • This file defines setUp()/tearDown() twice, which will fail to compile due to redefinition. Remove one pair (prefer keeping a single definition near the test harness at the bottom), or mark the earlier ones static with different names if they serve a separate purpose.
    tests/src/test_intrusive_misc.c:1
  • This file defines setUp()/tearDown() twice, which will fail to compile due to redefinition. Remove one pair (prefer keeping a single definition near the test harness at the bottom), or mark the earlier ones static with different names if they serve a separate purpose.
    tests/src/test_api_tx_queue.cpp:1
  • std::memcpy(rec.data, bytes, can_data.size) assumes can_data.size <= sizeof(rec.data) (64). If a malformed frame slips through (or a future MTU change occurs), this will overflow the capture buffer and crash the test binary. Add an assertion that can_data.size <= sizeof(rec.data) (and fail the test if violated), or clamp the copy length to sizeof(rec.data).

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@pavel-kirienko pavel-kirienko marked this pull request as ready for review March 24, 2026 15:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants