continue TM handling refactoring
Some checks failed
EIVE/eive-obsw/pipeline/pr-develop There was a failure building this commit

This commit is contained in:
2023-03-09 17:44:05 +01:00
parent eb61996f91
commit 96865c1dd2
22 changed files with 396 additions and 220 deletions

View File

@ -1,77 +1,26 @@
#include "VirtualChannel.h"
#include "CcsdsIpCoreHandler.h"
#include "OBSWConfig.h"
#include "fsfw/ipc/QueueFactory.h"
#include "fsfw/objectmanager/ObjectManager.h"
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
VirtualChannel::VirtualChannel(object_id_t objectId, uint8_t vcId, const char* vcName, PtmeIF& ptme,
const std::atomic_bool& linkStateProvider)
: SystemObject(objectId),
vcId(vcId),
vcName(vcName),
ptme(ptme),
linkStateProvider(linkStateProvider) {}
VirtualChannel::VirtualChannel(object_id_t objectId, uint8_t vcId, const char* vcName,
uint32_t tmQueueDepth)
: SystemObject(objectId), vcId(vcId), vcName(vcName) {
auto mqArgs = MqArgs(objectId, reinterpret_cast<void*>(vcId));
tmQueue = QueueFactory::instance()->createMessageQueue(
tmQueueDepth, MessageQueueMessage::MAX_MESSAGE_SIZE, &mqArgs);
ReturnValue_t VirtualChannel::initialize() { return returnvalue::OK; }
ReturnValue_t VirtualChannel::sendNextTm(const uint8_t* data, size_t size) {
return write(data, size);
}
ReturnValue_t VirtualChannel::initialize() {
tmStore = ObjectManager::instance()->get<StorageManagerIF>(objects::TM_STORE);
if (tmStore == nullptr) {
sif::error << "VirtualChannel::initialize: Failed to get tm store" << std::endl;
return returnvalue::FAILED;
ReturnValue_t VirtualChannel::write(const uint8_t* data, size_t size) {
if (linkStateProvider.load()) {
return ptme.writeToVc(vcId, data, size);
}
return returnvalue::OK;
}
ReturnValue_t VirtualChannel::performOperation(uint8_t opCode) {
ReturnValue_t result = returnvalue::OK;
TmTcMessage message;
// To be able to push high datarates, we use a custom permanent loop.
while (true) {
unsigned int count = 0;
while (tmQueue->receiveMessage(&message) == returnvalue::OK) {
store_address_t storeId = message.getStorageId();
const uint8_t* data = nullptr;
size_t size = 0;
result = tmStore->getData(storeId, &data, &size);
if (result != returnvalue::OK) {
sif::warning << "VirtualChannel::performOperation: Failed to read data from TM store"
<< std::endl;
tmStore->deleteData(storeId);
return result;
}
if (linkIsUp) {
result = ptme->writeToVc(vcId, data, size);
}
tmStore->deleteData(storeId);
if (result != returnvalue::OK) {
return result;
}
count++;
if (count == 500) {
sif::error << "VirtualChannel: Possible message storm detected" << std::endl;
break;
}
}
}
return returnvalue::FAILED;
}
MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) const {
return tmQueue->getId();
}
void VirtualChannel::setPtmeObject(PtmeIF* ptme_) {
if (ptme_ == nullptr) {
sif::warning << "VirtualChannel::setPtmeObject: Invalid ptme object" << std::endl;
return;
}
ptme = ptme_;
}
void VirtualChannel::setLinkState(bool linkIsUp_) { linkIsUp = linkIsUp_; }
uint8_t VirtualChannel::getVcid() const { return vcId; }
const char* VirtualChannel::getName() const { return vcName.c_str(); }