Skip to content

Commit

Permalink
[xpcc] Separate the rx handling part of the update fct of the dispatcher
Browse files Browse the repository at this point in the history
Call that separated function instead
and have it available as a public function as well.
  • Loading branch information
se-bi committed Mar 14, 2023
1 parent 8a3a20b commit 2273bae
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
27 changes: 18 additions & 9 deletions src/modm/communication/xpcc/dispatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ xpcc::Dispatcher::update()

//Check if a new packet was received by the backend
while (this->backend->isPacketAvailable())
{
this->updateOnceRx();
this->backend->dropPacket();
}

// check if there are packets to send
this->handleWaitingMessages();
}

void
xpcc::Dispatcher::updateOnceRx()
{
//Check if a new packet was received by the backend
if (this->backend->isPacketAvailable())
{
const Header& header = this->backend->getPacketHeader();
const modm::SmartPointer& payload = this->backend->getPacketPayload();
Expand All @@ -46,17 +60,12 @@ xpcc::Dispatcher::update()
{
const bool is_response = this->handlePacket(header, payload);
if (!header.isAcknowledge && header.destination != 0)
{
if (is_response or postman->isComponentAvailable(header.destination))
this->sendAcknowledge(header);
}
{
if (is_response or postman->isComponentAvailable(header.destination))
this->sendAcknowledge(header);
}
}

this->backend->dropPacket();
}

// check if there are packets to send
this->handleWaitingMessages();
}

void
Expand Down
3 changes: 3 additions & 0 deletions src/modm/communication/xpcc/dispatcher.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,9 @@ namespace xpcc
void
update();

void
updateOnceRx();

private:
/// Does not handle requests which are not acknowledge.
bool
Expand Down

0 comments on commit 2273bae

Please sign in to comment.