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