refactored throttle handling
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-main This commit looks good
This commit is contained in:
@ -53,11 +53,14 @@ ReturnValue_t LiveTmTask::performOperation(uint8_t opCode) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (channel.isBusy() and not signals::CFDP_CHANNEL_THROTTLE_SIGNAL) {
|
||||
if (channel.isBusy() and !throttlePeriodOngoing) {
|
||||
// Throttle CFDP packet creator. It is by far the most relevant data creator, so throttling
|
||||
// it is the easiest way to handle back pressure for now in a sensible way. It is cleared
|
||||
// by the data creator.
|
||||
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = true;
|
||||
// it is the easiest way to handle back pressure for now in a sensible way.
|
||||
throttleCfdp();
|
||||
} else if(!channel.isBusy() and throttlePeriodOngoing) {
|
||||
if(minimumPeriodThrottleCd.hasTimedOut()) {
|
||||
releaseCfdp();
|
||||
}
|
||||
}
|
||||
if (!handledTm) {
|
||||
if (tmFunnelCd.hasTimedOut()) {
|
||||
@ -164,7 +167,7 @@ ReturnValue_t LiveTmTask::handleGenericTmQueue(MessageQueueIF& queue) {
|
||||
result = channel.write(data, size, partiallyWrittenSize);
|
||||
if (result == DirectTmSinkIF::PARTIALLY_WRITTEN) {
|
||||
// Already throttle CFDP.
|
||||
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = true;
|
||||
throttleCfdp();
|
||||
result = channel.handleLastWriteSynchronously(data, size, partiallyWrittenSize, 200);
|
||||
if (result != returnvalue::OK) {
|
||||
// TODO: Event? Might lead to dangerous spam though..
|
||||
@ -180,6 +183,17 @@ ReturnValue_t LiveTmTask::handleGenericTmQueue(MessageQueueIF& queue) {
|
||||
return result;
|
||||
}
|
||||
|
||||
void LiveTmTask::throttleCfdp() {
|
||||
throttlePeriodOngoing = true;
|
||||
minimumPeriodThrottleCd.resetTimer();
|
||||
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = true;
|
||||
}
|
||||
|
||||
void LiveTmTask::releaseCfdp() {
|
||||
throttlePeriodOngoing = false;
|
||||
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = false;
|
||||
}
|
||||
|
||||
ModeTreeChildIF& LiveTmTask::getModeTreeChildIF() { return *this; }
|
||||
|
||||
ReturnValue_t LiveTmTask::initialize() {
|
||||
|
@ -39,6 +39,10 @@ class LiveTmTask : public SystemObject,
|
||||
CfdpTmFunnel& cfdpFunnel;
|
||||
VirtualChannel& channel;
|
||||
const std::atomic_bool& ptmeLocked;
|
||||
// This countdown ensures that the CFDP is always throttled with a minimum period. Only after
|
||||
// this period, the CFDP can be released if the channel is not busy.
|
||||
Countdown minimumPeriodThrottleCd = Countdown(40);
|
||||
bool throttlePeriodOngoing = false;
|
||||
|
||||
void readCommandQueue(void);
|
||||
|
||||
@ -56,6 +60,8 @@ class LiveTmTask : public SystemObject,
|
||||
void startTransition(Mode_t mode, Submode_t submode) override;
|
||||
|
||||
void announceMode(bool recursive) override;
|
||||
void throttleCfdp();
|
||||
void releaseCfdp();
|
||||
|
||||
object_id_t getObjectId() const override;
|
||||
const HasHealthIF* getOptHealthIF() const override;
|
||||
|
@ -58,6 +58,7 @@ ReturnValue_t VirtualChannel::handleLastWriteSynchronously(const uint8_t* data,
|
||||
delayMs += 10;
|
||||
continue;
|
||||
}
|
||||
sif::debug << "last write after" << delayMs << std::endl;
|
||||
return finishWrite(data, start, remLen);
|
||||
}
|
||||
return returnvalue::FAILED;
|
||||
|
Reference in New Issue
Block a user