Repository navigation
feat(CanMsg): add Remote Transmission Request (RTR) frame support - #284
Open
pruthvi828 wants to merge 1 commit into
Open
pruthvi828 wants to merge 1 commit into
pruthvi828 wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Feature
This PR adds first-class support for Remote Transmission Request (RTR) frames to
CanMsg, closing #230.Background
The CAN standard defines the RTR (Remote Transmission Request) bit in arbitration headers to differentiate remote request frames from data frames. Under Linux SocketCAN (
linux/can.h), whichCanMsg.hexplicitly references in its comment block (lines 127–132):CAN_EFF_FLAG = 0x80000000U)CAN_RTR_FLAG = 0x40000000U)Prior to this PR, bit 30 was marked as
/* reserved (future remote transmission request flag) */, but lacked definition and API helpers, preventing Arduino platforms (such as Renesas Uno R4 Minima/WiFi, ESP32, STM32) from representing or checking for RTR frames.Changes
api/CanMsg.h:static uint32_t constexpr CAN_RTR_FLAG = 0x40000000U;.CanMsg(can_id, len, ptr, bool const rtr = false)with default argumentrtr = falseensuring 100% backward compatibility with all existing code.bool isRtr() const: ReturnstrueifCAN_RTR_FLAGis set.bool isRemote() const: Alias matchingisRtr().CanStandardRtrId(uint32_t const id): Constructs a standard 11-bit ID with RTR flag set.CanExtendedRtrId(uint32_t const id): Constructs an extended 29-bit ID with EFF and RTR flags set.printTo(Print & p)to emitRTRindicator for remote request frames ([020 RTR] (0) :) while leaving standard data frame output identical.Tests (
test/src/CanMsg/):test_isRtr.cppwith Catch2 test cases covering standard RTR, extended RTR, constructor flag, and false assertions on standard data frames.test_printTo.cppwith test cases for standard RTR and extended RTR frame serialization.test_isRtr.cppintest/CMakeLists.txt.Verification
clang++(-std=c++11 -Wall -Wextra).test/src/CanMsg/retain identical behavior and assertions.Fixes #230