Skip to content

Commit

Permalink
Always send back a feedback packet, even if empty. (#452)
Browse files Browse the repository at this point in the history
This PR ensures that the railcom driver sends back at least one feedback
packet for each track packet, even if no railcom feedback was received.
  • Loading branch information
balazsracz authored Oct 19, 2020
1 parent be87ee7 commit f6264bc
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/freertos_drivers/ti/TivaRailcom.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ private:
void end_cutout() OVERRIDE
{
HW::disable_measurement();
bool have_packets = false;
for (unsigned i = 0; i < ARRAYSIZE(HW::UART_BASE); ++i)
{
while (MAP_UARTCharsAvail(HW::UART_BASE[i]))
Expand Down Expand Up @@ -431,12 +432,25 @@ private:
Debug::RailcomRxActivate::set(false);
//HWREGBITW(HW::UART_BASE[i] + UART_O_CTL, UART_CTL_RXE) = 0;
if (returnedPackets_[i]) {
have_packets = true;
this->feedbackQueue_.commit_back();
Debug::RailcomPackets::toggle();
returnedPackets_[i] = nullptr;
MAP_IntPendSet(HW::OS_INTERRUPT);
}
}
if (!have_packets)
{
// Ensures that at least one feedback packet is sent back even when
// it is with no railcom payload.
auto *p = this->alloc_new_packet(0);
if (p)
{
this->feedbackQueue_.commit_back();
Debug::RailcomPackets::toggle();
MAP_IntPendSet(HW::OS_INTERRUPT);
}
}
Debug::RailcomCh2Data::set(false);
Debug::RailcomDriverCutout::set(false);
}
Expand Down

0 comments on commit f6264bc

Please sign in to comment.