Skip to content

Commit

Permalink
[amnb] Remove unnecessary while(1) loops
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Oct 24, 2024
1 parent 24f16e1 commit d0a2051
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions src/modm/communication/amnb/node.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,15 +137,11 @@ class Node : public modm::Resumable<6>
transmit()
{
RF_BEGIN(2);
while(1)
if (not tx_queue.isEmpty())
{
if (not tx_queue.isEmpty())
{
RF_WAIT_WHILE(is_sending);
RF_CALL(send(tx_queue.get()));
tx_queue.pop();
}
RF_YIELD();
RF_WAIT_WHILE(is_sending);
RF_CALL(send(tx_queue.get()));
tx_queue.pop();
}
RF_END();
}
Expand Down Expand Up @@ -206,21 +202,17 @@ class Node : public modm::Resumable<6>
receive()
{
RF_BEGIN(5);
while(1)
rx_msg.deallocate(); // deallocates previous message
if (RF_CALL(interface.receiveHeader(&rx_msg)) == InterfaceStatus::Ok)
{
rx_msg.deallocate(); // deallocates previous message
if (RF_CALL(interface.receiveHeader(&rx_msg)) == InterfaceStatus::Ok)
// Check lists if we are interested in this message
is_rx_msg_for_us = handleRxMessage(false);
// Receive the message data, only allocate if it's for us
if (RF_CALL(interface.receiveData(&rx_msg, is_rx_msg_for_us)) == InterfaceStatus::Ok)
{
// Check lists if we are interested in this message
is_rx_msg_for_us = handleRxMessage(false);
// Receive the message data, only allocate if it's for us
if (RF_CALL(interface.receiveData(&rx_msg, is_rx_msg_for_us)) == InterfaceStatus::Ok)
{
// Only handle message *with* data if it's for us
if (is_rx_msg_for_us) handleRxMessage(true);
}
// Only handle message *with* data if it's for us
if (is_rx_msg_for_us) handleRxMessage(true);
}
RF_YIELD();
}
RF_END();
}
Expand Down

0 comments on commit d0a2051

Please sign in to comment.