Skip to content

Commit

Permalink
Fix: do not automatically assume a MTU != CANARD_MTU_CAN_CLASSIC (8) …
Browse files Browse the repository at this point in the history
…is CAN_FD, do a dedicated check instead. (#260)
  • Loading branch information
aentinger committed Nov 8, 2023
1 parent cdf3dc9 commit dd6a8b5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/CanRxQueueItem.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,7 @@ namespace cyphal
template<size_t MTU_BYTES>
class CanRxQueueItem
{
static_assert((MTU_BYTES
== CANARD_MTU_CAN_CLASSIC) || (MTU_BYTES == CANARD_MTU_CAN_FD),
static_assert((MTU_BYTES == CANARD_MTU_CAN_CLASSIC) || (MTU_BYTES == CANARD_MTU_CAN_FD),
"CanRxQueueItem can only have an MTU size of either 8 (CANARD_MTU_CAN_CLASSIC) or 64 (CANARD_MTU_CAN_FD).");
public:
CanRxQueueItem()
Expand Down
4 changes: 2 additions & 2 deletions src/Node.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ void Node::onCanFrameReceived(CanardFrame const & frame)
CanRxQueueItem<CANARD_MTU_CAN_CLASSIC> const rx_queue_item(&frame, _micros_func());
static_cast<CircularBufferCan *>(_canard_rx_queue.get())->enqueue(rx_queue_item);
}
else
else if (_mtu_bytes == CANARD_MTU_CAN_FD)
{
CanRxQueueItem<CANARD_MTU_CAN_FD> const rx_queue_item(&frame, _micros_func());
static_cast<CircularBufferCanFd *>(_canard_rx_queue.get())->enqueue(rx_queue_item);
Expand Down Expand Up @@ -172,7 +172,7 @@ void Node::processRxQueue()
processRxFrame(rx_queue_item);
can_rx_queue_ptr->pop();
}
else
else if (_mtu_bytes == CANARD_MTU_CAN_FD)
{
CircularBufferCanFd * canfd_rx_queue_ptr = static_cast<CircularBufferCanFd *>(_canard_rx_queue.get());
CanRxQueueItem<CANARD_MTU_CAN_FD> const * rx_queue_item = canfd_rx_queue_ptr->peek();
Expand Down

0 comments on commit dd6a8b5

Please sign in to comment.