maybe this works better?
All checks were successful
EIVE/eive-obsw/pipeline/head This commit looks good

This commit is contained in:
Robin Müller 2023-10-13 14:20:50 +02:00
parent be1fb22e39
commit 2279eab5e7
Signed by: muellerr
GPG Key ID: FCE0B2BD2195142F
2 changed files with 15 additions and 4 deletions

View File

@ -37,7 +37,8 @@ ReturnValue_t LiveTmTask::performOperation(uint8_t opCode) {
// TODO: Must read CFDP TM queue and regular TM queue and forward them. Handle regular queue
// first.
handledTm = false;
if (!channel.isBusy()) {
updateBusyFlag();
if (!channelIsBusy) {
result = handleRegularTmQueue();
if (result == MessageQueueIF::EMPTY) {
result = handleCfdpTmQueue();
@ -54,14 +55,14 @@ ReturnValue_t LiveTmTask::performOperation(uint8_t opCode) {
}
}
}
if (channel.isBusy()) {
if (channelIsBusy) {
sif::debug << "busy" << std::endl;
}
if (channel.isBusy() and !throttlePeriodOngoing) {
if (channelIsBusy 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.
throttleCfdp();
} else if (!channel.isBusy() and throttlePeriodOngoing) {
} else if (!channelIsBusy and throttlePeriodOngoing) {
// Half full/empty flow control: Release the CFDP is the queue is empty enough.
if (signals::CFDP_MSG_COUNTER <= config::LIVE_CHANNEL_CFDP_QUEUE_SIZE / 2) {
releaseCfdp();
@ -184,6 +185,9 @@ ReturnValue_t LiveTmTask::handleGenericTmQueue(MessageQueueIF& queue, bool isCfd
sif::warning << "LiveTmTask: Synchronous write of last segment failed with code 0x"
<< std::setw(4) << std::hex << result << std::dec << std::endl;
}
// This is a bit of a hack: If a partial write was performed and synchronously finished, we
// treat this like a busy channel.
channelIsBusy = true;
}
}
// Try delete in any case, ignore failures (which should not happen), it is more important to
@ -204,6 +208,11 @@ void LiveTmTask::releaseCfdp() {
sif::debug << "releasing CFDP" << std::endl;
}
void LiveTmTask::updateBusyFlag() {
// We cache this as a member, because the busy bit can toggle very quickly..
channelIsBusy = channel.isBusy();
}
ModeTreeChildIF& LiveTmTask::getModeTreeChildIF() { return *this; }
ReturnValue_t LiveTmTask::initialize() {

View File

@ -47,6 +47,7 @@ class LiveTmTask : public SystemObject,
// this period, the CFDP can be released if the channel is not busy.
// Countdown minimumPeriodThrottleCd = Countdown(config::CFDP_THROTTLE_PERIOD_MS);
bool throttlePeriodOngoing = false;
bool channelIsBusy = false;
void readCommandQueue(void);
@ -66,6 +67,7 @@ class LiveTmTask : public SystemObject,
void announceMode(bool recursive) override;
void throttleCfdp();
void releaseCfdp();
void updateBusyFlag();
object_id_t getObjectId() const override;
const HasHealthIF* getOptHealthIF() const override;