start groundwork for new TM downlink arch

This commit is contained in:
2023-03-09 01:32:27 +01:00
parent c1b43bb504
commit 21899d663e
24 changed files with 379 additions and 266 deletions

View File

@ -7,12 +7,12 @@
#include "fsfw/serviceinterface/ServiceInterfaceStream.h"
#include "fsfw/tmtcservices/TmTcMessage.h"
VirtualChannel::VirtualChannel(uint8_t vcId, uint32_t tmQueueDepth, object_id_t ownerId)
: vcId(vcId) {
auto mqArgs = MqArgs(ownerId, reinterpret_cast<void*>(vcId));
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);
vcName = "VC " + vcId;
}
ReturnValue_t VirtualChannel::initialize() {
@ -24,38 +24,40 @@ ReturnValue_t VirtualChannel::initialize() {
return returnvalue::OK;
}
ReturnValue_t VirtualChannel::performOperation() {
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;
}
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;
if (linkIsUp) {
result = ptme->writeToVc(vcId, data, size);
}
tmStore->deleteData(storeId);
return result;
}
if (result != returnvalue::OK) {
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;
count++;
if (count == 500) {
sif::error << "VirtualChannel: Possible message storm detected" << std::endl;
break;
}
}
}
return result;
return returnvalue::FAILED;
}
MessageQueueId_t VirtualChannel::getReportReceptionQueue(uint8_t virtualChannel) const {