Skip to content

Commit 6d5be76

Browse files
authored
Reduce ProgramsAreAvailableOnCobc() calls (#483)
The function `ProgramsAreAvailableOnCobc()` is called unnecessarily often and should only be called when the EDU is alive.
2 parents 0db15ac + ed314ee commit 6d5be76

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

Sts1CobcSw/Edu/Edu.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
#include <etl/vector.h>
2929

3030
#include <algorithm>
31-
#include <array>
3231
#include <charconv>
3332
#include <cstddef>
3433
#include <cstdint>
@@ -61,8 +60,6 @@ constexpr auto cepData = 0x8b_b; //! Data packet format is used (not a command
6160
// 1.5 s just to be sure.
6261
constexpr auto sendTimeout = 1500 * ms;
6362
constexpr auto receiveTimeout = 1500 * ms;
64-
// TODO: Can we choose a smaller value?
65-
constexpr auto flushReceiveBufferTimeout = 1 * ms;
6663

6764
// TODO: Choose proper values
6865
// Max. number of send retries after receiving NACK

Sts1CobcSw/Firmware/EduPowerManagementThread.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,13 +86,16 @@ class EduPowerManagementThread : public RODOS::StaticThread<stackSize>
8686
nextEduProgramStartTimeBuffer.get(nextEduProgramStartTime);
8787
auto timeTillNextEduProgram = ToRodosTime(nextEduProgramStartTime) - CurrentRodosTime();
8888
auto eduHasUpdate = edu::updateGpioPin.Read() == hal::PinState::set;
89-
auto noWorkMustBeDoneInTheNearFuture =
90-
not eduHasUpdate and not edu::ProgramsAreAvailableOnCobc()
91-
and timeTillNextEduProgram > persistentVariables.Load<"maxEduIdleDuration">();
92-
if(eduIsAlive and noWorkMustBeDoneInTheNearFuture)
89+
if(eduIsAlive)
9390
{
94-
DEBUG_PRINT("Turning EDU off\n");
95-
edu::TurnOff();
91+
auto noWorkMustBeDoneInTheNearFuture =
92+
not eduHasUpdate and not edu::ProgramsAreAvailableOnCobc()
93+
and timeTillNextEduProgram > persistentVariables.Load<"maxEduIdleDuration">();
94+
if(noWorkMustBeDoneInTheNearFuture)
95+
{
96+
DEBUG_PRINT("Turning EDU off\n");
97+
edu::TurnOff();
98+
}
9699
}
97100
else if(not eduIsAlive and timeTillNextEduProgram < (eduBootTime + eduBootTimeMargin))
98101
{

Sts1CobcSw/Firmware/EduProgramTransferThread.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ class EduProgramTransferThread : public RODOS::StaticThread<stackSize>
5151
{
5252
auto eduIsAlive = false;
5353
eduIsAliveBufferForProgramTransfer.get(eduIsAlive);
54-
if(edu::ProgramsAreAvailableOnCobc() and eduIsAlive)
54+
if(eduIsAlive and edu::ProgramsAreAvailableOnCobc())
5555
{
5656
DEBUG_PRINT("Sending programs to EDU\n");
5757
SendProgramsToEdu();

0 commit comments

Comments
 (0)