Skip to content

Commit

Permalink
init commit
Browse files Browse the repository at this point in the history
Signed-off-by: ismetatabay <[email protected]>
  • Loading branch information
ismetatabay committed Jan 25, 2024
1 parent 8996cdb commit 44c0676
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions ros2_socketcan/src/socket_can_id.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,13 @@ CanId & CanId::identifier(const IdT id)
constexpr auto MAX_STANDARD = 0x07EFU;
static_assert(MAX_EXTENDED <= EXTENDED_ID_MASK, "Max extended id value is wrong");
static_assert(MAX_STANDARD <= STANDARD_ID_MASK, "Max extended id value is wrong");
const auto max_id = is_extended() ? MAX_EXTENDED : MAX_STANDARD;
if (max_id < id) {
auto max_id = MAX_STANDARD;
auto unmasked_id = id;
if (is_extended()) {
max_id = MAX_EXTENDED;
unmasked_id = id & ~(EXTENDED_MASK);
}
if (max_id < unmasked_id) {
throw std::domain_error{"CanId would be truncated!"};
}
// Clear and set
Expand Down

0 comments on commit 44c0676

Please sign in to comment.