Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[xpcc] Separate the rx handling part of the update fct of the dispatcher #970

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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();
rleh marked this conversation as resolved.
Show resolved Hide resolved
}

// 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);
}
se-bi marked this conversation as resolved.
Show resolved Hide resolved
}

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