This commit is contained in:
parent
7023fe5c42
commit
fb324516bb
@ -33,14 +33,14 @@ ReturnValue_t PapbVcInterface::write(const uint8_t* data, size_t size) {
|
||||
return DirectTmSinkIF::IS_BUSY;
|
||||
}
|
||||
for (size_t idx = 0; idx < size; idx++) {
|
||||
if (pollPapbBusySignal(20) == returnvalue::OK) {
|
||||
if (pollPapbBusySignal(5) == returnvalue::OK) {
|
||||
*(vcBaseReg + DATA_REG_OFFSET) = static_cast<uint32_t>(data[idx]);
|
||||
} else {
|
||||
abortPacketTransfer();
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
}
|
||||
if (pollPapbBusySignal(20) == returnvalue::OK) {
|
||||
if (pollPapbBusySignal(5) == returnvalue::OK) {
|
||||
completePacketTransfer();
|
||||
} else {
|
||||
abortPacketTransfer();
|
||||
|
@ -34,7 +34,7 @@ ReturnValue_t PersistentLogTmStoreTask::performOperation(uint8_t opCode) {
|
||||
if (not someonesBusy) {
|
||||
TaskFactory::delayTask(100);
|
||||
} else if (someFileWasSwapped) {
|
||||
TaskFactory::delayTask(1);
|
||||
TaskFactory::delayTask(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#include <fsfw/tasks/TaskFactory.h>
|
||||
#include <fsfw/timemanager/Stopwatch.h>
|
||||
#include <mission/tmtc/PersistentSingleTmStoreTask.h>
|
||||
#include <unistd.h>
|
||||
|
||||
PersistentSingleTmStoreTask::PersistentSingleTmStoreTask(
|
||||
object_id_t objectId, StorageManagerIF& ipcStore, PersistentTmStoreWithTmQueue& tmStore,
|
||||
@ -10,6 +11,7 @@ PersistentSingleTmStoreTask::PersistentSingleTmStoreTask(
|
||||
dumpContext(eventIfDumpDone) {}
|
||||
|
||||
ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
|
||||
uint32_t dummy = 0;
|
||||
while (true) {
|
||||
// Delay done by the check
|
||||
if (not cyclicStoreCheck()) {
|
||||
@ -18,9 +20,26 @@ ReturnValue_t PersistentSingleTmStoreTask::performOperation(uint8_t opCode) {
|
||||
bool busy = handleOneStore(storeWithQueue, dumpContext);
|
||||
if (not busy) {
|
||||
TaskFactory::delayTask(100);
|
||||
} else if(dumpContext.vcBusyDuringDump) {
|
||||
TaskFactory::delayTask(30);
|
||||
} else if (fileHasSwapped) {
|
||||
TaskFactory::delayTask(1);
|
||||
TaskFactory::delayTask(30);
|
||||
} else if(dumpContext.packetWasDumped and dumpContext.numberOfDumpedPackets % 5 == 0) {
|
||||
TaskFactory::delayTask(30);
|
||||
} else {
|
||||
// dummy++;
|
||||
// if(dummy % 2000 == 0) {
|
||||
// sif::warning << "persistent tm store is stupid" << std::endl;
|
||||
// }
|
||||
TaskFactory::delayTask(2);
|
||||
// continue;
|
||||
}
|
||||
dummy = 0;
|
||||
//else if(dumpContext.numberOfDumpedPackets % 20 == 0) {
|
||||
// Manual load management because I don't know what the scheduler is doing..
|
||||
// Removing this delay can lead to evil side effects.
|
||||
//TaskFactory::delayTask(5);
|
||||
//}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -17,23 +17,33 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store,
|
||||
bool tmToStoreReceived = false;
|
||||
bool tcRequestReceived = false;
|
||||
bool dumpsPerformed = false;
|
||||
fileHasSwapped = false;
|
||||
|
||||
// Store TM persistently
|
||||
result = store.handleNextTm();
|
||||
if (result == returnvalue::OK) {
|
||||
tmToStoreReceived = true;
|
||||
}
|
||||
dumpContext.vcBusyDuringDump = false;
|
||||
// Dump TMs when applicable
|
||||
if (store.getState() == PersistentTmStore::State::DUMPING) {
|
||||
size_t dumpedLen = 0;
|
||||
if (not channel.isBusy()) {
|
||||
dumpContext.ptmeBusyCounter = 0;
|
||||
tmSinkBusyCd.resetTimer();
|
||||
result = store.dumpNextPacket(channel, dumpedLen, fileHasSwapped);
|
||||
bool fileHasSwappedLocal = false;
|
||||
result = store.dumpNextPacket(channel, dumpedLen, fileHasSwappedLocal);
|
||||
if (result == DirectTmSinkIF::IS_BUSY) {
|
||||
sif::warning << "Unexpected PAPB busy" << std::endl;
|
||||
}
|
||||
if ((result == PersistentTmStore::DUMP_DONE or result == returnvalue::OK) and dumpedLen > 0) {
|
||||
dumpContext.dumpedBytes += dumpedLen;
|
||||
dumpContext.numberOfDumpedPackets += 1;
|
||||
dumpContext.packetWasDumped = true;
|
||||
// Only register file swaps if more than 0 bytes were dumped.
|
||||
if(fileHasSwappedLocal) {
|
||||
fileHasSwapped = true;
|
||||
}
|
||||
}
|
||||
if (result == PersistentTmStore::DUMP_DONE) {
|
||||
uint32_t startTime;
|
||||
@ -46,11 +56,16 @@ bool TmStoreTaskBase::handleOneStore(PersistentTmStoreWithTmQueue& store,
|
||||
dumpsPerformed = true;
|
||||
}
|
||||
} else {
|
||||
dumpContext.vcBusyDuringDump = true;
|
||||
dumpContext.ptmeBusyCounter++;
|
||||
if (dumpContext.ptmeBusyCounter == 50) {
|
||||
// If this happens, something is probably wrong.
|
||||
sif::warning << "PTME busy for longer period. Dumped length so far: "
|
||||
<< dumpContext.dumpedBytes << std::endl;
|
||||
dumpContext.ptmeBusyCounter = 0;
|
||||
triggerEvent(persTmStore::DUMP_WAS_CANCELLED, store.getObjectId());
|
||||
store.cancelDump();
|
||||
channel.cancelTransfer();
|
||||
}
|
||||
}
|
||||
if (cancelDumpCd.hasTimedOut() or tmSinkBusyCd.hasTimedOut()) {
|
||||
|
@ -17,6 +17,8 @@ class TmStoreTaskBase : public SystemObject {
|
||||
uint32_t numberOfDumpedPackets = 0;
|
||||
uint32_t dumpedBytes = 0;
|
||||
uint32_t ptmeBusyCounter = 0;
|
||||
bool packetWasDumped = false;
|
||||
bool vcBusyDuringDump = false;
|
||||
};
|
||||
|
||||
TmStoreTaskBase(object_id_t objectId, StorageManagerIF& ipcStore, VirtualChannel& channel,
|
||||
@ -43,7 +45,7 @@ class TmStoreTaskBase : public SystemObject {
|
||||
// 20 minutes are allowed as maximum dump time.
|
||||
Countdown cancelDumpCd = Countdown(60 * 20 * 1000);
|
||||
// If the TM sink is busy for 1 minute for whatever reason, cancel the dump.
|
||||
Countdown tmSinkBusyCd = Countdown(60 * 1000);
|
||||
Countdown tmSinkBusyCd = Countdown(60 * 20 * 1000);//Countdown(60 * 1000 );
|
||||
VirtualChannel& channel;
|
||||
bool storesInitialized = false;
|
||||
bool fileHasSwapped = false;
|
||||
|
@ -1,12 +1,12 @@
|
||||
#include "VirtualChannel.h"
|
||||
|
||||
VirtualChannel::VirtualChannel(object_id_t objectId, uint8_t vcId, const char* vcName, PtmeIF& ptme,
|
||||
const std::atomic_bool& linkStateProvider)
|
||||
const std::atomic_bool& txOn)
|
||||
: SystemObject(objectId),
|
||||
ptme(ptme),
|
||||
vcId(vcId),
|
||||
vcName(vcName),
|
||||
linkStateProvider(linkStateProvider) {}
|
||||
txOn(txOn) {}
|
||||
|
||||
ReturnValue_t VirtualChannel::initialize() { return returnvalue::OK; }
|
||||
|
||||
@ -15,10 +15,10 @@ ReturnValue_t VirtualChannel::sendNextTm(const uint8_t* data, size_t size) {
|
||||
}
|
||||
|
||||
ReturnValue_t VirtualChannel::write(const uint8_t* data, size_t size) {
|
||||
if (linkStateProvider.load()) {
|
||||
//if (txOn) {
|
||||
return ptme.writeToVc(vcId, data, size);
|
||||
}
|
||||
return returnvalue::OK;
|
||||
//}
|
||||
//return returnvalue::OK;
|
||||
}
|
||||
|
||||
uint8_t VirtualChannel::getVcid() const { return vcId; }
|
||||
@ -27,9 +27,9 @@ const char* VirtualChannel::getName() const { return vcName.c_str(); }
|
||||
|
||||
bool VirtualChannel::isBusy() const {
|
||||
// Data is discarded, so channel is not busy.
|
||||
if (linkStateProvider.load()) {
|
||||
return false;
|
||||
}
|
||||
//if (not txOn) {
|
||||
// return false;
|
||||
//}
|
||||
return ptme.isBusy(vcId);
|
||||
}
|
||||
|
||||
|
@ -37,5 +37,5 @@ class VirtualChannel : public SystemObject, public VirtualChannelIF {
|
||||
PtmeIF& ptme;
|
||||
uint8_t vcId = 0;
|
||||
std::string vcName;
|
||||
const std::atomic_bool& linkStateProvider;
|
||||
const std::atomic_bool& txOn;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user