this is even better
All checks were successful
EIVE/eive-obsw/pipeline/pr-cfdp-source-handler This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-cfdp-source-handler This commit looks good
This commit is contained in:
parent
a47ad98d90
commit
e7709b7091
@ -58,16 +58,9 @@ ReturnValue_t LiveTmTask::performOperation(uint8_t opCode) {
|
|||||||
<< result << std::dec << std::endl;
|
<< result << std::dec << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (channelIsBusy and !throttlePeriodOngoing) {
|
|
||||||
// Throttle CFDP packet creator. It is by far the most relevant data creator, so throttling
|
cfdpBackpressureHandling();
|
||||||
// it is the easiest way to handle back pressure for now in a sensible way.
|
|
||||||
throttleCfdp();
|
|
||||||
} 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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (!handledTm) {
|
if (!handledTm) {
|
||||||
if (tmFunnelCd.hasTimedOut()) {
|
if (tmFunnelCd.hasTimedOut()) {
|
||||||
pusFunnel.performOperation(0);
|
pusFunnel.performOperation(0);
|
||||||
@ -159,9 +152,10 @@ ReturnValue_t LiveTmTask::handleGenericTmQueue(MessageQueueIF& queue, bool isCfd
|
|||||||
if (result == MessageQueueIF::EMPTY) {
|
if (result == MessageQueueIF::EMPTY) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
if (signals::CFDP_MSG_COUNTER > 0) {
|
if (isCfdp and signals::CFDP_MSG_COUNTER > 0) {
|
||||||
signals::CFDP_MSG_COUNTER--;
|
signals::CFDP_MSG_COUNTER--;
|
||||||
}
|
}
|
||||||
|
sif::debug << "CFDP msg counter: " << signals::CFDP_MSG_COUNTER << std::endl;
|
||||||
store_address_t storeId = message.getStorageId();
|
store_address_t storeId = message.getStorageId();
|
||||||
const uint8_t* data = nullptr;
|
const uint8_t* data = nullptr;
|
||||||
size_t size = 0;
|
size_t size = 0;
|
||||||
@ -177,17 +171,12 @@ ReturnValue_t LiveTmTask::handleGenericTmQueue(MessageQueueIF& queue, bool isCfd
|
|||||||
size_t writtenSize = 0;
|
size_t writtenSize = 0;
|
||||||
result = channel.write(data, size, writtenSize);
|
result = channel.write(data, size, writtenSize);
|
||||||
if (result == DirectTmSinkIF::PARTIALLY_WRITTEN) {
|
if (result == DirectTmSinkIF::PARTIALLY_WRITTEN) {
|
||||||
// Already throttle CFDP.
|
|
||||||
throttleCfdp();
|
|
||||||
result = channel.handleWriteCompletionSynchronously(writtenSize, 200);
|
result = channel.handleWriteCompletionSynchronously(writtenSize, 200);
|
||||||
if (result != returnvalue::OK) {
|
if (result != returnvalue::OK) {
|
||||||
// TODO: Event? Might lead to dangerous spam though..
|
// TODO: Event? Might lead to dangerous spam though..
|
||||||
sif::warning << "LiveTmTask: Synchronous write of last segment failed with code 0x"
|
sif::warning << "LiveTmTask: Synchronous write of last segment failed with code 0x"
|
||||||
<< std::setw(4) << std::hex << result << std::dec << std::endl;
|
<< 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
|
// Try delete in any case, ignore failures (which should not happen), it is more important to
|
||||||
@ -199,11 +188,13 @@ ReturnValue_t LiveTmTask::handleGenericTmQueue(MessageQueueIF& queue, bool isCfd
|
|||||||
void LiveTmTask::throttleCfdp() {
|
void LiveTmTask::throttleCfdp() {
|
||||||
throttlePeriodOngoing = true;
|
throttlePeriodOngoing = true;
|
||||||
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = true;
|
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = true;
|
||||||
|
sif::debug << "throttling CFDP" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LiveTmTask::releaseCfdp() {
|
void LiveTmTask::releaseCfdp() {
|
||||||
throttlePeriodOngoing = false;
|
throttlePeriodOngoing = false;
|
||||||
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = false;
|
signals::CFDP_CHANNEL_THROTTLE_SIGNAL = false;
|
||||||
|
sif::debug << "releasing CFDP" << std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LiveTmTask::updateBusyFlag() {
|
void LiveTmTask::updateBusyFlag() {
|
||||||
@ -211,6 +202,21 @@ void LiveTmTask::updateBusyFlag() {
|
|||||||
channelIsBusy = channel.isBusy();
|
channelIsBusy = channel.isBusy();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void LiveTmTask::cfdpBackpressureHandling() {
|
||||||
|
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.
|
||||||
|
if (signals::CFDP_MSG_COUNTER >= (config::LIVE_CHANNEL_CFDP_QUEUE_SIZE / 2)) {
|
||||||
|
throttleCfdp();
|
||||||
|
}
|
||||||
|
} 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 / 4)) {
|
||||||
|
releaseCfdp();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ModeTreeChildIF& LiveTmTask::getModeTreeChildIF() { return *this; }
|
ModeTreeChildIF& LiveTmTask::getModeTreeChildIF() { return *this; }
|
||||||
|
|
||||||
ReturnValue_t LiveTmTask::initialize() {
|
ReturnValue_t LiveTmTask::initialize() {
|
||||||
|
@ -56,6 +56,8 @@ class LiveTmTask : public SystemObject,
|
|||||||
|
|
||||||
void getMode(Mode_t* mode, Submode_t* submode) override;
|
void getMode(Mode_t* mode, Submode_t* submode) override;
|
||||||
|
|
||||||
|
void cfdpBackpressureHandling();
|
||||||
|
|
||||||
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
ReturnValue_t checkModeCommand(Mode_t mode, Submode_t submode,
|
||||||
uint32_t* msToReachTheMode) override;
|
uint32_t* msToReachTheMode) override;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user